Example #1
0
def click_play(x, y, b, m):
    if othello.end(disks, size) or othello.check_all_moves(disks, size):
        othello.write_score(disks)
        os.remove("othello_disks.json")
        raise SystemExit("End")

    symbol = get_symbol()

    if othello.check_possible_move(disks, symbol, size):
        try:
            new_coordinate = get_coordinates(x, y)
            new_coordinate = othello.check_coordinates(disks, new_coordinate,
                                                       size)
            changes = util.move(disks, new_coordinate, symbol)
            util.reversal(disks, new_coordinate, symbol, changes)
            change_player()
        except ValueError as e:
            print(e)
    else:
        print("You cannot play.")
        change_player()
Example #2
0
def test_check_move3():
    disks = {(1,1): "x", (2,1): "x", (3,1): "x", (1,2): "x", (1,3): "x", (2,3): "x", (3,3): "x", (3,2): "x", (2,2): "o"}
    assert othello.check_possible_move(disks, "o", 8) == True
Example #3
0
def test_check_move5():
    disks ={(0,0): "o", (0,1): "x", (0,2): "x", (0,3): "x", (1,0): "x", (2,0): "x", (3,0): "x"}
    assert othello.check_possible_move(disks, "x", 4) == False
Example #4
0
def test_check_move1():
    size = 8
    disks = {(3,3): "x", (4,4): "x", (3,4): "o", (4,3): "o"}
    assert othello.check_possible_move(disks, "x", 8)