Commit 9a15cc55 authored by Brahim Ghaouthi's avatar Brahim Ghaouthi
Browse files

Upload New File

parent 666f4194
import unittest
import gameAi
import random
from datetime import datetime
class test(unittest):
def test_mode(self):
if gameAi.View.return_gamemode() == 'ai':
changed_mode = 'pvp'
changed_mode = 'ai'
expected_mode = gameAi.View.change_gamemode()
self.assertEqual(expected_mode, changed_mode)
def random_bords(n):
empty_sqrs = gameAi.AI.board.get_empty_sqrs()
for i in range(n):
idx = random.randrange(0, len(empty_sqrs))
gameAi.Model.mark_square(empty_sqrs[idx][0], empty_sqrs[idx][1], gameAi.AI.player)
return empty_sqrs[idx] # (row, col)
for i in range(100):
n = 9
for j in range(9):
(row, col) = random_bords(n)
n -= 1
start =
gameAi.Controller.main().game.make_move(row, col)
end = - start
start1 =
board = gameAi.Controller.main().board
row, col = gameAi.Controller.main().ai.eval(board)
gameAi.Controller.main().game.make_move(row, col)
end1 = - start1
with open('', 'a') as f:
f.write('Random AI took: ' + end)
f.write('Unbeatabale AI took: ' + end1)
if __name__ == '__main__':
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment