python - Solving tic-tac-toe through brute force -


i have been struggling problem while. need solve tic tac toe through brute force - is, having computer "learn" playing few million times.

right now, "setup" works - i'll briefly describe it. computer plays generating random moves, until 1 side or other has won. stores list represents game, , associates list 1, 0, or -1 win, draw, or loss.

the algorithm i'm using simple one; find move on board associated wins , least losses, out of games can result current board, , move there.

this works ever case; except important ones: forks.

in situation this:

o - -       o - x     o - x  - x -   >   - x -  >  - x -  - - o       - - o     o - o 

where computer has next move, computer invariably goes in corner, , later gets forked.

is there way solve tic tac toe through "brute force" (without using min/max, heuristics, hard coding forks, etc.)?

a few million times may excessive. think there 362,880 possible "games" (statistics: first player has 9 options, next player has 8 remaining, 7, etc.. 9! = 362,880).

i recommend weighing move selection based not on eventual win/loss, on number of moves required win. fewer moves = better decision.

also, once build "complete" map, can map moves in situations "death" moves, leading inevitably loss. designed weighing metric see there no route win, , never select move (which include forks).


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -