Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
array in an array?
Author Message
SpaceDude

Posted: Thu Jun 03, 2004 3:06 pm   Post subject: 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

Posted: Thu Jun 03, 2004 3:34 pm   Post subject: (No subject)

making a card game eh? 8)

for this use a 2D array.

 code: var deck : array 1 .. 4, 1 .. 13 of int
SpaceDude

Posted: Thu Jun 03, 2004 3:47 pm   Post subject: (No subject)

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

Posted: Thu Jun 03, 2004 3:58 pm   Post subject: (No subject)

deck shuffle is very simple... well.. if you keep cards in a 1D array (having it as 2D just complicates things)
deck shuffle
Tony's programming blog. DWITE - a programming contest.
Cervantes

Posted: Thu Jun 03, 2004 4:10 pm   Post subject: (No subject)

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
SpaceDude

Posted: Thu Jun 03, 2004 4:14 pm   Post subject: (No subject)

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

Posted: Thu Jun 03, 2004 4:34 pm   Post subject: (No subject)

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

Posted: Thu Jun 03, 2004 4:48 pm   Post subject: (No subject)

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

Posted: Thu Jun 03, 2004 5:30 pm   Post subject: (No subject)

you could have an array like this:

 code: 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

Posted: Thu Jun 03, 2004 5:37 pm   Post subject: (No subject)

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
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 10 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: