예제 #1
0
 def test_once_move_completed_jumped_pieces_eaten(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ x _#
     #1 _ _ _ _ _ T _ _#
     #2 x _ _ _ x _ _ _#
     #3 _ T _ T _ _ _ _#
     #4 _ _ B _ _ _ _ _#
     #5 _ _ _ x _ _ _ _#
     #6 _ _ _ _ B _ _ _#
     #7 _ _ _ _ _ x _ _#
     # # # # # # # # # #
     self.tboard.place_piece(1, 5, origin.TOP)
     self.tboard.place_piece(3, 1, origin.TOP)
     self.tboard.place_piece(3, 3, origin.TOP)
     self.tboard.place_piece(4, 2, origin.BOTTOM)
     self.tboard.place_piece(6, 4, origin.BOTTOM)
     calc = Movement(self.tboard.game.board, 4, 2)
     moves = calc.get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(4, 2), (2, 0)]), moves[0])
     self.assertEqual(as_move_list([(4, 2), (2, 4), (0, 6)]), moves[1])
     self.tboard.game.current_turn = Turn(self.tboard.game, origin.TOP)
     self.tboard.game.move_piece((4, 2), (2, 4))
     self.tboard.game.move_piece((2, 4), (0, 6))
     
     self.assertIsNone(self.tboard.game.get_piece(4, 2))
     self.assertIsNone(self.tboard.game.get_piece(3, 3))
     self.assertIsNone(self.tboard.game.get_piece(2, 4))
     self.assertIsNone(self.tboard.game.get_piece(1, 5))
     self.assertIsNotNone(self.tboard.game.get_piece(0, 6))
 def test_once_you_move_if_piece_is_adjacent_for_jumping_over_do_not_allow_jump(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ T _ _ _ _ _ _#
     #3 x _ x _ _ _ _ _#
     #4 _ _ _ B _ _ _ _#
     #5 _ _ _ _ _ _ _ _#
     #6 _ _ _ _ _ _ _ _#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(2, 1, origin.TOP)
     self.tboard.place_piece(4, 3, origin.BOTTOM)
     calc = Movement(self.tboard.game.board, 2, 1)
     moves = calc.get_available_moves()
     self.assertEqual(as_move_list([(2, 1), (3, 0)]), moves[0])
     self.assertEqual(as_move_list([(2, 1), (3, 2)]), moves[1])
     
     self.tboard.game.move_piece((2, 1), (3, 2))
     self.assertIsNone(self.tboard.game.current_turn.piece)
     self.tboard.game.move_piece((3, 2), (5, 4))
     self.assertIsNone(self.tboard.game.get_piece(5, 4))
     self.assertIsNotNone(self.tboard.game.get_piece(4, 3))
     self.assertIsNotNone(self.tboard.game.get_piece(3, 2))
예제 #3
0
 def test_cannot_move_opponent_piece_while_player_move_not_complete(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ _ _ T _ _ _ _#
     #3 _ _ B _ B _ _ _#
     #4 _ x _ _ _ x _ _#
     #5 _ _ B _ _ _ _ _#
     #6 _ _ _ x _ _ _ _#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(2, 3, origin.TOP)
     self.tboard.place_piece(3, 2, origin.BOTTOM)
     self.tboard.place_piece(3, 4, origin.BOTTOM)
     self.tboard.place_piece(5, 2, origin.BOTTOM)
     calc = Movement(self.tboard.game.board, 2, 3)
     moves = calc.get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(2, 3), (4, 1), (6, 3)]), moves[0])
     self.assertEqual(as_move_list([(2, 3), (4, 5)]), moves[1])
     
     self.tboard.game.move_piece((2, 3), (4, 1))
     self.assertIsNone(self.tboard.game.get_piece(2, 3))
     self.assertIsNotNone(self.tboard.game.get_piece(4, 1))
     
     self.tboard.game.move_piece((3, 2), (2, 1))
     self.assertIsNotNone(self.tboard.game.get_piece(3, 2))
     self.assertIsNone(self.tboard.game.get_piece(2, 1))
