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"
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"
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"
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"
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"
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"
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"
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"
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 == []
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"
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"
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"