HELP with Rock, Paper, Scissor Game

[color=Blue]This is the template that we are suppose to use while doing the program, I am a beginner to this programming language and really have no clue what I am doing[/color]


import random
#table of winning plays
win_play_for = {

Comments

  • Hello, swt_thang.
    Here are a couple suggestions for you.

    You don't need to keep track of next b/c you can get to the end of the list with
    hist[-1] or hist[len(hist)-1]

    You can update hist with either
    hist += ['x'] #'x' has to be in a list here
    or
    hist.append('x')

    You can guess the player's next move using something like
    move = hist[random.randint(1, len(hist)-1)]#selects a random element out of hist
    move = win_move_for[move] #converts the player's move into what would beat it
    #the above 2 lines could be smushed into one line, but I ran out of room

    You can calculate who wins w/ something like:
    if win_move_for(user_move) == move:
    #computer wins
    elif win_move_for(move) == user_move:
    #user wins
    else:
    #tie, assuming valid input

    Hope that helps.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion