summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2015-09-01 20:40:10 +0200
committerFlorian Jung <flo@windfisch.org>2015-09-01 20:40:10 +0200
commit7c1180a7b58e7b8c17c8dab297058d0c001386c6 (patch)
tree76a21545963ba482fa025935b55768b0cfe04276
parente06a42f55444eba9bac38103dbc82425d282a310 (diff)
try to chase less
-rw-r--r--mechanics.py12
-rw-r--r--strategy.py9
2 files changed, 16 insertions, 5 deletions
diff --git a/mechanics.py b/mechanics.py
index 5f2254b..3aaa405 100644
--- a/mechanics.py
+++ b/mechanics.py
@@ -1,5 +1,13 @@
-def speed(size):
- return 86 / (size**0.45)
+from agarnet.agarnet.world import Cell
+
+def speed(size_or_cell):
+ if isinstance(size_or_cell, Cell):
+ if size_or_cell.is_virus or size_or_cell.is_ejected_mass or size_or_cell.is_food:
+ return 0
+ else:
+ return speed(size_or_cell.size)
+ else:
+ return 86 / (size_or_cell**0.45)
def viewport_diag(sizesum):
return 370 * max(sizesum,70)**0.431776
diff --git a/strategy.py b/strategy.py
index eeacc4f..3d5721a 100644
--- a/strategy.py
+++ b/strategy.py
@@ -53,9 +53,12 @@ class Strategy:
def nonsplitkiller(self, cell):
return not cell.is_virus and not cell.is_food and 1.20*self.get_my_smallest().mass < cell.mass and cell.mass < 1.25*2*self.get_my_smallest().mass
- def quality(self, cell):
+ def quality(self, cell, myspeed):
dd_sq = max((cell.pos[0]-self.c.player.center[0])**2 + (cell.pos[1]-self.c.player.center[1])**2,0.001)
- sigma = 500
+ sigma = 500 * max(cell.mass,1) # TODO FIXME don't try to eat running away cells
+ if mechanics.speed(cell) - myspeed >= 0:
+ sigma = sigma / 3 / math.exp((mechanics.speed(cell)-myspeed)/10)
+
dist_score = -math.exp(-dd_sq/(2*sigma**2))
rivals = filter(lambda r : self.rival(r,cell), self.c.world.cells.values())
@@ -283,7 +286,7 @@ class Strategy:
if not self.has_target:
food = list(filter(self.edible, self.c.world.cells.values()))
- food = sorted(food, key = self.quality)
+ food = sorted(food, key = lambda c : self.quality(c, mechanics.speed(my_largest)))
if len(food) > 0:
self.target = (food[0].pos[0], food[0].pos[1])