An AI to play the Rock Paper Scissors game
https://github.com/SouravJohar/rock-paper-scissors
此项目给出了一个使用OpenCV + CNN 做手势识别,和机器人随机对战的界面游戏。
An AI to play the Rock Paper Scissors game
https://learnopencv.com/playing-rock-paper-scissors-with-ai/
给出了实现过程的详解。
Here’s a breakdown of our application in steps.
- Step 1: Gather Data, for rock, paper scissor classes.
- Step 2: (Optional) Visualize the Data.
- Step 3: Preprocess Data and Split it.
- Step 4: Prepare Our Model for Transfer Learning.
- Step 5: Train Our Model.
- Step 6: Check our Accuracy, Loss graphs & save the model.
- Step 7: Test on Live Webcam Feed.
- Step 8: Create the Final Application.
问题-1
手势数据为自行收集,数据收集的质量和数量, 对手势的识别准确度影响较大。
解决方法
https://colab.research.google.com/github/trekhleb/machine-learning-experiments/blob/master/experiments/rock_paper_scissors_cnn/rock_paper_scissors_cnn.ipynb#scrollTo=Q8lENOmkmiBF
TensorFlow提供了此游戏的手势数据集,可以直接使用
DATASET_NAME = 'rock_paper_scissors'
(dataset_train_raw, dataset_test_raw), dataset_info = tfds.load(
name=DATASET_NAME,
data_dir='tmp',
with_info=True,
as_supervised=True,
split=[tfds.Split.TRAIN, tfds.Split.TEST],
)
问题-2
此处的智能为视觉识别上的智能, 对于对弈过程中,机器人仅仅使用随机方法,来出招。
对于此机器人,可以对出招的策略进行建模,学习。
Q-learning强化学习版本
https://github.com/fanqingsong/rock-paper-scissors-AI-Bot/blob/master/play.py
还可以使用RNN来预测对手的出招
https://github.com/fanqingsong/boilerplate-rock-paper-scissors/blob/master/RPS.py
以及其他方法:
http://www.datasmith.org/2020/05/17/ai-for-rock-paper-scissors/
感知机等
There are other possible approaches, too:
- Monte Carlo approaches have been suggested, but it’s unlikely that a sufficiently large population of throws *made under extremely similar circumstances* could be obtained as the basis for MC simulation. I also suspect that the combinatorial space of the problem isn’t large enough to make MC a good approach.
- A Markov chain (a contextual Markov chain, not a pure Markov process) seems like a tempting approach, but as with Monte Carlo, part of the challenge would be in building up a corpus of observed throws from which to project the next throw. This approach may be very powerful but would require both an interesting Markov chain algorithm, and a pre-existing body of game histories from which scenarios relevant to the current game could be selected. Further research on this would be interesting.
- Bayesian logic seems like a good fit, since we are taking a sequence of observations (throws) and adjusting an expected outcome. An important challenge, however, would be this: how would the Bayesian model react to sudden changes of opponent strategy? If an opponent who has thrown scissors twenty times suddenly throws paper four times, can the Bayesian model be re-weighted to represent the fact that the next throw is likely to be paper? I’m not sure.