summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2015-09-22 18:21:27 +0200
committerFlorian Jung <flo@windfisch.org>2015-09-22 18:21:27 +0200
commit6b01cbf241173e9047654eef02786669216e2e9d (patch)
treed2090d763e36e27ba3eaf3522207efef3fa16ab3
parent30e5ff144d20008f1f7f93384f06d254f2e1e1d3 (diff)
mechanics.py++
-rw-r--r--mechanics.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/mechanics.py b/mechanics.py
index 3aaa405..c290a5f 100644
--- a/mechanics.py
+++ b/mechanics.py
@@ -13,3 +13,22 @@ def viewport_diag(sizesum):
return 370 * max(sizesum,70)**0.431776
eject_delta = 22 # how many degrees do ejects deviate from the original direction (maximum)
+
+def get_my_smallest_cell(c):
+ return sorted(c.player.own_cells, key = lambda x: x.mass)[0]
+
+def get_my_largest_cell(c):
+ return sorted(c.player.own_cells, key = lambda x: x.mass)[-1]
+
+def is_enemy(cell, c):
+ return (not cell.same_player(c.player.own_cells[0])) and cell.mass > 1.25 * get_my_smallest_cell(c).mass
+
+def is_splitkiller(cell, c):
+ return (not cell.same_player(c.player.own_cells[0])) and cell.mass > 2.5 * get_my_smallest_cell(c).mass
+
+def is_edible(cell, c):
+ return cell.is_food or cell.is_ejected_mass or ( (not cell.same_player(c.player.own_cells[0])) and not is_enemy(cell,c) and get_my_largest_cell(c).mass > 1.25 * cell.mass )
+
+def is_dangerous_virus(cell, c):
+ return cell.is_virus and (cell.mass < self.get_my_largest().mass)
+