def test_tag(): t = Tracker(Board(5, 500, 500, 500, othelloAI())) t.bd.generate_board() t.bd.disks[1][1].halo_tag = True t.tag() assert t.tag_count == 1 assert t.computer_moves == [t.bd.disks[1][1]]
def test_generate_board(): bd = Board(10, 100, 1009, 1, othelloAI()) bd.generate_board() assert bd.disks[4][3].node_dict[1] is bd.disks[4][2] assert bd.disks[9][9].node_dict[7] is None assert bd.disks[6][0].node_dict[0] is None assert bd.disks[1][0].node_dict[4] is bd.disks[0][0] assert bd.disks[0][0].node_dict == {0: None, 1: None, 2: None, 3: bd.disks[1][0], 4: None, 5: None, 6: bd.disks[0][1], 7: bd.disks[1][1]} assert bd.disks[9][9].node_dict == {0: bd.disks[8][8], 1: bd.disks[9][8], 2: None, 3: None, 4: bd.disks[8][9], 5: None, 6: None, 7: None} assert bd.disks[0][4].node_dict == {0: None, 1: bd.disks[0][3], 2: bd.disks[1][3], 3: bd.disks[1][4], 4: None, 5: None, 6: bd.disks[0][5], 7: bd.disks[1][5]}
def test_scanner(): t = Tracker(Board(5, 500, 500, 500, othelloAI())) t.bd.generate_board() t.scanner() assert t.white_disks == 2 assert t.black_disks == 2 assert t.disks_on_board == 4
def test_clear_bad_moves(): ai = othelloAI() d = Disk(-1000, '345') d2 = Disk(1, 1) ai.coordinate_extractor(d) ai.coordinate_extractor(d2) ai.fill_fin_avoid() assert ai.clear_bad_moves() == [(-1000, '345')]
def test_choose_move(): ai = othelloAI() d = Disk(-1000, '345') ai.coordinate_extractor(d) ai.fill_fin_avoid() assert ai.choose_move() == (-1000, '345') ai.moves_reset() assert ai.choose_move() is None
def test_last_resort(): ai = othelloAI() d = Disk(-1000, '345') d2 = Disk(1, 1) ai.coordinate_extractor(d) ai.coordinate_extractor(d2) ai.fill_fin_avoid() assert ai.last_resort() == [(-1000, '345')]
def test_board_scan_reset(): t = Tracker(Board(5, 500, 500, 500, othelloAI())) t.bd.generate_board() t.bd.disks[1][1].halo_tag = True t.board_scan_reset() assert t.white_disks == 0 assert t.black_disks == 0 assert t.disks_on_board == 0 assert t.computer_moves == [] assert t.tag_count == 0
def test_moves_reset(): ai = othelloAI() d = Disk(-1000, '345') ai.coordinate_extractor(d) ai.moves_reset() assert ai.possible_moves == []
def test_standard_tile(): bd = Board(5, 12, 58, 2, othelloAI()) bd.generate_board() assert bd.disks[2][3].node_dict[1] is not None assert bd.disks[3][3].node_dict[2] == bd.disks[4][2]
def test_adjacent_edges(): bd = Board(5, 12, 58, 2, othelloAI()) bd.generate_board() assert bd.disks[0][3].node_dict[1] == bd.disks[0][2] assert bd.disks[4][3].node_dict[6] == bd.disks[4][4]
def test_adjacent_corners(): bd = Board(5, 12, 58, 2, othelloAI()) bd.generate_board() assert bd.disks[0][0].node_dict[0] is None assert bd.disks[0][4].node_dict[1] == bd.disks[0][3]
def test_node_connect(): bd = Board(5, 100, 508, 2, othelloAI()) bd.generate_board() bd.node_connect(4, 2, bd.disks[4][1], 5) assert bd.disks[4][1].node_dict[5] is bd.disks[4][2] assert bd.disks[4][2].node_dict[1] is bd.disks[4][1]
def test_moves_avail(): t = Tracker(Board(5, 500, 500, 500, othelloAI())) out = t.moves_avail() assert out is False
def test_board_scan(): t = Tracker(Board(5, 500, 500, 500, othelloAI())) t.bd.generate_board() out = t.board_scan() assert out is False
def test_tag_reset(): t = Tracker(Board(5, 500, 500, 500, othelloAI())) t.bd.generate_board() t.bd.disks[1][1].halo_tag = True t.tag_reset() assert t.bd.disks[1][1].halo_tag is False
def test_constructor(): ai = othelloAI() assert ai.fin_priorities0 == {(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0)} assert ai.avoid3 == {(6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)} assert ai.possible_moves == []
def test_constructor(): bd = Board(10, 100, 1009, 1, othelloAI()) assert bd.disks == {} assert bd.setup == (4.0, 6.0) assert bd.HEIGHT == 1009.0
def test_validate_in(): gc = GameController(Tracker(Board(5, 1, 1, 1, othelloAI())), 1) out = gc.validate_in(2, 2) assert out == (False, 1, 1)