2018-07-31
It's uninteresting, really: leo-xo.html = leo.c x minimaXO.c
In this shitty** thingy, Leo knows the rules of XO (like minimaXO);
however, he doesn't know how to play:
* In the beginning, having an empty decision tree (DT), Leo takes (valid) random moves.
* Leo records the game at each step ("state"):
record = { states, winner }
winner = 'X' or 'O' or '-' (draw)
state = {board, turn, m}
Example: { board: ["-", "-", "-", "-", "X", "X", "O", "-", "O"], turn: 'X', m: 3 }
Meaning: The board was like this; player 'X' chose the move/cell/case index 3.
* After each match, he rebuilds his DT based on:
- his moves if he wins.
- the opponent's moves if he loses.
- both his moves and the opponent's if it's a draw.
(And, of course, using previous matches' records)
* Leo then starts using the DT to choose his moves.
In case he choses an invalid move, he randomly takes a valid one instead.
(** I tried it manually: it doesn't seem like it's doing [well at] what it's supposed to do.
I've attempted to organize the code in a way that allows Leo (with a few modifications) to play against himself to learn quickly...
Gotta edit it someday...)