Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 5 implement artificial intelligence algorithms #24

Merged
merged 8 commits into from Dec 13, 2019

Conversation

j-richey
Copy link
Owner

Adding the AI algorithms per the task described in task #5.

Note: the README.md file is not yet updated to mention how to run the benchmarks. I felt like this will be better if done at the same time as adding the code example and other updates that are schedule as part of task #6.

This includes the AIPlayer and AIOutcome enums, helper methods for
building from the game's state, and unit tests.

See issue #5.
The AIOpponent struct contains the majority of the AI algorithms logic.
Test and documentation are added to describe how to use the structure
and to ensure it works as expected.

Note: There are still some rough spots in this commit such as duplicated
code for finding the best position and insufficient documentation
examples.

See issue #5.
Rename the AIOpponent and AIOutcome structures to Opponent and Outcome
respectively. Since these live in the AI module the AI prefix is
unnecessary.

See issue #5.
The worst case AI update time is where a new game with an empty board
must be evaluated.

See issue #5.
Refactor the ai::best_position() and ai::worst_outcome() functions to
use a loop instead of a series of if-else statements. This reduces code
duplication with the set / map key names and simplifies the functions.

See issue #5.
The updated documentation includes a full game played by two AI
opponents.
This commit adds additional benchmarks: one for playing an entire game
and others for the perfect AI with various numbers of remaining free
positions. This helps provide more insight on the performance
characteristics of the library.
The specification for ai::Opponent::new() is to clamp the mistake
probability to the range [0, 1]. This was not being done which would
have resulted in a panic for incorrect values provided.

This commit ensures the values are being clamped.
@j-richey j-richey merged commit 659a518 into master Dec 13, 2019
@j-richey j-richey deleted the issue-5-implement-artificial-intelligence-algorithms branch December 13, 2019 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant