summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpitfireX <timm.weber@me.com>2015-08-14 04:41:05 +0200
committerSpitfireX <timm.weber@me.com>2015-08-14 04:41:05 +0200
commitd82cca770dc0f1c6ecb900e2b8907abd2b52200d (patch)
tree03175a76f95a49b2c4eb63cbe275e00b60c92b7d
parenta8a2d62f846c8406e10138aa413aa805044d6c82 (diff)
Improved cell weight function
-rw-r--r--strategy.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/strategy.py b/strategy.py
index 5240fd3..0d2d8f0 100644
--- a/strategy.py
+++ b/strategy.py
@@ -86,12 +86,14 @@ class Strategy:
#return density_score
def weight_cell(self, cell):
- df = (1/self.dist(cell))
+ df = (10/self.dist(cell))
if self.edible(cell):
+ quality = self.quality(cell)
if cell.is_food:
- return cell.mass * df
+ return 1 + cell.mass * df * quality
else:
- return cell.mass * df #todo: factor for optimal food mass
+ mf = 1 / ((self.get_my_smallest().mass * 0.75) + 1) - cell.mass
+ return cell.mass * df * quality * mf
elif self.threat(cell):
if cell.is_virus:
return -cell.mass * df * 100
@@ -172,11 +174,9 @@ class Strategy:
self.target = (food[0].pos[0], food[0].pos[1])
self.target_cell = food[0]
- print(self.target_cell.mass)
- print(self.weight_cell(self.target_cell))
-
self.has_target = True
self.color = (0,0,255)
+ print("weight: ", self.weight_cell(self.target_cell))
print("Found food at: " + str(food[0].pos))
else:
rx = self.c.player.center[0] + random.randrange(-400, 401)