Python Forum
Forum-wide Competition: Rock Paper Scissors [Meta-thread]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Forum-wide Competition: Rock Paper Scissors [Meta-thread]
#7
(Oct-08-2016, 10:13 PM)wavic Wrote: This define a set(), right? But you initiate as a dictionary. Or I am wrong?
responses = {}
for me in 'RPS':
    for them in 'RPS':
        responses[me + them] = collections.Counter('RPS')

The responses variable is not a set, it is a dictionary ({} is the literal for an empty dictionary). The keys of responses are all the possible two-player plays: RR, RP, RS, PR, PP, PS, SR, SP, and SS. It tracks what the opponent did after each round, based on what was played in that round. So if the previous round was RP, and the opponent plays S, responses['RP'] gets one added to S. That means the next time the previous round was RP, Sirius will be more likely to guess that the opponent will play S, and therefore Sirius will be more likely to play R.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Forum-wide Competition: Rock Paper Scissors [Meta-thread] - by ichabod801 - Oct-08-2016, 10:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  system-wide unique incrementing string or number Skaperen 11 4,309 Jul-08-2020, 08:10 PM
Last Post: Yoriz
  re module: want a regexhttps://python-forum.io/Thread-re-module-want-a-regex Skaperen 4 2,648 Sep-19-2019, 10:54 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020