예제 #4
0
 def test_king_can_move_around_and_stuff_stays_consistent(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 x _ x _ _ _ _ _#
     #2 _ t _ _ _ x _ _#
     #3 x _ B _ B _ _ _#
     #4 _ _ _ x _ _ _ _#
     #5 _ _ _ _ _ _ _ _#
     #6 _ _ _ _ _ _ _ _#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_king(2, 1, origin.TOP)
     self.tboard.place_piece(3, 2, origin.BOTTOM)
     self.tboard.place_piece(3, 4, origin.BOTTOM)
     calc = Movement(self.tboard.game.board, 2, 1)
     moves = calc.get_available_moves()
     self.assertEqual(4, len(moves))
     self.assertEqual(as_move_list([(2, 1), (1, 0)]), moves[0])
     self.assertEqual(as_move_list([(2, 1), (1, 2)]), moves[1])
     self.assertEqual(as_move_list([(2, 1), (3, 0)]), moves[2])
     self.assertEqual(as_move_list([(2, 1), (4, 3), (2, 5)]), moves[3])
     
     self.tboard.game.move_piece((2, 1), (4, 3))
     self.assertIsNone(self.tboard.game.get_piece(2, 1))
     self.assertIsNotNone(self.tboard.game.get_piece(3, 2))
     self.assertIsNotNone(self.tboard.game.get_piece(4, 3))
     
     self.assertTrue(self.tboard.game.get_piece(4, 3).is_king())
     
     self.tboard.game.move_piece((4, 3), (2, 5))
     self.assertIsNone(self.tboard.game.get_piece(3, 2))
     self.assertIsNone(self.tboard.game.get_piece(3, 4))
     self.assertIsNotNone(self.tboard.game.get_piece(2, 5))
예제 #5
0
 def test_move_backwards_within_turn_and_then_keep_going(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ _ _ _ _ _ _ _#
     #3 _ T _ T _ _ _ _#
     #4 _ _ B _ _ _ _ _#
     #5 _ x _ _ _ _ _ _#
     #6 _ _ B _ _ _ _ _#
     #7 _ _ _ x _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(3, 1, origin.TOP)
     self.tboard.place_piece(3, 3, origin.TOP)
     self.tboard.place_piece(4, 2, origin.BOTTOM)
     self.tboard.place_piece(6, 2, origin.BOTTOM)
     
     self.tboard.game.move_piece((3, 3), (5, 1))
     moves = Movement(self.tboard.game.board, 5, 1).get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(5, 1), (6, 0)]), moves[0])
     self.assertEqual(as_move_list([(5, 1), (7, 3)]), moves[1])
     
     self.tboard.game.move_piece((5, 1), (3, 3))
     self.assertIsNone(self.tboard.game.get_piece(5, 1))
     self.assertIsNotNone(self.tboard.game.get_piece(3, 3))
     
     self.tboard.game.move_piece((3, 3), (5, 1))
     self.assertIsNone(self.tboard.game.get_piece(3, 3))
     self.assertIsNotNone(self.tboard.game.get_piece(5, 1))
 def test_get_avail_moves_with_opponent_piece_returns_jumped_position(self):
     self.tboard.place_piece(1, 5, origin.TOP)
     self.tboard.place_piece(2, 4, origin.BOTTOM)
     calc = Movement(self.tboard.game.board, 1, 5)
     moves = calc.get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(1, 5), (3, 3)]), moves[0])
     self.assertEqual(as_move_list([(1, 5), (2, 6)]), moves[1])
