This page explains the five AI algorithms used in our experiment. Understanding these helps us think about how artificial intelligence makes decisions and learns from data.
The simplest AI just picks randomly every time. This gives us a baseline to compare other algorithms against.
makeMove() {
const choices = ['Rock', 'Paper', 'Scissors'];
const randomIndex = Math.floor(Math.random() * 3);
return choices[randomIndex];
}
Why it's useful: Random play is unpredictable. No strategy can consistently beat it - you'll win about 33% of the time, lose 33%, and tie 33%.
This AI remembers your last move and plays the move that would beat it. It assumes you'll repeat your previous choice.
makeMove() {
// If no previous moves, play randomly
if (this.playerHistory.length === 0) {
return this.playRandom();
}
// Get the player's last move
const lastPlayerMove = this.playerHistory[this.playerHistory.length - 1];
// Play the move that beats their last move
if (lastPlayerMove === 'Rock') return 'Paper';
if (lastPlayerMove === 'Paper') return 'Scissors';
if (lastPlayerMove === 'Scissors') return 'Rock';
}
Strategy insight: This works well against players who repeat moves or get stuck in patterns. However, once you realize what it's doing, you can easily beat it by avoiding repetition.
This AI tracks which move you use most often and always plays the counter to that favorite move.
makeMove() {
// Track frequencies: { Rock: 5, Paper: 3, Scissors: 2 }
let mostFrequent = 'Rock';
let maxCount = this.playerFrequency.Rock;
if (this.playerFrequency.Paper > maxCount) {
mostFrequent = 'Paper';
maxCount = this.playerFrequency.Paper;
}
if (this.playerFrequency.Scissors > maxCount) {
mostFrequent = 'Scissors';
}
// Play the move that beats their most frequent choice
if (mostFrequent === 'Rock') return 'Paper';
if (mostFrequent === 'Paper') return 'Scissors';
if (mostFrequent === 'Scissors') return 'Rock';
}
Strategy insight: Most people have unconscious biases toward certain moves. This AI exploits your overall tendencies rather than short-term patterns.
This AI replicates the exact strategy from the Mohammadi Sepahvand et al. (2014) research study. It has three phases with increasing bias toward certain moves.
makeMove() {
const random = Math.random();
if (this.moveCount <= 200) {
// Phase 1: Random (33% each)
return choices[Math.floor(Math.random() * 3)];
} else if (this.moveCount <= 400) {
// Phase 2: Light bias (50% Rock, 25% Paper, 25% Scissors)
if (random < 0.5) return 'Rock';
if (random < 0.75) return 'Paper';
return 'Scissors';
} else {
// Phase 3: Heavy bias (10% Rock, 80% Paper, 10% Scissors)
if (random < 0.1) return 'Rock';
if (random < 0.9) return 'Paper';
return 'Scissors';
}
}
Research purpose: This AI was used in the original study to test how humans adapt to changing opponent strategies. The gradual bias increase tests human pattern detection abilities.
The most sophisticated AI, implementing the ELPH (Entropy Learned Pruned Hypothesis space) algorithm from academic research. It uses advanced mathematics to detect and exploit patterns.
// Example: Your last 3 moves were Rock-Paper-Scissors
// ELPH generates hypotheses:
// "Rock" → ? (from all games starting with Rock)
// "Paper" → ? (from all games where Paper was played)
// "Rock-Paper" → ? (from all Rock-Paper sequences)
// "Paper-Scissors" → ? (from all Paper-Scissors sequences)
// "Rock-Paper-Scissors" → ? (from all Rock-Paper-Scissors sequences)
// It calculates entropy for each pattern:
// "Rock-Paper" has low entropy (you always play Scissors after this)
// "Paper" has high entropy (you play randomly after Paper)
// It selects the most reliable pattern and counters your predicted move
Why it's challenging: ELPH combines the best of all strategies - it finds your patterns like Pattern AI, but uses rigorous mathematics to avoid false patterns. It's designed to be as close to optimal play as possible.
The advanced AIs use different confidence measures:
// Frequency Counter: Only predict if enough data
if (totalMoves >= 5) {
return mostFrequentMove;
}
// ELPH: Only predict if entropy is low enough
if (patternEntropy <= entropyThreshold && observations >= minObservations) {
return reliablePattern;
}
This prevents the AIs from making overconfident predictions based on limited or unreliable data.
Good AI systems have fallbacks when their primary strategy fails:
As you play against these AIs, ask yourself:
These AIs enable interesting research questions:
Research note: These questions mirror real research in AI detection, human-computer interaction, and game theory. Understanding how people interact with different AI systems is crucial for designing better technology.
Our AI implementations demonstrate a clear progression from simple to sophisticated:
Real-world Connection: This progression mirrors how AI systems are built in practice - from simple rule-based systems to complex machine learning models that use statistical analysis and uncertainty quantification.
This collection demonstrates core AI concepts through interactive gameplay. Students can experience the difference between rule-based AI (Counter), statistical AI (Frequency Counter), research methodology (Biased Random), and advanced pattern recognition (ELPH). The progression from simple to sophisticated mirrors both the historical development of AI and modern machine learning pipelines.