def testDraw(): B = Board() G = Game(B) #Initialize Players White_Player = Human(Color.White) Black_Player = Human(Color.Black) G.White_Player = White_Player G.Black_Player = Black_Player #Black Rooks placed r1 = Rook("r1", Color.Black) r2 = Rook("r2", Color.Black) n1 = Knight("n1", Color.Black) b1 = Bishop("b1", Color.Black) place_piece(B, "a8", r1) place_piece(B, "h8", r2) place_piece(B, "b8", n1) place_piece(B, "c8", b1) #Black King k = King("k", Color.Black) place_piece(B, "e8", k) G.black_king = k Black_Player.add_piece(r1) Black_Player.add_piece(r2) Black_Player.add_piece(n1) Black_Player.add_piece(b1) Black_Player.add_piece(k) #White Rooks placed R1 = Rook("R1", Color.White) R2 = Rook("R2", Color.White) N1 = Knight("N1", Color.White) B1 = Bishop("B1", Color.White) place_piece(B, "a1", R1) place_piece(B, "h1", R2) place_piece(B, "b1", N1) place_piece(B, "c1", B1) #White King K = King("K", Color.White) place_piece(B, "e1", K) G.white_king = K White_Player.add_piece(R1) White_Player.add_piece(R2) White_Player.add_piece(N1) White_Player.add_piece(B1) White_Player.add_piece(K) G.pieces_in_game.extend(White_Player.pieces) G.pieces_in_game.extend(Black_Player.pieces) G.current_player = White_Player G.game_state = State.Running
def testHumanVsHuman(): B = Board() G = Game(B) G.run()
# A sample text-based chess game created by William Larson from defaultBoardPositions import * from ChessGame import Game game = Game() game.play()
def testWin(): B = Board() G = Game(B) G.init_white(PlayerType.Human) G.init_black(PlayerType.Human) #Initialize Players White_Player = G.White_Player Black_Player = G.Black_Player #Black Rooks placed r1 = Rook("r1", Color.Black) r2 = Rook("r2", Color.Black) place_piece(B, "a8", r1) place_piece(B, "h8", r2) #Black King k = King("k", Color.Black) place_piece(B, "e8", k) G.black_king = k Black_Player.add_piece(r1) Black_Player.add_piece(r2) Black_Player.add_piece(k) #White Rooks placed R1 = Rook("R1", Color.White) R2 = Rook("R2", Color.White) place_piece(B, "a1", R1) place_piece(B, "h1", R2) #White King K = King("K", Color.White) place_piece(B, "e1", K) G.white_king = K White_Player.add_piece(R1) White_Player.add_piece(R2) White_Player.add_piece(K) G.pieces_in_game.extend(White_Player.pieces) G.pieces_in_game.extend(Black_Player.pieces) G.current_player = Black_Player G.game_state = State.Running p, old_loc, p_removed, new_loc, c, castle = G.update_board(Black_Player.pieces[2], "A8") G.display_board() print p.name, old_loc, p_removed, new_loc, c, castle G.reverse_step(p, old_loc, p_removed, new_loc, c, castle) G.display_board()
#White_Player.add_piece(B1) White_Player.add_piece(K) G.pieces_in_game.extend(White_Player.pieces) G.pieces_in_game.extend(Black_Player.pieces) G.current_player = White_Player G.opponent = Black_Player G.next_legal_moves() G.game_state = State.Running if __name__ == "__main__": print("Welcome! Enjoy this riveting game of Wizard's Chess.") configuration = True B = Board() G = Game(B) the_board = "c" while (configuration): print("Please specify players.") print(" <h for human, ai for ai, ard for arduino serial, v for voice>") line = raw_input("White Player:") if line == "h": G.init_white(PlayerType.Human) elif line == "ai": G.init_white(PlayerType.AI) elif line == "ard": G.init_white(PlayerType.Arduino) elif line == "v": G.init_white(PlayerType.Voice) else: