Beispiel #1
0
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()
Beispiel #2
0
		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:
			print "Invalid player configuration! Restarting configuration process."
			continue
		line = raw_input("Black Player:")
		if line == "h":
			G.init_black(PlayerType.Human)
		elif line == "ai":
			G.init_black(PlayerType.AI)
		elif line == "ard":
			G.init_black(PlayerType.Arduino)
		elif line == "v":
			G.init_black(PlayerType.Voice)
		else:
			print "Invalid player configuration! Restarting configuration process."
			continue

		print("Please specify whether you want to play on the console or GUI.")
		line = raw_input("<c for console, g for gui>:")
		if line == "c" or line == "g":
			the_board = line
			configuration = False