
-----------------------------------
SpaceDude
Thu Jun 03, 2004 3:06 pm

array in an array?
-----------------------------------
well hmm i'm trying to make an array inside an array
so i try to do it but its not working lol...

var a : array 1 .. 4 of int := init (b, b, b, b)
var b : array 1 .. 13 of int

??
i dunno how to put it together
like i want the 1..4 array to contain 1..13 array in each spot, how can i do this?

thanks

-----------------------------------
Cervantes
Thu Jun 03, 2004 3:34 pm


-----------------------------------
making a card game eh? 8)

for this use a 2D array.


var deck : array 1 .. 4, 1 .. 13 of int


-----------------------------------
SpaceDude
Thu Jun 03, 2004 3:47 pm


-----------------------------------
ya thanks =D
lol
now i just somehow need to make the deck shuffle and have to keep track of the cards using boolean now lol

-----------------------------------
Tony
Thu Jun 03, 2004 3:58 pm


-----------------------------------
deck shuffle is very simple... well.. if you keep cards in a 1D array (having it as 2D just complicates things)
[url=http://www.compsci.ca/v2/viewtopic.php?t=2184]deck shuffle

-----------------------------------
Cervantes
Thu Jun 03, 2004 4:10 pm


-----------------------------------
despite being less organized, I think a 1 dimensional array from 1 to 52 is actually the better way to go with this.  it makes shuffling and dealing a lot easier.

though I guess it depends on what type of game you are making.  For games with trump (Euchre, 500, Bridge) or other games such as Hearts, a 2D array might be best.  But for Blackjack or War or something, 1 .. 52 might be easier.

how are you planning on shuffling and keeping track of cards?

EDIT: erg that took me forever to type.  damn MSN  :x 

-----------------------------------
SpaceDude
Thu Jun 03, 2004 4:14 pm


-----------------------------------
ya was deciding like wat type of array i want
so i was experimenting it
but if i use 1d array rite, like i can use rand.int  to help me shuffle it, but if i need to keep track of it i need to use boolean rite?
so how can i keep track with it with boolean?
when i mean keep track like, if i got a 3rd of spades out, i can't draw another 3rd of spade again

EDIT: like i'm thinking of keeping the suits of the cards by different colour, i don't want any graphics or anything in this game since i'm trying to keep it as simple as possible

-----------------------------------
Cervantes
Thu Jun 03, 2004 4:34 pm


-----------------------------------
um, I would tag it with an integer.  0 means its in the deck, 1 means its in player 1s hand, 2 means its in player 2s hand.

-----------------------------------
SpaceDude
Thu Jun 03, 2004 4:48 pm


-----------------------------------
hmm how would i tag them with 0,1,2?
i know i got lots of question i'm sry, i'm new at turing, like i've started from scratch this semester, and is almost due now i;m doing my isu

edit : like i know the basics, cuz thats wat we've learned lol

-----------------------------------
SuperGenius
Thu Jun 03, 2004 5:30 pm


-----------------------------------
you could have an array like this:


var cardstate : array 1..52 of int

for a: 1..52
cardstate(a) :=0
end for


this will get the array set up, and set the values to 0.

-----------------------------------
SpaceDude
Thu Jun 03, 2004 5:37 pm


-----------------------------------
thanks =D
i'll see if i can figure out the rest b4 i ask u guys again, i wanna see if i can figure it out lol
