From 1cb3b42adb319d3e15cb98348815ad944f0ab414 Mon Sep 17 00:00:00 2001 From: onezDerv Date: Mon, 2 Sep 2024 14:26:20 -0400 Subject: [PATCH] aggression blaance --- js/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/index.js b/js/index.js index 9acb634..b0b7964 100644 --- a/js/index.js +++ b/js/index.js @@ -44,6 +44,7 @@ function Game(baseMap) { this.baseMap = baseMap; this.colors = {}; this.aggression = {}; + this.strength = {}; } Game.prototype.main = function() { @@ -52,6 +53,7 @@ Game.prototype.main = function() { var data = dat.data; var out = new Uint8Array(4); + for (let k = 0; k < width*height; k++) { let i = k; if (!colonized[i]) continue; @@ -64,7 +66,7 @@ Game.prototype.main = function() { if (isLand(rgba)) setRGBA(data,i,this.colors[colonized[i]]); - let weight = 10; + let weight = 11; let broken = false; @@ -83,7 +85,9 @@ Game.prototype.main = function() { let rgbaH = rgba[0] * 0x10000 + rgba[1] * 0x100 + rgba[2]; let bias = ((rgbaH in BIASES) ? BIASES[rgbaH] : 0.2) / weight; - if (colonized[y2 * width + x2] != 0) bias /= this.aggression[colonized[i]]; + if (colonized[y2 * width + x2] != 0) { + bias *= this.aggression[colonized[i]]; + } if (Math.random() > bias) { continue; @@ -93,6 +97,7 @@ Game.prototype.main = function() { } colonized[y2 * width + x2] = colonized[i2]; + this.strength[colonized[i]]++; broken = true; break; } @@ -140,6 +145,7 @@ Game.prototype.place = function() { colonized[i] = count; this.aggression[count] = Math.random(); this.colors[count] = [Math.floor(Math.random() * 255),Math.floor(Math.random() * 255),Math.floor(Math.random() * 255),255]; + this.strength[count] = 1; } }