Skip to content

Commit

Permalink
Merge pull request #57 from bcollazo/feature/dql
Browse files Browse the repository at this point in the history
Feature/dql
  • Loading branch information
bcollazo committed Feb 12, 2021
2 parents 50e45ff + 4c2f0ec commit 28b5a16
Show file tree
Hide file tree
Showing 5 changed files with 1,163 additions and 6 deletions.
21 changes: 15 additions & 6 deletions catanatron/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ def winning_player(self):
return player
return None

def play_tick(self, action_callback=None, decide_fn=None):
"""
Consume from queue (player, decision) to support special building phase,
discarding, and other decisions out-of-turn.
If nothing there, fall back to (current, playable()) for current-turn.
"""
def winning_color(self):
player = self.winning_player()
return None if player is None else player.color

def pop_from_queue(self):
"""Important: dont call this without consuming results. O/W illegal state"""
if len(self.tick_queue) > 0:
(seating, action_prompt) = self.tick_queue.pop(0)
player = self.players[seating]
Expand All @@ -164,6 +164,15 @@ def play_tick(self, action_callback=None, decide_fn=None):
action_prompt = (
ActionPrompt.PLAY_TURN if player.has_rolled else ActionPrompt.ROLL
)
return player, action_prompt

def play_tick(self, action_callback=None, decide_fn=None):
"""
Consume from queue (player, decision) to support special building phase,
discarding, and other decisions out-of-turn.
If nothing there, fall back to (current, playable()) for current-turn.
"""
player, action_prompt = self.pop_from_queue()

actions = self.playable_actions(player, action_prompt)
self.branching_factors.append(len(actions)) # for analytics
Expand Down
Loading

0 comments on commit 28b5a16

Please sign in to comment.