예제 #7
0
 def test_king_moves_case_2(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ _ _ _ _ _ _ _#
     #3 _ _ _ _ _ _ _ _#
     #4 _ _ _ _ _ _ _ _#
     #5 _ _ _ _ _ _ _ _#
     #6 _ _ x _ x _ _ _#
     #7 _ _ _ t _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_king(7, 3, origin.TOP)
     calc = Movement(self.tboard.game.board, 7, 3)
     moves = calc.get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(7, 3), (6, 2)]), moves[0])
     self.assertEqual(as_move_list([(7, 3), (6, 4)]), moves[1])
예제 #8
0
 def test_king_can_move_in_either_direction(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ x _ x _ _ _ _#
     #3 _ _ b _ _ _ _ _#
     #4 _ x _ T _ _ _ _#
     #5 _ _ _ _ x _ _ _#
     #6 _ _ _ _ _ _ _ _#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_king(3, 2, origin.BOTTOM)
     self.tboard.place_piece(4, 3, origin.TOP)
     calc = Movement(self.tboard.game.board, 3, 2)
     moves = calc.get_available_moves()
     self.assertEqual(4, len(moves))
     self.assertEqual(as_move_list([(3, 2), (4, 1)]), moves[0])
     self.assertEqual(as_move_list([(3, 2), (5, 4)]), moves[1])
     self.assertEqual(as_move_list([(3, 2), (2, 1)]), moves[2])
     self.assertEqual(as_move_list([(3, 2), (2, 3)]), moves[3])
 def test_moves_case_4(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ T _ _ _ _#
     #1 _ _ B _ x _ _ _#
     #2 _ x _ _ _ _ _ _#
     #3 _ _ B _ _ _ _ _#
     #4 _ _ _ x _ _ _ _#
     #5 _ _ B _ _ _ _ _#
     #6 _ x _ _ _ _ _ T#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(0, 3, origin.TOP)
     self.tboard.place_piece(1, 2, origin.BOTTOM)
     self.tboard.place_piece(3, 2, origin.BOTTOM)
     self.tboard.place_piece(5, 2, origin.BOTTOM)
     calc = Movement(self.tboard.game.board, 0, 3)
     moves = calc.get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(0, 3), (2, 1), (4, 3), (6, 1)]), moves[0])
     self.assertEqual(as_move_list([(0, 3), (1, 4)]), moves[1])
예제 #10
0
 def test_king_moves_doesnt_jump_over_own_dudes(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ x _ _ _#
     #2 _ x _ b _ t _ _#
     #3 _ _ t _ _ _ _ _#
     #4 _ T _ t _ _ _ _#
     #5 _ _ _ _ _ _ _ _#
     #6 _ _ _ _ _ _ _ _#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_king(2, 3, origin.BOTTOM)
     self.tboard.place_king(2, 5, origin.TOP)
     self.tboard.place_king(3, 2, origin.TOP)
     self.tboard.place_piece(4, 1, origin.TOP)
     self.tboard.place_king(4, 3, origin.TOP)
     calc = Movement(self.tboard.game.board, 3, 2)
     moves = calc.get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(3, 2), (2, 1)]), moves[0])
     self.assertEqual(as_move_list([(3, 2), (1, 4)]), moves[1])
