コード例 #1
0
ファイル: gologictest.py プロジェクト: jimbobsweeney/Go
 def test_check_for_group(self):
     self.testgame = gologic.game(19)
     self.testgame.groups.append(gologic.group((5,5),0)) 
     self.testmove = gologic.move((4,5),0)
     self.testgame.check_for_group(self.testmove)
     assert len(self.testmove.adjacent_groups) == 1,"There should be one adjacent group to this move"
     self.testgame.groups.append(gologic.group((3,5),1))
     self.testgame.check_for_group(self.testmove)
     assert len(self.testmove.adjacent_op_groups) == 1,"There should be one adjacent opponent group to this move" 
コード例 #2
0
ファイル: gologictest.py プロジェクト: jimbobsweeney/Go
 def test_check_for_group_2(self):
     self.testgame = gologic.game(19)
     self.testgame.groups.append(gologic.group((5,5),0)) 
     self.testgame.groups.append(gologic.group((3,5),0)) 
     self.testgame.groups.append(gologic.group((4,6),0)) 
     self.testgame.groups.append(gologic.group((4,4),0))
     self.testmove = gologic.move((4,5),0) 
     self.testgame.check_for_group(self.testmove)
     assert len(self.testmove.adjacent_groups) == 4,"There should be 4 adjacent groups to this move"
コード例 #3
0
ファイル: gologictest.py プロジェクト: jimbobsweeney/Go
 def test_check_for_group_3(self):
     self.testgame = gologic.game(19)
     self.testgame.groups.append(gologic.group((5,5),0))
     self.testgame.groups[0].add_position((4,4))
     self.testgame.groups[0].add_position((5,4))
     self.testgame.groups[0].add_position((3,4))
     self.testgame.groups[0].add_position((3,5))      
     self.testmove = gologic.move((4,5),0)
     self.testgame.check_for_group(self.testmove)
     assert len(self.testmove.adjacent_groups) == 1,"There should be one adjacent group to this move"  
