Tell us what’s happening:
Looking for general guidance with this project. I have looked at the bots and their strategies and just tried to play around with creating my own strategy (use least frequent of last 10 moves as a predictor, use average of last 10 moves, keeping track of my own moves and trying to use those as part of it, etc.) and they are beating some, but not others. What are we intended to use for this project?
The module is machine learning, so it seems obvious that we should be building a neural network of some kind, but other projects I have done on fCC don’t necessarily use the exact tools that were in the practice. So just wondering if the intention is to definitely use a NN or maybe just get creative enough and you could win without one? I just don’t want to waste my time going down one path and it be completely wrong. (Honestly, I’m avoiding the NN thing because the videos were no where close to enough for me to be able to create one on my own, so it would take a long time to figure it out)
Your code so far
import random
def player(prev_play, opponent_history=[], my_history=[]):
choices = ['R', 'P', 'S']
if prev_play == '' or len(my_history) % 2 == 1:
guess = random.choice(['R', 'P', 'S'])
else:
prediction_index = (choices.index(my_history[-1]) + 1) % len(choices)
prediction = choices[prediction_index]
ideal_response = {'P': 'S', 'R': 'P', 'S': 'R'}
guess = ideal_response[prediction]
my_history.append(guess)
return guess
### Your browser information:
User Agent is: <code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36</code>
### Challenge Information:
Machine Learning with Python Projects - Rock Paper Scissors
https://www.freecodecamp.org/learn/machine-learning-with-python/machine-learning-with-python-projects/rock-paper-scissors