Visit the Ironworks Gaming Website Email the Webmaster Graphics Library Rules and Regulations Help Support Ironworks Forum with a Donation to Keep us Online - We rely totally on Donations from members Donation goal Meter

Ironworks Gaming Radio

Ironworks Gaming Forum

Go Back   Ironworks Gaming Forum > Ironworks Gaming Forums > General Discussion

Thread Tools Search this Thread
Old 06-05-2006, 03:43 PM   #1
20th Level Warrior

Join Date: December 28, 2003
Location: Kentucky
Age: 32
Posts: 2,820
...So, I was getting my dork on, making an NPC battle simulator, when it occurred to me that the most efficient method for doing so was to build a nine dimensional array, representing a myriad of stats...problem is, I can't remember crap from my CS 115 class, other than the basics, and the MSDN library is a little on the technical what I really need to know is the following:

1)What's the syntax for storing something to a single element of an array?
2)What's the syntax of a for loop?

I guess that's it for now...if you all know of where I could find that (I'd hate to buy a forty dollar book just for two little things like that!), you'd win my complete admiration and respect!

EDIT: OH, this is in C++ ...might need that!

[ 06-05-2006, 03:47 PM: Message edited by: Ilander ]

Is that what you really want to say?
Ilander is offline   Reply With Quote
Old 06-05-2006, 04:53 PM   #2
Xanathar Thieves Guild

Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 54
Posts: 4,524
I used to know how to program in Basic, will that help???
To those we have lost; May your spirits fly free.
Good Music: Here.
Interesting read, one of my blogs.
robertthebard is offline   Reply With Quote
Old 06-05-2006, 05:08 PM   #3
Jack Burton

Join Date: July 19, 2003
Location: an expat living in France
Age: 32
Posts: 5,577
To place an element into an array you should use:

array [i][j]...[n]=datatoinput
[/QUOTE]where the first [] represents the first dimension, the second the second, etc.

The syntax for a for loop is:

for (commandToExecuteAtStart; exitCondition; commandToExecuteAtEachIteration){}
[/QUOTE]and then you would put the instructions you want to execute inside the {}. Two examples would be:

for (i=0; i<n; i++)
[/QUOTE], which does n iterations
for ( ; ; )
[/QUOTE], which is an infinite for loop.

Hope that helps.
dplax is offline   Reply With Quote
Old 06-05-2006, 06:41 PM   #4

Join Date: October 4, 2001
Location: Canada
Age: 11
Posts: 158
Here's a C/C++ reference page and a tutorial on arrays.
If at first you don't succeed, try, try again. Then quit. There's no point in being a damn fool about it.
W. C. Fields
Knightscape is offline   Reply With Quote
Old 06-06-2006, 06:54 AM   #5

Join Date: October 2, 2001
Location: Aberdeen, Scotland
Age: 36
Posts: 4,774
A nine dimensional array? That sounds wrong. If your doing what I think your doing, you want a one dimensional array of data structures, where the struct contains everything you need to know about one NPC. If you know any STL, use a std::vector instead of an array, its more efficient, but if you dont know STL but do know how to use an array safely, go ahead with an array.
andrewas is offline   Reply With Quote
Old 06-06-2006, 07:11 AM   #6
20th Level Warrior

Join Date: December 28, 2003
Location: Kentucky
Age: 32
Posts: 2,820
...Have not seen data structures...that's the first topic in CS 215, which I intend to take next spring.

I was going to have a nine dimensional array that represented each stat of each allegiance stat, unit number, HP, strike bonus, Attacks Per Round, damage dealt, initiative, and a stat that qualified the NPC as dead.

I didn't know how to make an array of varying types (it would be nice to have one that had boolean values as well as integers!), my program is going to have lots of loops...lots and lots...and yeah, it seems my list is only eight long...I don't have my laptop up and running, otherwise I'd go ahead and write down exactly what they are.

...In my first post, I meant how to I store a value to an element in an array.

Say, I want the fifth element in an eight dimensional array to be four. How do I do that?

[ 06-06-2006, 07:30 AM: Message edited by: Ilander ]

Is that what you really want to say?
Ilander is offline   Reply With Quote
Old 06-06-2006, 08:31 AM   #7
Dungeon Master

Join Date: July 27, 2005
Posts: 52
I don't think the latest question suffice for an eight dimensional array.
arra[a][b][c][d][e][f][g][h] = value
// Wich of these arrays do you want to change element 4 in?
[/QUOTE]If you want to store data for n ammount of bots, a much easier way is to store a structure or an object described by a bot class in each element. You could get something like this:
myBotArray[botIdentificator].Health = 100
myBotArray[botIdentificator].IsDead = false
Drakilor is offline   Reply With Quote
Old 06-06-2006, 04:15 PM   #8
20th Level Warrior

Join Date: December 28, 2003
Location: Kentucky
Age: 32
Posts: 2,820
Looks worth looking up how to do, as it's exactly what I had wanted to do.

Is that what you really want to say?
Ilander is offline   Reply With Quote
Old 06-06-2006, 07:19 PM   #9

Join Date: January 10, 2002
Location: Upstate NY
Age: 50
Posts: 2,109
I've been programming for a LONG time (22+ years)... and I don't recall everr using more than a 3d array, and I can probably count the number of those on one hand.

I think you need to think about your architecture some... something doesn't sound right to me.

[ 06-06-2006, 07:20 PM: Message edited by: Thoran ]
Thoran is offline   Reply With Quote
Old 06-06-2006, 07:57 PM   #10
40th Level Warrior

Join Date: October 29, 2001
Location: Western Wilds of Michigan
Posts: 11,752
I'll agree with Thoran... rethink your design. A nine-dimension array violates quite a few basic concepts of database design. In fact, from a true database perspective, you'd have something like...

... a character record with a key and description
... a stats table keyed off the character and stat type and containing the stat value

You'd look up the character, then the stats. If you wanted, the stats record would just have columns for each stat so you could retrieve it once.
Save Early, Save Often Save Before, Save After
Two-Star General, Spelling Soldiers
Give 'em a hug one more time. It might be the last.
Bungleau is offline   Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programmers/Developers SilentThief Dungeon Craft - RPG Game Maker 20 06-24-2007 03:34 AM
OTS: Hackers and Programmers Please help Loumistro Wizards & Warriors Forum 4 01-20-2004 12:25 PM
Any Fellow Programmers might enjoy this harleyquinn General Conversation Archives (11/2000 - 01/2005) 15 02-07-2003 10:22 AM

All times are GMT -4. The time now is 08:13 AM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
©2017 Ironworks Gaming TM & The Great Escape Studios - All Rights Reserved