예제 #11
0
 def test_origin_moves_list_contains_only_non_empty_move_lists(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ _ _ _ _ _ _ _#
     #3 _ _ _ _ _ _ _ _#
     #4 _ _ _ _ _ _ _ _#
     #5 _ _ x _ x _ x _#
     #6 _ _ _ B _ B _ _#
     #7 _ _ _ _ B _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(6, 3, origin.BOTTOM)
     self.tboard.place_piece(6, 5, origin.BOTTOM)
     self.tboard.place_piece(7, 4, origin.BOTTOM)
     
     allmoves = OriginMoves(self.tboard.game.board,origin.BOTTOM).get_moves()
     self.assertEqual(4, len(allmoves))
     self.assertEqual(as_move_list([(6, 3), (5, 2)]), allmoves[0])
     self.assertEqual(as_move_list([(6, 3), (5, 4)]), allmoves[1])
     self.assertEqual(as_move_list([(6, 5), (5, 4)]), allmoves[2])
     self.assertEqual(as_move_list([(6, 5), (5, 6)]), allmoves[3])
예제 #12
0
 def test_get_all_moves_for_given_origin(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ _ _ _ _ _ _ _#
     #3 _ x x _ x _ _ _#
     #4 B _ _ B _ _ _ _#
     #5 _ _ _ _ x _ x _#
     #6 _ _ _ _ _ B _ _#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(4, 0, origin.BOTTOM)
     self.tboard.place_piece(4, 3, origin.BOTTOM)
     self.tboard.place_piece(6, 5, origin.BOTTOM)
     allmoves = OriginMoves(self.tboard.game.board, origin.BOTTOM).get_moves()
     
     self.assertEqual(5, len(allmoves))
     self.assertEqual(as_move_list([(4, 0), (3, 1)]), allmoves[0])
     self.assertEqual(as_move_list([(4, 3), (3, 2)]), allmoves[1])
     self.assertEqual(as_move_list([(4, 3), (3, 4)]), allmoves[2])
     self.assertEqual(as_move_list([(6, 5), (5, 4)]), allmoves[3])
     self.assertEqual(as_move_list([(6, 5), (5, 6)]), allmoves[4])
예제 #13
0
 def test_move_list_mid_jump_contains_only_further_jumps_or_backwards_movement(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ _ _ _ _ _ _ _#
     #3 _ T _ T _ _ _ _#
     #4 _ _ B _ _ _ _ _#
     #5 _ x _ _ _ _ _ _#
     #6 _ _ B _ _ _ _ _#
     #7 _ _ _ x _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(3, 1, origin.TOP)
     self.tboard.place_piece(3, 3, origin.TOP)
     self.tboard.place_piece(4, 2, origin.BOTTOM)
     self.tboard.place_piece(6, 2, origin.BOTTOM)
     
     
     #Problem : since refactoring, Backwards movement isn't in Available moves anymore.
     #Also, Moving only ONE SPOT when previously you did a jump is VALID when you just
     #Check Get Available Moves -> the Further Filtering happens within the TURN.
     #This should really be checking that you CAN'T MOVE to 6,0, not that it's not in
     #The list of moves.
     
     #Similarly with backward movement. It won't show up, but you CAN do it because
     #The filtering will occur IN THE TURN.
     
     self.tboard.game.move_piece((3, 3), (5, 1))
     moves = Movement(self.tboard.game.board, 5, 1).get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(5, 1), (6, 0)]), moves[0])
     self.assertEqual(as_move_list([(5, 1), (7, 3)]), moves[1])
     
     #Now try moving to 6, 0 - it won't work.
     self.tboard.game.move_piece((5, 1), (6, 0))
     self.assertIsNone(self.tboard.game.get_piece(6, 0))
     self.assertIsNotNone(self.tboard.game.get_piece(5, 1))
