From 990456d976950bde63ca7bb58158a2e93243316e Mon Sep 17 00:00:00 2001 From: Boris Zaitsev Date: Mon, 5 Aug 2019 12:17:03 +0500 Subject: [PATCH 1/2] Update constants.py --- paperio/local_runner/constants.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/paperio/local_runner/constants.py b/paperio/local_runner/constants.py index cae8c51..d57f98c 100644 --- a/paperio/local_runner/constants.py +++ b/paperio/local_runner/constants.py @@ -21,6 +21,8 @@ def parse_json(value, default=None): UP = 'up' DOWN = 'down' +OPPOSITE_DIRECTION = {LEFT: RIGHT, RIGHT: LEFT, UP: DOWN, DOWN: UP, None: None} + SPEED = toint(os.getenv('SPEED'), 5) WIDTH = toint(os.getenv('WIDTH'), 30) # должно делиться на 2 BONUS_CHANCE = toint(os.getenv('BONUS_CHANCE'), 500) # 1 из BONUS_CHANCE From a63cc5a9ce5662145974f0cd9131f7ecba679ecf Mon Sep 17 00:00:00 2001 From: Boris Zaitsev Date: Mon, 5 Aug 2019 12:42:57 +0500 Subject: [PATCH 2/2] check collisions between players without tails --- paperio/local_runner/game_objects/game.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/paperio/local_runner/game_objects/game.py b/paperio/local_runner/game_objects/game.py index 0144c7f..2a2cd28 100644 --- a/paperio/local_runner/game_objects/game.py +++ b/paperio/local_runner/game_objects/game.py @@ -8,7 +8,7 @@ from helpers import is_intersect from constants import WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH, PLAYER_COLORS, MAX_TICK_COUNT, BONUS_CHANCE, \ BONUSES_MAX_COUNT, X_CELLS_COUNT, Y_CELLS_COUNT, SPEED, NEUTRAL_TERRITORY_SCORE, ENEMY_TERRITORY_SCORE, \ - LINE_KILL_SCORE, SAW_KILL_SCORE, AVAILABLE_BONUSES, SAW_SCORE + LINE_KILL_SCORE, SAW_KILL_SCORE, AVAILABLE_BONUSES, SAW_SCORE, OPPOSITE_DIRECTION from game_objects.player import Player from game_objects.bonuses import Nitro, Slowdown, Bonus, Saw @@ -134,6 +134,13 @@ def check_loss(self, player, players): is_loss = True self.append_event('faced with other player', player, p) break + else: + zero_tail_opps = [opp for opp in players if opp != player and len(opp.lines) == 0] + for p in zero_tail_opps: + if is_intersect((player.x, player.y), (p.x, p.y)) and player.direction == OPPOSITE_DIRECTION[p.direction]: + is_loss = True + self.append_event('faced with other player', player, p) + break if len(player.territory.points) == 0: is_loss = True