Machine Learning with Python Projects - Rock Paper Scissors

Tell us what’s happening:

Ok, I toiled on it the whole day but I think it’s time to ask for help.
Basically, after several failed implementations, I finally came down to a strategy I’m partially happy with. My strategy is:

  • Open with a random move;
  • From there on, simply look at the last move the opponent played and play the ideal response to it
  • Repeat that for x turns (x = revisit_frequency). If the strategy is not working (success rate < 60%), then an adaptive algorithm kicks in. It’s supposed to be a simply Hidden Markov Chain, with a variable lookback period used to calculate the transition and stationary probability tables. This should make my approach less guess-y and more reactive to the opponent play style

I can beat quincy and mrugesh consistently (usually around 100 and 85% win rates), but I’m struggling to adapt my strategies to abbey and kris (unable to leave the 50% win rate mark). But after looking at this code the whole day, I’m kind of burned out and unable to tell if:

  • My algorithm is properly implemented or not
  • If I just need parameter adjustment or a total logic revamp
  • If my overall approach is flawed

I know the reactive portion of my algorithm will struggle against kris anyway because he’s a non-Markovian player, but I would assume my implementation would work well against abbey?

Anyway, what I’m asking is a mix of feedback about both my overall approach, as well as for my Markov Chain implementation. Any pointers would be welcome. This challenge feels an extreme step-up in difficulty compared with some of the recent projects in other modules (well, maybe not so extreme compared how much I had to study outside the module to implement the multiplayer game), but I know this feedback has been shared previously by other users reading the past forum posts.

Thanks in advance!

Your code so far

https://gitpod.io/start/#freecodecam-boilerplate-b3xfq79tdlz

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0

Challenge Information:

Machine Learning with Python Projects - Rock Paper Scissors

I can’t really find the option to edit my post, so I’ll just reply here. I ended up refactoring my approach to the problem and simplifying the implementation of the markov chain, and now I can complete the challenge. Cheers!