Memory game

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 2
Reputation: kempablavitt is an unknown quantity at this point 
Solved Threads: 0
kempablavitt kempablavitt is offline Offline
Newbie Poster

Memory game

 
0
  #1
Nov 3rd, 2008
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. ...
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 943
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 146
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is online now Online
previously paulthom12345

Re: Memory game

 
0
  #2
Nov 3rd, 2008
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.
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,063
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 267
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: Memory game

 
0
  #3
Nov 3rd, 2008
Originally Posted by kempablavitt View Post
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.
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 943
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 146
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is online now Online
previously paulthom12345

Re: Memory game

 
0
  #4
Nov 4th, 2008
Okay, well here is one i knocked together, it dosent let you win but it has a lot of the features you will need:
  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.
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC