943,919 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 587
  • Python RSS
Nov 3rd, 2008
0

Memory game

Expand Post »
I need help to get started with this. Any one that knows any examples I can get inspire from?

Im going to create a game that plays Memory. The user should try to solve a
6x6 matrix by matching words in different cells in a matrix.It should look like this:
1 2 3 4 5 6
A - - - - - --
B - - - - - --
C - - - - - --
D - - - - - --
E - - - - - --
F - - - - - --
==================
Choice1: A5

1 2 3 4 5 6
A - - - - fun --
B - - - - - --
C - - - - - --
D - - - - - --
E - - - - - --
F - - - - - --
==================
Choice2: B7,
etc. ...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kempablavitt is offline Offline
2 posts
since Nov 2008
Nov 3rd, 2008
0

Re: Memory game

Okay, do you have any code so-far or are you starting from scratch?
Last edited by Paul Thompson; Nov 3rd, 2008 at 3:22 pm.
Reputation Points: 264
Solved Threads: 183
Veteran Poster
Paul Thompson is offline Offline
1,095 posts
since May 2008
Nov 3rd, 2008
0

Re: Memory game

I need help to get started with this. Any one that knows any examples I can get inspire from?
Looks like he's starting from scratch.
Reputation Points: 355
Solved Threads: 292
Veteran Poster
jlm699 is offline Offline
1,102 posts
since Jul 2008
Nov 4th, 2008
0

Re: Memory game

Okay, well here is one i knocked together, it dosent let you win but it has a lot of the features you will need:
python Syntax (Toggle Plain Text)
  1. import random
  2.  
  3.  
  4. def start():
  5. words = ['one','one','two','two','three','three',
  6. 'four','four','five','five','six','six']
  7. d = {}
  8. random.shuffle(words)
  9.  
  10. for index, word in enumerate(words):
  11. d[index] = word
  12. return d
  13.  
  14. def printboard(d,revealed):
  15. side = 1
  16. print " 1 2 3 4"
  17. print "A",
  18. for i,f in enumerate(d.keys()):
  19. if revealed[i]:
  20. print d[f],
  21. else:
  22. print '--',
  23.  
  24. if (i+1)%4==0:
  25.  
  26. if i==3:
  27. print
  28. print "B",
  29.  
  30. elif i == 7:
  31. print
  32. print "C",
  33. def guess(rev):
  34. values= {'a':0,
  35. 'b':4,
  36. 'c':8}
  37. row = raw_input("\nWhat row do you choose? (a,b,c)").lower()
  38. col = input("What column do you choose? (1,2,3,4)")
  39. row = values[row]
  40. total = row+col-1
  41. if rev[total]==True:
  42. rev[total]='already_guessed'
  43. else:
  44. rev[total] = True
  45. return rev, total
  46.  
  47.  
  48. def Main():
  49. rev = [False for f in range(12)]
  50. d = start()
  51.  
  52.  
  53. while True:
  54. printboard(d,rev)
  55. rev, total = guess(rev)
  56. printboard(d,rev)
  57. rev, total2 = guess(rev)
  58.  
  59. if d[total]==d[total2]:
  60. print "\nGreat you got one"
  61. else:
  62. printboard(d,rev)
  63. print "\nOh no, not this time"
  64. raw_input("enter to continue")
  65.  
  66.  
  67. if rev[total] == 'already_guessed':
  68. pass
  69. else:
  70. rev[total]=False
  71.  
  72.  
  73. if rev[total2] == 'already_guessed':
  74. pass
  75. else:
  76. rev[total2] = False
  77.  
  78. if __name__ == '__main__':
  79. Main()
Last edited by Paul Thompson; Nov 4th, 2008 at 5:26 pm.
Reputation Points: 264
Solved Threads: 183
Veteran Poster
Paul Thompson is offline Offline
1,095 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: boost python question
Next Thread in Python Forum Timeline: Need a bit of Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC