Design comparison
Solution retrospective
it is fine but need some of refactor in future :D
Community feedback
- @turtlecrabPosted over 2 years ago
Hey, nice submission!
There are some problems in the game logic:
- There are no draws. It's probably your design decision and you are aware of this, but it's not Rock Paper Scissors when your opponent knows your hand and doesn't repeat it.
- The opponent's choice is biased towards the Rock. This is because of how you generate the choice:
const guess = shapes[Math.round(Math.random() * 2)]
You round a number between 0 and 2, so:
0 < N < 0.5
=0
0.5 < N < 1.5
=1
1.5 < N < 2
=2
As you can see the range that rounds to
1
is two times bigger than others. So if you choose the Paper every move, the opponent will choose the Rock in66%
and the Scissors in33%
. And vice versa, when you choose the Scissors you lose twice as frequent as you win.The proper random number is:
Math.floor(Math.random() * 3)
Also there are accessibility warnings that you should check out, accessibility is important.
Hope this helps.
Marked as helpful2@KhaledSobhy10Posted over 2 years ago@turtlecrab Thanks for your useful feedback 1- There are no draws >> yes i want that 2- Your right , will fix it
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord