Description
β Problem Statement
The current Rock Paper Scissors implementation uses a completely random strategy for generating the computer's move.
In the web version, the computer's move is selected using:
const computerChoice = choices[Math.floor(Math.random() * 3)];
In the Python CLI version, the computer's move is selected using:
computer_choice = random.choice(choices)
I reviewed the current implementation and verified that the move selection is statistically fair and unbiased. Each option (Rock, Paper, and Scissors) has an equal probability of being selected.
However, every round is completely independent because the computer does not track previous player moves or adapt its strategy based on user behavior.
As a result, repeated gameplay can feel repetitive since the computer opponent always behaves the same way regardless of how the player plays.
π Proposed Enhancement
Enhance the computer opponent by introducing adaptive move selection based on the player's recent move history.
Instead of relying entirely on random selection, the computer can analyze recent player choices, identify simple patterns, and use that information to make more informed decisions.
Example:
Player history:
Rock
Rock
Paper
Rock
Rock
Observed pattern:
Rock is the most frequently selected move
Predicted next move:
Rock
Computer response:
Paper (counter move)
The goal is not to make the opponent unbeatable, but to make gameplay feel more interactive, strategic, and engaging while maintaining fairness.
π Suggested Implementation
Store the player's recent choices in an array.
Analyze either:
The most frequently used move, or
The last 3β5 moves to detect recent trends.
Predict the player's likely next move.
Select a counter move based on the prediction.
Optionally combine prediction with a degree of randomness to keep the gameplay balanced.
Benefits
Improves user engagement.
Increases replayability.
Encourages strategic thinking.
Makes the computer opponent feel more responsive.
Requires no external libraries, machine learning, or additional dependencies.
Remains beginner-friendly and lightweight.
I am a registered GSSoC 2026 contributor.
I would like to implement this feature myself.
π Assignment Request
I would like to work on this feature under GSSoC'26. Kindly assign this issue to me if it is available.
Thank you!
Description
β Problem Statement
The current Rock Paper Scissors implementation uses a completely random strategy for generating the computer's move.
In the web version, the computer's move is selected using: