| | |
Memory game
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
Hi!
I need help with a memory game. I dont know how to do when I want the users choice to appear. The function guessing. I want the user to first write e.g. A1 and then B2. and the doldmatris() is the one with the words. Then the start function will get the words so you can see and if the words the same they should stay there and still appear. Anyone with any ideas of how I can do?thank you
and if you see something that can be done with a nicer coding please give me the advice
I need help with a memory game. I dont know how to do when I want the users choice to appear. The function guessing. I want the user to first write e.g. A1 and then B2. and the doldmatris() is the one with the words. Then the start function will get the words so you can see and if the words the same they should stay there and still appear. Anyone with any ideas of how I can do?thank you

and if you see something that can be done with a nicer coding please give me the advice

Python Syntax (Toggle Plain Text)
import random class Matrix(object): def __init__(self, cols, rows, letters): letters = ['A','B','C','D','E','F'] print ' 1 2 3 4 5 6' self.cols = cols self.rows = rows self.matrix = [] for i in range(rows): ea_row = [] for j in range(cols): ea_row.append('---') self.matrix.append(ea_row) def setitem(self, col, row, v): self.matrix[col][row] = v def getitem(self, col, row): return self.matrix[col][row] #Print out the letters def __repr__(self): outStr = "" for i in range(self.rows): outStr += '%s %s\n' % (letters[i], self.matrix[i]) return outStr def start(): start = Matrix(6,6,0) print start #Hidden matrix to import the words from the list and #then compare with the other matrix def doldmatris(): infile = open('memo.txt', 'r') words = infile.readlines() infile.close() index = 0 while index < len(words): words[index] = words[index].rstrip('\n') index += 1 random.shuffle(words) index = 1 dold = [] for i in range(6): ia_row = [] for j in range(6): ia_row.append(words[i]) i +=1 dold.append(ia_row) return dold def guessing(): row = raw_input('Which row? (A-F)').lower() col = input('Which column? (1-6)') return guess def main(): start() doldmatris() guessing() main()
•
•
Join Date: May 2008
Posts: 538
Reputation:
Solved Threads: 86
Is this game supposed to be like the card game memory?
Where you turn over two cards and if they match you count the pair (usually removing the cards) and if not flip them back over?
So for each user turn:
the user should pick a first card
you 'turn face up' the first card
(display the grid)
the user should pick a second card
you 'turn face up' the second card
(display the grid)
if the cards match, remove the cards from play
if the cards do not match, turn then back 'face down'
(display the grid)
until the user has either matched all of the cards or quit
This means that each location in the grid has one of 3 states: face down, face up, empty
If you would like further assistance, please implement more of the code. It would also be nice if your posted code would at least compile, and if you want to use an external file, a sample of what that file was intended to contain would also be useful.
PS- As an alternative design to the 'scrolling text' method you are using, if you are at least passing familiar with the python graphic support, this application would lend itself well to a grid of buttons. Although it would be a very different approach from what you have, I think the result would be more user friendly.
Where you turn over two cards and if they match you count the pair (usually removing the cards) and if not flip them back over?
So for each user turn:
the user should pick a first card
you 'turn face up' the first card
(display the grid)
the user should pick a second card
you 'turn face up' the second card
(display the grid)
if the cards match, remove the cards from play
if the cards do not match, turn then back 'face down'
(display the grid)
until the user has either matched all of the cards or quit
This means that each location in the grid has one of 3 states: face down, face up, empty
If you would like further assistance, please implement more of the code. It would also be nice if your posted code would at least compile, and if you want to use an external file, a sample of what that file was intended to contain would also be useful.
PS- As an alternative design to the 'scrolling text' method you are using, if you are at least passing familiar with the python graphic support, this application would lend itself well to a grid of buttons. Although it would be a very different approach from what you have, I think the result would be more user friendly.
![]() |
Similar Threads
- Beautyfull Memory Game (Geeks' Lounge)
- Spark Game (Highly Addictive) (Geeks' Lounge)
- Memory game with c++ console applicaton (C++)
- why wont my flash game work? (Graphics and Multimedia)
- why i can not load game on one partition but can on aother (Troubleshooting Dead Machines)
- Freezes and Odd things after memory upgrade (Windows NT / 2000 / XP)
- Big Game need progrmmers (C++)
- SHUTDOWNS, new video card (Monitors, Displays and Video Cards)
Other Threads in the Python Forum
- Previous Thread: help with this program
- Next Thread: Auth Object
| Thread Tools | Search this Thread |
address aliased anydbm app bash beginner bits calling casino changecolor cipher clear conversion coordinates corners count cturtle curves definedlines development dictionary digital dynamic events examples excel external feet file float format function gui handling hints homework iframe images import input java keycontrol line linux list lists loan loop matching mouse multiple number numbers output parsing path port prime programming projects py py2exe pygame pymailer python random rational raw_input recursion recursive scrolledtext searchingfile shebang signal singleton split string strings tails terminal text threading time tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 valueerror variable web-scrape whileloop word wxpython xlwt





