Hi all,

I'm trying to implement some game logic. First i would like to give an

example.

We have 3 different colors of cards. In each color there are 504 cards

(numbered from 0 to 503).

Now each player is given some cards. The cards given to each player

shall be represented by a combination of following

a). Individual card number

b). Range of card numbers.

c) Note: each player will have cards belonging to only one color. one

player cannot have same color cards as another player.

eg. player 1 has : yellow cards (1,3, 20-30,50, 99, 200-310)

player 2 has : green cards (1-100, 301-305, 499)

I want to implement a structure which can represent the cards each

player has.

typedef struct

{

T_COLOR color;

int length; /*length of absolute card numbers */

int *num; /* array of standalone numbers, ie not represented by

ranges */

int num of range; /*length of number of ranges */

int *start; /* indicate start of each range */

int *end; /* indicate end of each range */

}

For example

layer 1 has : yellow cards (1,3, 20-30,50, 99, 200-310)

This is represented in the above structure like,

{

color = YELLOW

length = 3;

num = [1,3,99]

num_of_range = 2

start = [20,200]

end = [30,310]

}

Adding some complexity on top of this is, i should be able to

dyanmically add and remove number of cards to each player. Again this

dynamic input is represented by

eg: Add the following cards for player 1 : Yellow cards (320, 401-419)

remove the following cards for player 2: green cards (40-50, 301)

I thought of implementing this in bitmaps. But memory is of concern

here (sometimes a player can have only one card, so pre-allocating a

bitmap of size 504 seemed overkill). Can someone comment on the

structure ? Is there a better way to implement these ?

Thanks