コード例 #4
0
ファイル: gologictest.py プロジェクト: Wonko-the-sane/GOLOGIC
 def test_make_a_move2(self):
     self.testgame = gologic.game(19)
     self.testgame.gameboard.add_stone((4,5),1,15)
     self.testgame.groups.append(gologic.group((4,5),1,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((6,5),1,15)
     self.testgame.groups.append(gologic.group((6,5),1,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((5,6),1,15)
     self.testgame.groups.append(gologic.group((5,6),1,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((5,4),1,15)
     self.testgame.groups.append(gologic.group((5,4),1,self.testgame.gameboard.grid))
     self.testmove = gologic.move((5,5),0)
     legality = self.testgame.make_a_move(self.testmove)
     assert legality == False,"this move should be illegal"
コード例 #5
0
ファイル: gologictest.py プロジェクト: Wonko-the-sane/GOLOGIC
 def test_sim_move2(self):
     self.testgame = gologic.game(19)
     self.testgame.gameboard.add_stone((4,5),0,15)
     self.testgame.groups.append(gologic.group((4,5),0,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((6,5),0,15)
     self.testgame.groups.append(gologic.group((6,5),0,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((5,6),0,15)
     self.testgame.groups.append(gologic.group((5,6),0,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((5,4),0,15)
     self.testgame.groups.append(gologic.group((5,4),0,self.testgame.gameboard.grid))
     self.testmove = gologic.move((5,5),0)
     sim_game = self.testgame.sim_move(self.testmove)
     assert len(sim_game.groups) == 1,"There should be 1 group"
     assert len(sim_game.groups[0].positions) == 5,"There should be 5 positions in the group"
コード例 #6
0
ファイル: gologictest.py プロジェクト: Wonko-the-sane/GOLOGIC
 def test_check_for_group_4(self):
     self.testgame = gologic.game(19)
     self.testgame.gameboard.add_stone((5,5),0,1)
     self.testgame.groups.append(gologic.group((5,5),0,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((4,4),0,1)
     self.testgame.groups[0].add_position((4,4),self.testgame.gameboard.grid)
     self.testgame.gameboard.add_stone((5,4),0,1)
     self.testgame.groups[0].add_position((5,4),self.testgame.gameboard.grid)
     self.testgame.gameboard.add_stone((3,4),0,1)
     self.testgame.groups.append(gologic.group((3,4),0,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((3,5),0,1)
     self.testgame.groups[1].add_position((3,5),self.testgame.gameboard.grid) 
     self.testgame.gameboard.add_stone((4,6),0,1)
     self.testgame.groups.append(gologic.group((4,6),0,self.testgame.gameboard.grid))     
     self.testmove = gologic.move((4,5),0)
     self.testgame.check_for_group(self.testmove)
     assert len(self.testmove.adjacent_groups) == 3,"There should be 3 adjacent groups to this move" 
コード例 #7
0
ファイル: gologictest.py プロジェクト: Wonko-the-sane/GOLOGIC
 def test_make_a_move3(self):
     self.testgame = gologic.game(19)
     self.testgame.gameboard.add_stone((4,5),1,15)
     self.testgame.groups.append(gologic.group((4,5),1,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((6,5),1,15)
     self.testgame.groups.append(gologic.group((6,5),1,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((5,6),1,15)
     self.testgame.groups.append(gologic.group((5,6),1,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((5,4),1,15)
     self.testgame.groups.append(gologic.group((5,4),1,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((4,4),0,15)
     self.testgame.groups.append(gologic.group((4,4),0,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((5,3),0,15)
     self.testgame.groups.append(gologic.group((5,3),0,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((6,4),0,15)
     self.testgame.groups.append(gologic.group((6,4),0,self.testgame.gameboard.grid))
     self.testmove = gologic.move((5,5),0)
     legality = self.testgame.make_a_move(self.testmove)
     assert legality != False,"this move should be legal" 
     assert len(self.testgame.groups) == 7,"should be 7 groups after this move has been made"  
     assert legality.dead_stones[1] == 1,"One white stone should have died"
コード例 #8
0
ファイル: gologictest.py プロジェクト: Wonko-the-sane/GOLOGIC
 def test_make_a_move4(self):
     self.testgame = gologic.game(19)
     self.testgame.gameboard.add_stone((3,4),0,10)
     self.testgame.groups.append(gologic.group((3,4),0,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((3,5),0,10)
     self.testgame.groups[0].add_position((3,5),self.testgame.gameboard.grid)
     self.testgame.gameboard.add_stone((2,3),1,10)
     self.testgame.groups.append(gologic.group((2,3),1,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((2,4),1,10)
     self.testgame.groups[1].add_position((2,4),self.testgame.gameboard.grid)
     self.testgame.gameboard.add_stone((2,5),1,10)
     self.testgame.groups[1].add_position((2,5),self.testgame.gameboard.grid)
     self.testgame.gameboard.add_stone((4,4),1,10)
     self.testgame.groups.append(gologic.group((4,4),1,self.testgame.gameboard.grid))
     self.testgame.gameboard.add_stone((4,5),1,10)
     self.testgame.groups[1].add_position((4,5),self.testgame.gameboard.grid)
     self.testgame.gameboard.add_stone((3,6),1,10)
     self.testgame.groups.append(gologic.group((3,6),1,self.testgame.gameboard.grid))
     self.testmove = gologic.move((3,3),1)
     legality = self.testgame.make_a_move(self.testmove)
     assert legality != False,"this move should be legal"
     assert len(legality.groups) == 3,"should be 3 groups after this move has been made"  
     assert legality.dead_stones[0] == 2,"2 black stones should have died"
コード例 #9
0
ファイル: gologictest.py プロジェクト: jimbobsweeney/Go
 def test_new_move(self):
     self.testmove = gologic.move((5,5),0)
     assert self.testmove.position == (5,5)
     assert self.testmove.colour == 0
     assert self.testmove.adjacent_groups == []
コード例 #10
0
ファイル: gologictest.py プロジェクト: jimbobsweeney/Go
 def test_make_a_move(self):
     self.testgame = gologic.game(19)
     self.testmove = gologic.move((5,5),0)
     self.testgame.make_a_move(self.testmove)
     assert len(self.testgame.groups) == 1,"There should be 1 group"
コード例 #11
0
ファイル: gologictest.py プロジェクト: Wonko-the-sane/GOLOGIC
 def test_make_a_move(self):
     self.testgame = gologic.game(19)
     self.testmove = gologic.move((5,5),0)
     legality = self.testgame.make_a_move(self.testmove)
     assert legality != False,"this move should be legal"
コード例 #12
0
ファイル: gologictest.py プロジェクト: Wonko-the-sane/GOLOGIC
 def test_sim_move(self):
     self.testgame = gologic.game(19)
     self.testmove = gologic.move((5,5),0)
     sim_game = self.testgame.sim_move(self.testmove)
     assert len(sim_game.groups) == 1,"There should be 1 group"
     assert len(sim_game.groups[0].positions) == 1,"There should be 1 position in the group"