move v2.0.0 changes to v2 folder
all changes post-v1.2.1 were reverted in the main directory
separate math.Log and math.Sqrt calls
update README to reflect v2.0 changes
add error return values for (*MCTS).BestAction
rework action selection system
We offload the action selection to the user of this package.
Theoritically, gmcts only needs to know how many actions there are,
and pick random actions from there.
This change is a rather massive change for current implementations,
but significant speed gains are available due to not having to convert
actions from values to interfaces back to values.
This change also removes the need for an Action interface, as the package
no longer needs to hold a list of random actions.
add Hash() as a required method on Game
The game state is now allowed to be uncomparable, as we use the hash,
assumed to be comparable, to map game states to nodes. This might seem,
like kicking the rock down the road, and it is to an extent, but this
allows the underlying game state to hold slices and maps.
This commit is harmless to current implemenations as the Hash function
can return the game state itself.
reduce amount of IsTerminal calls
we only need to check it if a node hasn't been expanded yet
remove isParentOf func
The reason this function existed was to filter duplicate moves from
the same game state. The reason for its removal is that the filtering
of moves should be moved onto the user of this package. 9 times out of
10, there would be no moves to filter, so it just wastes cpu cycles on
searching for a non-existent duplicate through the node's children. This
loop would occur each time a duplicate game state was found, wasting
time for games where duplicate states are common.
add mcts benchmark for tic-tac-toe
add SetSeed method on MCTS type
create tests relating to (*MCTS).BestAction()
these tests check to see if BestAction returns nil
when it does not have enough information or just can't
add test for (*Tree).Search()
add statistical methods on trees
switch node.nodeVisits from float64 to int
refactor tictactoe test
Instead of running mcts multiple times, we run it once
using a TestMain func, and save the necessary values to check
so the other tests can run.
add tests for state/action comparability
NewMCTS: check if each inital action is comparable
the old implementation was flawed. It checked if the Action
type was comparable which always returned true.
This change checks the base type of each action returned
from the inital state, and checks if each type is comparable.
The reason we check each separate action is that there's no
reason that the slice won't contain multiple base types.
use democracy to get the best action among trees
test terminal status before expanding tree