Skip to content

Commit 7ebe3d4

Browse files
authored
Merge pull request #821 from otizonaizit/shade-size
2 parents 771f928 + 5244376 commit 7ebe3d4

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

pelita/game.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
MAX_FOOD_AGE = 30
3838

3939
#: Food pellet shadow distance
40-
SHADOW_DISTANCE = 3
40+
SHADOW_DISTANCE = 1
4141

4242
class TkViewer:
4343
def __init__(self, *, address, controller, geometry=None, delay=None, stop_after=None, fullscreen=False):

test/test_filter_gamestates.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pelita.layout import parse_layout
1010
from pelita.player import stepping_player
1111
import pelita.utils
12-
12+
import pelita.game
1313

1414
def make_gamestate():
1515
def dummy_team(bot, state):
@@ -774,6 +774,10 @@ def test_relocate_expired_food_nospaceleft():
774774
def test_pacman_resets_age():
775775
# We move bot a across the border
776776
# Once it becomes a bot, the food_age should reset
777+
# XXX: BAD TRICK to make this test work independent of the
778+
# actually configured SHADOW_DISTANCE
779+
old_SHADOW_DISTANCE = pelita.game.SHADOW_DISTANCE
780+
pelita.game.SHADOW_DISTANCE = 3
777781
test_layout = (
778782
""" ##################
779783
# x y#
@@ -807,3 +811,4 @@ def test_pacman_resets_age():
807811
state = play_turn(state)
808812
assert state['turn'] == 3
809813
assert state['food_age'] == [{}, {}]
814+
pelita.game.SHADOW_DISTANCE = old_SHADOW_DISTANCE

test/test_team.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import networkx
55

66
from pelita.layout import parse_layout, get_random_layout, initial_positions
7-
from pelita.game import run_game, setup_game, play_turn
7+
from pelita.game import run_game, setup_game, play_turn, SHADOW_DISTANCE
8+
from pelita.gamestate_filters import manhattan_dist
89

910
def stopping(bot, state):
1011
return bot.position
@@ -395,12 +396,14 @@ def asserting_team(bot, state):
395396

396397
assert bot.walls == tuple(sorted(bot.walls))
397398
assert bot.homezone == tuple(sorted(bot.homezone))
398-
399399
if bot.is_blue:
400400
assert set(bot.homezone) == set(homezones[0])
401401
assert set(bot.enemy[0].homezone) == set(homezones[1])
402-
assert set(bot.shaded_food) == set([(1, 1), (3, 1), (4, 1), (5, 1)])
403-
assert set(bot.other.shaded_food) == set([(1, 1), (3, 1), (4, 1), (5, 1)])
402+
shaded_food = set(food for food in bot.food if
403+
manhattan_dist(bot.position, food) <= SHADOW_DISTANCE or
404+
manhattan_dist(bot.other.position, food) <= SHADOW_DISTANCE)
405+
assert set(bot.shaded_food) == shaded_food
406+
assert set(bot.other.shaded_food) == shaded_food
404407
assert set(bot.enemy[0].shaded_food) == set()
405408
assert set(bot.enemy[1].shaded_food) == set()
406409
else:

0 commit comments

Comments
 (0)