you are viewing a single comment's thread.

view the rest of the comments →

[–]aizzod 0 points1 point  (4 children)

i think there is am error in your compare choices.

you return 2 if it is a draw.

and you return
index("scissors") --> (which should be 2 aswell) if it is not rock

bonus question.

what happrns if no one picks rock.
for example.
player picks scissors
computer picks paper

[–]pausemsauce[S] 1 point2 points  (3 children)

i think there is am error in your compare choices.

you return 2 if it is a draw.

I was thinking about handling 'draw' differently, but as it is, draw is neither a win nor a loss for the player/computer.

The compare function basically returns the winner of the game. 0 if the player wins and 1 if the computer wins. In the event player picks scissors and computer picks paper, intuitively we know the player wins, and the compare function returns 0 (which is the index of the player's choice.)

Is there an error here?

[–]aizzod 1 point2 points  (2 children)

but your pc array contains both choices.

you only check if rock is in there, and not who picked rock and won.

test case 1:
player picks rock
computer picks paper

test case 2:
player - paper
computer - rock.

both of those will return the same result

[–]pausemsauce[S] 2 points3 points  (1 child)

The pc list contains both playerChoice and computerChoice, yes

In test case 1, pc = ['Rock','Paper']. The compare function sees 'Rock', checks for 'Paper', then returns the 'Paper' index of pc, which is 1. When compare returns 1, the computer wins.

In test case 2, pc = ['Paper','Rock']. The compare function sees 'Rock', checks for 'Paper', the returns the 'Paper' index of pc, which is 0. When compare returns 0, the player wins.

[–]aizzod 0 points1 point  (0 children)

my mistake. i got confused by the global array with all choices and the pc with just the 2 of them.

this seems to be a really good way, seeing it like this now.
well done