Skip to content

Commit

Permalink
More compact code in TilePositionFinder.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentbons committed Jun 4, 2020
1 parent a1d9987 commit 15680a0
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions wingedsheep/carcassonne/utils/tile_position_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,10 @@ def possible_playing_positions(game_state: CarcassonneGameState, tile_to_play: T
continue

for tile_turns in range(0, 4):
if row_index == 0:
top = None
else:
top = game_state.board[row_index - 1][column_index]

if row_index == len(game_state.board) - 1:
bottom = None
else:
bottom = game_state.board[row_index + 1][column_index]

if column_index == 0:
left = None
else:
left = game_state.board[row_index][column_index - 1]

if column_index == len(board_row) - 1:
right = None
else:
right = game_state.board[row_index][column_index + 1]
top = game_state.get_tile(row_index - 1, column_index)
bottom = game_state.get_tile(row_index + 1, column_index)
left = game_state.get_tile(row_index, column_index - 1)
right = game_state.get_tile(row_index, column_index + 1)

if TileFitter.fits(tile_to_play.turn(tile_turns), top=top, bottom=bottom, left=left, right=right, game_state=game_state):
playing_positions.append(PlayingPosition(coordinate=Coordinate(row=row_index, column=column_index), turns=tile_turns))
Expand Down

0 comments on commit 15680a0

Please sign in to comment.