self.assertEqual(state1, state2)
def test_export_new_board(self):
- board = GameBoard.new_game([{'actions': [{
- 'action_class': 'LoseHealthOrMSB',
- 'required_bits': [],
- }]}])
+ board = GameBoard.new_game([{'actions': [
+ {
+ 'action_class': 'LoseHealthOrMSB',
+ 'required_bits': [],
+ }, {
+ 'action_class': 'GainHealth',
+ 'required_bits': [BITS.RED],
+ },
+ ]}])
exported_state = board.export()
board_locations = exported_state.pop('board_locations')
self.assertEqual(exported_state, {
'health': 4,
'wins_required': 4,
'wins': 0,
- 'locations': [{'actions': [{
- 'action_class': 'LoseHealthOrMSB',
- 'required_bits': [],
- }]}],
+ 'locations': [{'actions': [
+ {
+ 'action_class': 'LoseHealthOrMSB',
+ 'required_bits': [],
+ }, {
+ 'action_class': 'GainHealth',
+ 'required_bits': [BITS.RED],
+ },
+ ]}],
'player': board.player.export(),
})
- self.assertEqual(
- set(board_locations.keys()),
- set((x, y) for x in range(5) for y in range(5)))
- for location_state in board_locations.values():
+ positions = []
+ for position, location_state in board_locations:
+ positions.append(position)
self.assertEqual(
sorted(location_state.keys()), ['actions', 'bitwise_operand'])
- self.assertEqual(location_state['actions'], [{
- 'action_class': 'LoseHealthOrMSB',
- 'required_bits': [],
- 'data': {},
- }])
+ self.assertEqual(location_state['actions'], [
+ {
+ 'action_class': 'LoseHealthOrMSB',
+ 'required_bits': [],
+ 'data': {},
+ }, {
+ 'action_class': 'GainHealth',
+ 'required_bits': [BITS.RED],
+ 'data': {},
+ },
+ ])
self.assertTrue(2 <= len(location_state['bitwise_operand']) <= 3)
+ self.assertEqual(
+ positions, sorted((x, y) for x in range(5) for y in range(5)))
def test_lose_health(self):
board = GameBoard.new_game([{'actions': []}])