I've been working on a project called Mind Circuit, a collection of six browser-based experiments with classical AI algorithms.
Each experiment has a small game or challenge alongside information about how the algorithm makes its decisions. Everything runs in JavaScript, and the project is hosted on GitHub Pages.
Predicting human choices
Predict Me asks you to choose between three shapes over 30 rounds. The machine makes its prediction before you select a shape.
There are five predictors. Some look at overall frequencies, others look at sequences of up to three previous choices. Another takes into account whether the previous prediction was correct.
Their relative weights change based on how well they predict your behaviour.
With three choices, random guessing gives an expected accuracy of 33.3%. Try repeating patterns, alternating between shapes or deliberately changing your strategy.
Solving a detective case
In Deduction, you investigate a case with eight suspects.
Each clue costs time. The algorithm ranks available clues by expected information gain divided by their cost.
You might eliminate several suspects with an expensive clue, while another clue could provide enough information for less time.
The implementation also calculates the cheapest possible proof by checking combinations of evidence. This makes it possible to compare the greedy algorithm's investigation with an optimal solution.
A hunter that learns
Hunter uses tabular Q-learning.
The player collects eight energy units and tries to reach the exit while being chased. The hunter's state includes its distance from the player, available directions and the direction towards the player's likely objective.
The Q-table contains 9,600 entries. The hunter explores randomly in 12% of its decisions and updates its action values during gameplay.
The table is saved in localStorage, so starting another match doesn't reset what the hunter has learned.
Drawing recognition with KNN
Classifier uses 3,500 training drawings from Google's Quick, Draw! dataset.
Drawings are centred and resized to 28×28 pixels, then converted into a normalised 196-element feature vector.
The classifier compares this vector with stored examples and selects the five nearest neighbours using cosine distance.
A category needs at least three votes, and the nearest example must be sufficiently close. Otherwise, the classifier returns an uncertain result.
You can inspect the neighbours, correct the answer and add your own labelled examples. There are also 300 separate drawings for testing the original classifier.
Rock, Paper, Scissors, Lizard, Spock
Five uses Regret Matching+ with a small amount of random exploration.
Suppose the opponent starts with equal probabilities for all five gestures and you choose Rock.
Paper and Spock would both win against Rock. After that first round, their probabilities increase to 47% each, leaving 2% for each of the other gestures.
As you continue playing, the algorithm updates its accumulated regrets and adjusts its strategy.
The machine selects its move before you make yours.
The original five-gesture game was created by Sam Kass and Karen Bryla.
Looking ahead in Reversi
Tactics is a 6×6 Reversi game using Minimax with Alpha-Beta pruning.
The search depth is three moves. Board evaluation considers the number of pieces, available moves, corner ownership and positions adjacent to empty corners.
Taking more pieces can be a bad decision if it allows the opponent to capture a corner on the next turn.
After each machine move, you can inspect the alternative moves, their evaluation scores and one simulated sequence of best responses. The interface also shows how many positions were evaluated and how many branches were pruned.
Source code
The experiments use vanilla JavaScript, HTML and CSS. There's no build step, backend or external AI API.
The source code is available under the MIT license. The Quick, Draw! dataset is attributed separately under CC BY 4.0.
