I'm going to play rock-paper-scissors with a three-term operator, but when the user is 1 or 2, it runs well without a problem When the value of com is 3, Win for both 1 and 2 No matter how I change it, Win comes out, so which part should I modify?
Rock-paper-scissors is the epitome of a game where no pure strategy exists, so it cannot be determined by this simple ifelse. When the opponent gives scissors, rocks, and beams, you have to define the winning or losing process for each of the three. If not, the machine of rock-paper-scissors creates loopholes.
The code that determines victory or defeat is written in one line with two three-term operators appears to be because of poor readability. Even if it is slightly longer, it is better to make it easier for others to read.The other person here includes himself a year later.
© 2022 pinfo. All rights reserved.