def start(): g = Game() try: choice2 = (int(input("Write 1 to reload or 0 to have a new game:"))) if choice2 == 1: g.service.read_file() elif choice2 != 0: print("Wrong number!") except Exception as e: print(e) print(g) ai = Ai(g.board, g.service) while True: try: g.input() if g.service.Order_won() == True: raise ex.HumanWon("Order has Won!!!") ai.random_move() if g.service.Order_won() == True: raise ex.HumanWon("Order has Won!!!") print(g) ai.free_moves() except ex.HumanWon as e: print(e) break except Exception as e: print(e)
def test(): newB = B() newS = s(newB) newAi = AI(newB, newS) newS.move(0, 0, 1) assert newB.get_b(0, 0) == 1 count = 0 for i in range(6): for j in range(6): if newB.get_b(i, j) == 1: count += 1 assert count == 1 newS.move(0, 1, 1) newS.move(0, 2, 1) newS.move(0, 3, 1) assert newS.Order_won() == False newS.move(0, 4, 1) assert newS.Order_won() == True assert newAi.free_moves() == 6 * 6 - 5