473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Memory game, good structure

Hi.

I need some help with a memory game. How should I structure it before I begin to write it.
Is it good to have a class that defines a matrix for the play board and something like that?
Or should I use functions that defines lists and for-slings? Whats the easiest way? Im thinking about lists, and then functions to do all the commands from the user and everything else.

its going to look something like this:

1 2 3 4 5 6
A - - - - - -
B - - - - - -
C - - - - - -
D - - - - - -
E - - - - - -
F - - - - - -
==================
choice1: A5

1 2 3 4 5 6
A - - - - kul -
B - - - - - -
C - - - - - -
D - - - - - -
E - - - - - -
F - - - - - -
==================
choice2: B7 etc..
Nov 6 '08 #1
1 2148
bvdet
2,851 Expert Mod 2GB
I would create a class object and initialize a dictionary. The rows (A,B,C,D...) would be the dictionary keys and the values would be lists. Provide overload methods __str__, __setitem__, and __getitem__ to print, set individual cells, and retrieve individual cells. You can add whatever methods from there to suit your game. Possible interaction:
Expand|Select|Wrap|Line Numbers
  1. >>> g = Game(6)
  2. >>> g['C3']=10
  3. >>> g['C3']
  4. 10
  5. >>> g['C4']
  6. '-'
  7. >>> print g
  8.            0     1     2     3     4     5
  9.      A     -     -     -     -     -     -
  10.      B     -     -     -     -     -     -
  11.      C     -     -     -    10     -     -
  12.      D     -     -     -     -     -     -
  13.      E     -     -     -     -     -     -
  14.      F     -     -     -     -     -     -
  15. >>>
Nov 6 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Moosebumps | last post by:
When I have time, I am planning to evaluate Python for console game development (on Playstation 2, GameCube, and Xbox). Does anyone have any experience with this? Pretty much the only resource...
1
by: Cyhawk | last post by:
Hello. Im working on a game, (mud actually) (socketmud for anyone who cares ;) and ive decided on a very large array to hold my world data. (Nethack style, every cord == number == represents a...
13
by: hurry | last post by:
In order to avoid declaring static variables in a function I was asked to write a scratch memory. Reserve a block of memory outside the function and assigning pointers to the memory locations as...
10
by: goose | last post by:
Hello all I've written a wrapper for malloc and friends. Its available from http://www.lelanthran.com/downloads/os_mem/index.php The reason for doing writing this so that newbies can...
18
by: MajorSetback | last post by:
I am using the Redhat version of Linux and GNU C++. It is not clear to me whether this is a Linux issue or a C++ issue. I do not have this problem running the same program on Windows but...
10
by: sam_cit | last post by:
Hi Everyone, I'm working on developing a chess game and i decided to use c++ for its object oriented approach. I have a bass class unit and is inherited to distinct number of units (like king,...
62
by: Generic Usenet Account | last post by:
A lot of research has been done to prove that the contention that C code is more efficient and more compact than equivalent C++ code is a myth. My posting pertains to a slightly different aspect...
3
by: dawson.jon | last post by:
Hello: In C# is there a way to declare a certain portion of memory protected or secure, so that when you shut down an application that area of memory will get overwritten or allow someone to...
12
by: David Given | last post by:
I have a situation where I need to be able to allocate chunks on unmapped virtual memory. Because the memory I'm allocating isn't mapped, I can't use a normal memory allocator, as most of them...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.