Exemple #1
0
	def test_ai_choice_6(self):  #This tests the AI's ability to not move somewhere that gives the opponent the win
		game = c4main.Game(c4main.Player("AI"), c4main.Player("AI"))
		board = game.board
		board.place(1,2).place(2,1).place(3,1).place(1,1).place(2,1).place(3,2).place(3,2).place(2,2).place(1,1).place(1,1).place(1,2).place(2,2).place(6,2).place(6,2).place(7,1)

		move = game.players[0].decide(board, 1)
		self.assertEqual(move, 7)
Exemple #2
0
	def test_ai_choise_8(self):  #Tests whether a move will be made when there atleast two moves that all lose the game.
		game = c4main.Game(c4main.Player("AI"), c4main.Player("AI"))
		board = game.board
		board.place(1,2).place(1,2).place(1,1).place(1,1).place(1,2).place(1,2)
		board.place(3,1).place(3,2).place(3,1).place(3,2).place(3,2).place(3,1)
		board.place(4,2).place(4,2).place(4,1).place(4,2).place(4,2).place(4,1)
		board.place(5,1).place(5,2).place(5,1).place(5,2).place(5,2).place(5,1)
		board.place(7,2).place(7,2).place(7,1).place(7,1).place(7,2).place(7,2)
		move = game.players[0].decide(board, 1)
		self.assertTrue(move in [2, 6])
Exemple #3
0
	def test_ai_choice_4(self):
		player = c4main.Player("AI")
		game = c4main.Game(player, None)
		board = game.board
		board.place(2,1).place(3,1).place(5,2).place(4,2).place(2,2).place(3,2)
		move = game.players[0].decide(board, 1)
		self.assertEqual(move, 4) #player.decide(board, 1) == 1)
Exemple #4
0
	def create_test_game_2(self):
		player = c4main.Player("AI")
		game = c4main.Game(player, None)
		board = game.board
		board.place(2,1).place(2,2).place(3,1).place(3,2).place(4,1).place(4,2).place(5,2).place(5,1).place(6,2).place(6,2).place(6,1).place(7,2).place(7,2)
		return game
Exemple #5
0
	def test_ai_play_game_0(self):
		game = c4main.Game(c4main.Player("AI"), c4main.Player("AI"))
		#game.start()

		self.assertTrue(True)	
Exemple #6
0
	def test_ai_choice_7(self):  #This tests that the AI will give their opponent the win only if they have no other moves
		game = c4main.Game(c4main.Player("AI"), c4main.Player("AI"))
		board = game.board
		board.place(1,2).place(2,1).place(3,1).place(1,1).place(2,1).place(3,2).place(3,2).place(2,2).place(1,1).place(1,1).place(1,2).place(2,2).place(6,2).place(6,2).place(7,1).place(1,2).place(2,1).place(2,2).place(3,1).place(3,1).place(3,1).place(5,2).place(5,1).place(5,1).place(5,2).place(5,2).place(5,1).place(6,1).place(6,1).place(6,2).place(6,2).place(7,1).place(7,2).place(7,2).place(7,2).place(7,1)
		move = game.players[0].decide(board, 1)
		self.assertEqual(move, 4)
Exemple #7
0
	def test_ai_choice_5(self):
		game = c4main.Game(c4main.Player("AI"), None)
		board = game.board
		move = game.players[0].decide(board,1)
		self.assertTrue(move > 0 and move < 8)