Trying to make a basic Python score counter in a game... will not count.

Discussion in 'Python' started by Darrien Glasser, Dec 16, 2012.

  1. Hey guys, I'm working on a Python rock paper scissors (lizard spock) game, and the beginning is complete. After I finished it, I thought, "You know what? I think I can make this even better, and add a score counter." And so I did.

    The problem is that it doesn't seem to actually keep track of score. In fact it always keeps the score at 0 for both players. It's fully functional otherwise, but it's bothering me that I can't get it to work.

    Currently using Windows Python 32 bit v2.6.8

    Download of the code here:

    https://www.box.com/s/2lupxeyk5jvsxs0zkdfb

    Copy of the code here:

    http://pastebin.com/MNdgiuSY

    Thanks in advance for your help...
     
    Darrien Glasser, Dec 16, 2012
    #1
    1. Advertising

  2. Darrien Glasser

    Kwpolska Guest

    Re: Trying to make a basic Python score counter in a game... will notcount.

    On Sun, Dec 16, 2012 at 6:00 PM, Darrien Glasser
    <> wrote:
    > Hey guys, I'm working on a Python rock paper scissors (lizard spock) game, and the beginning is complete. After I finished it, I thought, "You know what? I think I can make this even better, and add a score counter." And so I did.
    >
    > The problem is that it doesn't seem to actually keep track of score. In fact it always keeps the score at 0 for both players. It's fully functional otherwise, but it's bothering me that I can't get it to work.
    >
    > Currently using Windows Python 32 bit v2.6.8
    >
    > Download of the code here:
    >
    > https://www.box.com/s/2lupxeyk5jvsxs0zkdfb
    >
    > Copy of the code here:
    >
    > http://pastebin.com/MNdgiuSY
    >
    > Thanks in advance for your help...
    > --
    > http://mail.python.org/mailman/listinfo/python-list


    winx = winx + 1
    winy = winy + 1

    PS. please do not use pastebin.com.
    --
    Kwpolska <http://kwpolska.tk>
    stop html mail | always bottom-post
    www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
    GPG KEY: 5EAAEA16
     
    Kwpolska, Dec 16, 2012
    #2
    1. Advertising

  3. Awesome thanks, and sounds good.
     
    Darrien Glasser, Dec 16, 2012
    #3
  4. Re: Trying to make a basic Python score counter in a game... will notcount.

    Awesome thanks, and sounds good.
     
    Darrien Glasser, Dec 16, 2012
    #4
  5. Darrien Glasser

    Guest

    > Hey guys, I'm working on a Python rock paper scissors (lizard spock)
    > game, and the beginning is complete. After I finished it, I thought,
    > "You know what? I think I can make this even better, and add a score
    > counter." And so I did.
    >
    > The problem is that it doesn't seem to actually keep track of score.
    > In fact it always keeps the score at 0 for both players. It's fully
    > functional otherwise, but it's bothering me that I can't get it to
    > work.
    >
    > Currently using Windows Python 32 bit v2.6.8
    >
    > Download of the code here:
    > https://www.box.com/s/2lupxeyk5jvsxs0zkdfb
    >
    > Copy of the code here:
    > http://pastebin.com/MNdgiuSY


    If you are keeping the score in 'winx 'and 'winy' then you are adding
    one to the the values but not saving the results.

    I think you want

    winx = winx + 1

    or more concisely,

    winx += 1
     
    , Dec 16, 2012
    #5
  6. Darrien Glasser

    tbg Guest

    Actually, I was just going to post that it wasn't saving the scores. Great timing, I'll try it.
     
    tbg, Dec 16, 2012
    #6
  7. Darrien Glasser

    Guest

    On Sunday, December 16, 2012 10:09:53 AM UTC-7, Kwpolska wrote:
    >[...]
    > PS. please do not use pastebin.com.


    Why?
     
    , Dec 16, 2012
    #7
  8. Darrien Glasser

    Guest

    Re: Trying to make a basic Python score counter in a game... will notcount.

    On Sunday, December 16, 2012 10:09:53 AM UTC-7, Kwpolska wrote:
    >[...]
    > PS. please do not use pastebin.com.


    Why?
     
    , Dec 16, 2012
    #8
  9. Darrien Glasser

    Kwpolska Guest

    Re: Trying to make a basic Python score counter in a game... will notcount.

    On Sun, Dec 16, 2012 at 6:25 PM, <> wrote:
    > On Sunday, December 16, 2012 10:09:53 AM UTC-7, Kwpolska wrote:
    >>[...]
    >> PS. please do not use pastebin.com.

    >
    > Why?
    > --
    > http://mail.python.org/mailman/listinfo/python-list


    http://news.ycombinator.com/item?id=2595066 should answer this very question.
    --
    Kwpolska <http://kwpolska.tk>
    stop html mail | always bottom-post
    www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
    GPG KEY: 5EAAEA16
     
    Kwpolska, Dec 16, 2012
    #9
  10. Darrien Glasser

    tbg Guest

    On Sunday, December 16, 2012 12:16:34 PM UTC-5, wrote:
    > > Hey guys, I'm working on a Python rock paper scissors (lizard spock)

    >
    > > game, and the beginning is complete. After I finished it, I thought,

    >
    > > "You know what? I think I can make this even better, and add a score

    >
    > > counter." And so I did.

    >
    > >

    >
    > > The problem is that it doesn't seem to actually keep track of score.

    >
    > > In fact it always keeps the score at 0 for both players. It's fully

    >
    > > functional otherwise, but it's bothering me that I can't get it to

    >
    > > work.

    >
    > >

    >
    > > Currently using Windows Python 32 bit v2.6.8

    >
    > >

    >
    > > Download of the code here:

    >
    > > https://www.box.com/s/2lupxeyk5jvsxs0zkdfb

    >
    > >

    >
    > > Copy of the code here:

    >
    > > http://pastebin.com/MNdgiuSY

    >
    >
    >
    > If you are keeping the score in 'winx 'and 'winy' then you are adding
    >
    > one to the the values but not saving the results.
    >
    >
    >
    > I think you want
    >
    >
    >
    > winx = winx + 1
    >
    >
    >
    > or more concisely,
    >
    >
    >
    > winx += 1


    I changed it so that it said winx += 1 etc. and it doesn't seem to save it. I also tried pulling the variables from the loop and making them global variables at the top.

    The latter game me a traceback error when printing out the results. Any ideas?

    http://puu.sh/1BCbG

    Code Preview/Download

    https://www.box.com/s/jiu0259nohx0kae2am57
     
    tbg, Dec 16, 2012
    #10
  11. Darrien Glasser

    Kwpolska Guest

    Re: Trying to make a basic Python score counter in a game... will notcount.

    On Sun, Dec 16, 2012 at 6:44 PM, tbg <> wrote:
    > I changed it so that it said winx += 1 etc. and it doesn't seem to save it. I also tried pulling the variables from the loop and making them global variables at the top.
    >
    > The latter game me a traceback error when printing out the results. Any ideas?
    >
    > http://puu.sh/1BCbG
    >
    > Code Preview/Download
    >
    > https://www.box.com/s/jiu0259nohx0kae2am57
    > --
    > http://mail.python.org/mailman/listinfo/python-list


    Put this on top of your function:

    global winx, winy


    PS. Why did you put those delays in? They are useless.
    --
    Kwpolska <http://kwpolska.tk>
    stop html mail | always bottom-post
    www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
    GPG KEY: 5EAAEA16
     
    Kwpolska, Dec 16, 2012
    #11
  12. Darrien Glasser

    tbg Guest

    On Sunday, December 16, 2012 12:50:18 PM UTC-5, Kwpolska wrote:
    > On Sun, Dec 16, 2012 at 6:44 PM, tbg <> wrote:
    >
    > > I changed it so that it said winx += 1 etc. and it doesn't seem to save it. I also tried pulling the variables from the loop and making them global variables at the top.

    >
    > >

    >
    > > The latter game me a traceback error when printing out the results. Any ideas?

    >
    > >

    >
    > > http://puu.sh/1BCbG

    >
    > >

    >
    > > Code Preview/Download

    >
    > >

    >
    > > https://www.box.com/s/jiu0259nohx0kae2am57

    >
    > > --

    >
    > > http://mail.python.org/mailman/listinfo/python-list

    >
    >
    >
    > Put this on top of your function:
    >
    >
    >
    > global winx, winy
    >
    >
    >
    >
    >
    > PS. Why did you put those delays in? They are useless.
    >
    > --
    >
    > Kwpolska <http://kwpolska.tk>
    >
    > stop html mail | always bottom-post
    >
    > www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
    >
    > GPG KEY: 5EAAEA16


    I figured it would be too much for the person playing the game. Getting attacked with lines of text and all. Although it is a pain developing with it.

    And by the way, works perfectly now. Thanks for your help.
     
    tbg, Dec 16, 2012
    #12
  13. Darrien Glasser

    tbg Guest

    Re: Trying to make a basic Python score counter in a game... will notcount.

    On Sunday, December 16, 2012 12:50:18 PM UTC-5, Kwpolska wrote:
    > On Sun, Dec 16, 2012 at 6:44 PM, tbg <> wrote:
    >
    > > I changed it so that it said winx += 1 etc. and it doesn't seem to save it. I also tried pulling the variables from the loop and making them global variables at the top.

    >
    > >

    >
    > > The latter game me a traceback error when printing out the results. Any ideas?

    >
    > >

    >
    > > http://puu.sh/1BCbG

    >
    > >

    >
    > > Code Preview/Download

    >
    > >

    >
    > > https://www.box.com/s/jiu0259nohx0kae2am57

    >
    > > --

    >
    > > http://mail.python.org/mailman/listinfo/python-list

    >
    >
    >
    > Put this on top of your function:
    >
    >
    >
    > global winx, winy
    >
    >
    >
    >
    >
    > PS. Why did you put those delays in? They are useless.
    >
    > --
    >
    > Kwpolska <http://kwpolska.tk>
    >
    > stop html mail | always bottom-post
    >
    > www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
    >
    > GPG KEY: 5EAAEA16


    I figured it would be too much for the person playing the game. Getting attacked with lines of text and all. Although it is a pain developing with it.

    And by the way, works perfectly now. Thanks for your help.
     
    tbg, Dec 16, 2012
    #13
  14. Re: Trying to make a basic Python score counter in a game... willnot count.

    On 12/16/2012 12:00 PM, Darrien Glasser wrote:
    > Hey guys, I'm working on a Python rock paper scissors (lizard spock) game, and the beginning is

    complete. After I finished it, I thought, "You know what? I think I can
    make this even better, and add a score counter." And so I did.
    >
    > The problem is that it doesn't seem to actually keep track of score.

    In fact it always keeps the score at 0 for both players. It's fully
    functional otherwise, but it's bothering me that I can't get it to work.
    >
    > Currently using Windows Python 32 bit v2.6.8
    >
    > Download of the code here:
    >
    > https://www.box.com/s/2lupxeyk5jvsxs0zkdfb
    >
    > Copy of the code here:
    >
    > http://pastebin.com/MNdgiuSY
    >
    > Thanks in advance for your help...



    I was actually thinking of making a simple rock paper scissors game so I
    went ahead and cobbled it together, using a design with a class and
    generally a structured approach.. It keeps the scores, too, and you can
    set both players to be AI, or one to be AI, or both to be humans:

    https://github.com/pythonbyexample/PBE/blob/master/code/rockpaper.py

    (it needs python3 but can be easily changed to work with python2.x)


    - mitya

    --
    Lark's Tongue Guide to Python: http://lightbird.net/larks/
     
    Mitya Sirenef, Dec 16, 2012
    #14
  15. Darrien Glasser

    tbg Guest

    On Sunday, December 16, 2012 1:07:16 PM UTC-5, Mitya Sirenef wrote:
    > On 12/16/2012 12:00 PM, Darrien Glasser wrote:
    >
    > > Hey guys, I'm working on a Python rock paper scissors (lizard spock) game, and the beginning is

    >
    > complete. After I finished it, I thought, "You know what? I think I can
    >
    > make this even better, and add a score counter." And so I did.
    >
    > >

    >
    > > The problem is that it doesn't seem to actually keep track of score.

    >
    > In fact it always keeps the score at 0 for both players. It's fully
    >
    > functional otherwise, but it's bothering me that I can't get it to work.
    >
    > >

    >
    > > Currently using Windows Python 32 bit v2.6.8

    >
    > >

    >
    > > Download of the code here:

    >
    > >

    >
    > > https://www.box.com/s/2lupxeyk5jvsxs0zkdfb

    >
    > >

    >
    > > Copy of the code here:

    >
    > >

    >
    > > http://pastebin.com/MNdgiuSY

    >
    > >

    >
    > > Thanks in advance for your help...

    >
    >
    >
    >
    >
    > I was actually thinking of making a simple rock paper scissors game so I
    >
    > went ahead and cobbled it together, using a design with a class and
    >
    > generally a structured approach.. It keeps the scores, too, and you can
    >
    > set both players to be AI, or one to be AI, or both to be humans:
    >
    >
    >
    > https://github.com/pythonbyexample/PBE/blob/master/code/rockpaper.py
    >
    >
    >
    > (it needs python3 but can be easily changed to work with python2.x)
    >
    >
    >
    >
    >
    > - mitya
    >
    >
    >
    > --
    >
    > Lark's Tongue Guide to Python: http://lightbird.net/larks/


    Well there goes my hopes and dreams of being the first one to do that. Nice job by the way.
     
    tbg, Dec 16, 2012
    #15
  16. Darrien Glasser

    tbg Guest

    Re: Trying to make a basic Python score counter in a game... will notcount.

    On Sunday, December 16, 2012 1:07:16 PM UTC-5, Mitya Sirenef wrote:
    > On 12/16/2012 12:00 PM, Darrien Glasser wrote:
    >
    > > Hey guys, I'm working on a Python rock paper scissors (lizard spock) game, and the beginning is

    >
    > complete. After I finished it, I thought, "You know what? I think I can
    >
    > make this even better, and add a score counter." And so I did.
    >
    > >

    >
    > > The problem is that it doesn't seem to actually keep track of score.

    >
    > In fact it always keeps the score at 0 for both players. It's fully
    >
    > functional otherwise, but it's bothering me that I can't get it to work.
    >
    > >

    >
    > > Currently using Windows Python 32 bit v2.6.8

    >
    > >

    >
    > > Download of the code here:

    >
    > >

    >
    > > https://www.box.com/s/2lupxeyk5jvsxs0zkdfb

    >
    > >

    >
    > > Copy of the code here:

    >
    > >

    >
    > > http://pastebin.com/MNdgiuSY

    >
    > >

    >
    > > Thanks in advance for your help...

    >
    >
    >
    >
    >
    > I was actually thinking of making a simple rock paper scissors game so I
    >
    > went ahead and cobbled it together, using a design with a class and
    >
    > generally a structured approach.. It keeps the scores, too, and you can
    >
    > set both players to be AI, or one to be AI, or both to be humans:
    >
    >
    >
    > https://github.com/pythonbyexample/PBE/blob/master/code/rockpaper.py
    >
    >
    >
    > (it needs python3 but can be easily changed to work with python2.x)
    >
    >
    >
    >
    >
    > - mitya
    >
    >
    >
    > --
    >
    > Lark's Tongue Guide to Python: http://lightbird.net/larks/


    Well there goes my hopes and dreams of being the first one to do that. Nice job by the way.
     
    tbg, Dec 16, 2012
    #16
  17. Re: Trying to make a basic Python score counter in a game... willnot count.

    On 12/16/2012 01:17 PM, tbg wrote:
    > On Sunday, December 16, 2012 1:07:16 PM UTC-5, Mitya Sirenef wrote:
    >> On 12/16/2012 12:00 PM, Darrien Glasser wrote:
    >>
    >>> Hey guys, I'm working on a Python rock paper scissors (lizard spock) game, and the beginning is

    >> complete. After I finished it, I thought, "You know what? I think I can
    >>
    >> make this even better, and add a score counter." And so I did.
    >>
    >> >

    >>
    >> > The problem is that it doesn't seem to actually keep track of score.

    >>
    >> In fact it always keeps the score at 0 for both players. It's fully
    >>
    >> functional otherwise, but it's bothering me that I can't get it to work.
    >>
    >> >

    >>
    >> > Currently using Windows Python 32 bit v2.6.8

    >>
    >> >

    >>
    >> > Download of the code here:

    >>
    >> >

    >>
    >> > https://www.box.com/s/2lupxeyk5jvsxs0zkdfb

    >>
    >> >

    >>
    >> > Copy of the code here:

    >>
    >> >

    >>
    >> > http://pastebin.com/MNdgiuSY

    >>
    >> >

    >>
    >> > Thanks in advance for your help...

    >>
    >>
    >>
    >>
    >>
    >> I was actually thinking of making a simple rock paper scissors game so I
    >>
    >> went ahead and cobbled it together, using a design with a class and
    >>
    >> generally a structured approach.. It keeps the scores, too, and you can
    >>
    >> set both players to be AI, or one to be AI, or both to be humans:
    >>
    >>
    >>
    >> https://github.com/pythonbyexample/PBE/blob/master/code/rockpaper.py
    >>
    >>
    >>
    >> (it needs python3 but can be easily changed to work with python2.x)
    >>
    >>
    >>
    >>
    >>
    >> - mitya
    >>
    >>
    >>
    >> --
    >>
    >> Lark's Tongue Guide to Python: http://lightbird.net/larks/

    > Well there goes my hopes and dreams of being the first one to do that. Nice job by the way.


    Well you were the first :) I just did it to illustrate a modular
    approach, I think a
    simple game like that is a great learning opportunity.

    I posted an update with some small cleanups just now..

    --
    Lark's Tongue Guide to Python: http://lightbird.net/larks/
     
    Mitya Sirenef, Dec 16, 2012
    #17
  18. Darrien Glasser

    tbg Guest

    Nice, will have to try it out...
     
    tbg, Dec 16, 2012
    #18
  19. Darrien Glasser

    tbg Guest

    Re: Trying to make a basic Python score counter in a game... will notcount.

    Nice, will have to try it out...
     
    tbg, Dec 16, 2012
    #19
  20. Darrien Glasser

    alex23 Guest

    alex23, Dec 16, 2012
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. spartan
    Replies:
    1
    Views:
    1,323
    anupam
    Aug 17, 2004
  2. The Eeediot
    Replies:
    3
    Views:
    2,253
    =?Utf-8?B?UnVsaW4gSG9uZw==?=
    Dec 22, 2004
  3. George2
    Replies:
    1
    Views:
    810
    Alf P. Steinbach
    Jan 31, 2008
  4. Ian Kelly
    Replies:
    0
    Views:
    131
    Ian Kelly
    Dec 16, 2012
  5. Chris Angelico
    Replies:
    2
    Views:
    123
    Chris Angelico
    Dec 17, 2012
Loading...

Share This Page