예제 #14
0
 def test_king_moves_case_1(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ x _ _ _#
     #2 _ x _ t _ t _ _#
     #3 _ _ b _ _ _ x _#
     #4 _ x _ x _ T _ _#
     #5 _ _ _ _ x _ _ _#
     #6 _ _ _ _ _ t _ _#
     #7 _ _ _ _ _ _ x _#
     # # # # # # # # # #
     self.tboard.place_king(2, 3, origin.TOP)
     self.tboard.place_king(2, 5, origin.TOP)
     self.tboard.place_king(3, 2, origin.BOTTOM)
     self.tboard.place_piece(4, 5, origin.TOP)
     self.tboard.place_king(6, 5, origin.TOP)
     calc = Movement(self.tboard.game.board, 3, 2)
     moves = calc.get_available_moves()
     self.assertEqual(4, len(moves))
     self.assertEqual(as_move_list([(3, 2), (4, 1)]), moves[0])
     self.assertEqual(as_move_list([(3, 2), (4, 3)]), moves[1])
     self.assertEqual(as_move_list([(3, 2), (2, 1)]), moves[2])
     self.assertEqual(as_move_list([(3, 2), (1, 4), (3, 6), (5, 4), (7, 6)]), moves[3])
예제 #15
0
 def test_moves_case_3(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ _ _ T _ _ _ _#
     #3 _ _ B _ B _ _ _#
     #4 _ x _ _ _ _ _ _#
     #5 _ _ B _ _ _ B _#
     #6 _ _ _ B _ _ _ T#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(2, 3, origin.TOP)
     self.tboard.place_piece(3, 2, origin.BOTTOM)
     self.tboard.place_piece(3, 4, origin.BOTTOM)
     self.tboard.place_piece(5, 2, origin.BOTTOM)
     self.tboard.place_piece(5, 6, origin.BOTTOM)
     self.tboard.place_piece(6, 3, origin.BOTTOM)
     self.tboard.place_piece(6, 7, origin.TOP)
     calc = Movement(self.tboard.game.board, 2, 3)
     moves = calc.get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(2, 3), (4, 1)]), moves[0])
     self.assertEqual(as_move_list([(2, 3), (4, 5)]), moves[1])
예제 #16
0
 def test_cannot_move_a_new_piece_while_move_in_progress_even_if_on_same_side(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ x _#
     #1 _ _ _ _ _ T _ _#
     #2 _ _ _ _ x _ _ _#
     #3 _ x _ T _ _ _ _#
     #4 _ _ B _ _ _ _ _#
     #5 _ _ _ _ _ _ _ _#
     #6 _ _ _ _ B _ _ _#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(1, 5, origin.TOP)
     self.tboard.place_piece(3, 3, origin.TOP)
     self.tboard.place_piece(4, 2, origin.BOTTOM)
     self.tboard.place_piece(6, 4, origin.BOTTOM)
     calc = Movement(self.tboard.game.board, 4, 2)
     moves = calc.get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(4, 2), (3, 1)]), moves[0])
     self.assertEqual(as_move_list([(4, 2), (2, 4), (0, 6)]), moves[1])
     self.tboard.game.current_turn = Turn(self.tboard.game, origin.TOP)
     # start move
     self.tboard.game.move_piece((4, 2), (2, 4))
     self.assertIsNone(self.tboard.game.get_piece(4, 2))
     self.assertIsNotNone(self.tboard.game.get_piece(2, 4))
     
     # make sure can't move another piece of same type
     calc = Movement(self.tboard.game.board, 6, 4)
     moves = calc.get_available_moves()
     self.assertEqual(2, len(moves)) 
     self.assertEqual(as_move_list([(6, 4), (5, 3)]), moves[0])
     self.assertEqual(as_move_list([(6, 4), (5, 5)]), moves[1])
     self.tboard.game.move_piece((6, 4), (5, 5))
     self.assertIsNone(self.tboard.game.get_piece(5, 5))
     self.assertIsNotNone(self.tboard.game.get_piece(6, 4))
예제 #17
0
 def test_move_top_piece_along_and_do_some_backward_movement_to_trip_stuff_up(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ T _ _ _ _#
     #2 _ _ B _ x _ _ _#
     #3 _ x _ _ _ _ _ _#
     #4 _ _ B _ _ _ _ _#
     #5 _ _ _ x _ _ _ _#
     #6 _ _ _ _ B _ _ _#
     #7 _ _ _ _ _ x _ _#
     # # # # # # # # # #
     self.tboard.place_piece(1, 3, origin.TOP)
     self.tboard.place_piece(2, 2, origin.BOTTOM)
     self.tboard.place_piece(4, 2, origin.BOTTOM)
     self.tboard.place_piece(6, 4, origin.BOTTOM)
     moves = Movement(self.tboard.game.board, 1, 3).get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(1, 3), (3, 1), (5, 3), (7, 5)]), moves[0])
     self.assertEqual(as_move_list([(1, 3), (2, 4)]), moves[1])
     
     self.tboard.game.move_piece((1, 3), (3, 1))
     self.assertIsNone(self.tboard.game.get_piece(1, 3))
     self.assertIsNotNone(self.tboard.game.get_piece(2, 2))
     self.assertIsNotNone(self.tboard.game.get_piece(3, 1))
     
     moves = Movement(self.tboard.game.board, 3, 1).get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(3, 1), (4, 0)]), moves[0])
     self.assertEqual(as_move_list([(3, 1), (5, 3), (7, 5)]), moves[1])
     
     # move backward just to trip things up
     self.tboard.game.move_piece((3, 1), (1, 3))
     self.assertIsNone(self.tboard.game.get_piece(3, 1))
     self.assertIsNotNone(self.tboard.game.get_piece(2, 2))
     self.assertIsNotNone(self.tboard.game.get_piece(1, 3))
     
     moves = Movement(self.tboard.game.board, 1, 3).get_available_moves()
     self.assertEqual(2, len(moves))
     self.assertEqual(as_move_list([(1, 3), (3, 1), (5, 3), (7, 5)]), moves[0])
     ### bug-- it's 1,3 instead of 2,4 because 2,4 is gone- it's gone because
     ### you've jumped a piece so valid jumps are no longer there. 1,3 shouldn't be there either
     ### the problem is : if you're going backwards, pieces shouldn't be jumped over. Moves are different
     ### they're not just locations. there has to be a Move Object -> and this object will say whether
     ### it's a backwards movement, or a jumped movement, or just a regular movement
     ### time for some massive refactoring because we've been using tuples as moves...
     
     ### well, we don't want to take out all instances of tuples. maybe the inner functioning will change.
     ### ie the implementation details. 
     ### each time you make a move, the list of moves will have a new MOVE object.
     
     ### post-refactoring: The move is now off the list because there are moves in the moves object for the turn.
     ### this a bug that has been fixed using this test.-->actually, was the bug even there?
     self.assertEqual(as_move_list([(1, 3), (2, 4)]), moves[1])
 def test_calculate_moves_up_to_depth_one_does_not_touch_original_board_and_selects_best_move_considering_others_result_in_more_lost_pieces(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ _ T _ _ _ _ _#
     #3 _ x _ x _ _ _ _#
     #4 B _ _ _ _ _ _ _#
     #5 _ _ _ _ _ _ _ _#
     #6 _ _ _ _ _ _ _ _#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(2, 2, origin.TOP)
     self.tboard.place_piece(4, 0, origin.BOTTOM)
     best_move = BestMoveWithDepth(1, origin.TOP).calculate_for(self.tboard.game)
     self.assertEquals(as_move_list([(2, 2), (3, 3)]), best_move)
     self.assertIsNone(self.tboard.game.get_piece(3, 3))
     self.assertIsNotNone(self.tboard.game.get_piece(2, 2))
예제 #19
0
 def test_cannot_jump_over_own_kind_case_2(self):
     # # # # # # # # # #
     #  0 1 2 3 4 5 6 7#
     #0 _ _ _ _ _ _ _ _#
     #1 _ _ _ _ _ _ _ _#
     #2 _ _ _ _ _ _ _ _#
     #3 _ _ T _ _ _ _ _#
     #4 _ T _ B _ _ _ _#
     #5 _ _ _ _ x _ _ _#
     #6 _ _ _ _ _ T _ _#
     #7 _ _ _ _ _ _ _ _#
     # # # # # # # # # #
     self.tboard.place_piece(3, 2, origin.TOP)
     self.tboard.place_piece(4, 1, origin.TOP)
     self.tboard.place_piece(4, 3, origin.BOTTOM)
     self.tboard.place_piece(6, 5, origin.TOP)
     calc = Movement(self.tboard.game.board, 3, 2)
     moves = calc.get_available_moves()
     self.assertEqual(1, len(moves))
     self.assertEqual(as_move_list([(3, 2), (5, 4)]), moves[0])