Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / [DB Classic] A Question about Arrays: Why only 5D?

Author
Message
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 15th Jun 2006 03:22
Why only 5 coordinates?
Any way to increase the number?

Example:
DIM ArrayName(#,#,#,#,#,#,#,#,#,#,#)

When I dream,
I carry a sword in one hand,
a gun in the other...
Tobo
19
Years of Service
User Offline
Joined: 12th May 2005
Location:
Posted: 15th Jun 2006 07:53
Is there a specific use you require more than 5 for, or is it just a general question?

Bigger the array, more memory it requires.

An array more than 5 deep is massive! What did you have in mind?

T.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 15th Jun 2006 10:12
If you need more than 5, you probably do not use them properly. For example, an alphabet is not 26 coordinates it is just 1 coordinate holding 26 members.

Dim Alphabet(26)

Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 15th Jun 2006 15:42
You probably just need a one-dimentional array of a user defined type.



Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 15th Jun 2006 17:07
Wouldnt it just take up a unnessesary amount of memory? If you want a massive array, you can use all five dimentions, and a bunch of types (Crits idea in a modified version):


That array would be able to hold an massive amount of data.
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 15th Jun 2006 17:51
This is the first time I've heard of this 'type' command.

What is 'Type' and how does 'as t' effect the array?

And yes I do need more then a 5-dimensional array for what I'm doing...
Mwa Ha Ha Ha!!!!

When I dream,
I carry a sword in one hand,
a gun in the other...
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 15th Jun 2006 20:46
You need DBP for types.

Using Mr X's example, you could then address
array(1,20,14,9,20).mytype

I.e. each member of the array now has three components .mytype (an integer), .mytypeagain (a string) and finally mytypeathirdtime (a float). You now have eight dimensions.

And what on earth are you using this for?

Assuming a 5D array, with a length of 5 on each side, you can store 3125 numbers. With a length of 10, this becomes 100,000 (hundred thousand, or silly american million [sorry, couldn't resist!]). That is a lot of values. Sounds like bad data management if you need more than that.
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 15th Jun 2006 23:19 Edited at: 15th Jun 2006 23:23
I will try to explain types, even if I dont really know how. With types you can add your own dimentions, and name them as you wish. If you have a 2d game where you have two players that move around, you can put all the info you need in an array using types. Since you have two players, you dim the array, lets call it player, so it contains one coordinate with two members. Then you add the x and y coordinate with types.
. Now we have an array that have two members, one for each player, and user defined types which contains the x and y coordinates of the players. So with types you can add dimentions to an array, or an ordinary variable if you so like, and there is no limit. So if you want as many dimentions as you say you do, types is the answer. Goodluck.

EDIT:

To use the types, just add a "." and one of the names of the members of the type. In our case:
Slayer93
20
Years of Service
User Offline
Joined: 5th Aug 2004
Location: I wish I knew
Posted: 16th Jun 2006 05:03 Edited at: 16th Jun 2006 05:03
look at these newsletter tutorial for information on types
http://www.thegamecreators.com/data/newsletter/newsletter_issue_28.html#9
and
http://www.thegamecreators.com/data/newsletter/newsletter_issue_29.html#9

Your signature has been erased by a mod because it's larger than 600x120...
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Jun 2006 11:33
Wahey, somebody referred back to the newsletter tutorials!



Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 17th Jun 2006 00:58
Quote: "If you need more than 5, you probably do not use them properly."

Properly, an interesting word...
Is there a specific purpose defined to the use of arrays?
And if there is, is it not my 'duty' to find another use for it?

Quote: "Bigger the array, more memory it requires."

How badly is a large set of arrays going to slow down a program?
Lets say (10,10,10,10,10) as an example.
What kind of memory hit am I looking at here?
And what kind of hit would come off, say ten arrays all (10,10,10,10,10)?
(The answer to this question could drastically effect my current/future projects.)
What method should I use to calculate the memory use of the arrays I'm using?

Quote: "You need DBP for types."

My currant project is DBC... and I can't port it to DBP at the moment. (Ack, need to replace some faulty hardware... ) So no 'types' for me this time, but I'll keep them in mind for my next project... yes this should work nicely if I understand it correctly...

Quote: "look at these newsletter tutorial for information on types"

Interesting! Ack, I need to spend sometime catching up on the newsletters. Thanks for the link.

Quote: "An array more than 5 deep is massive! What did you have in mind?"

This will remain shrouded in mystery for the moment, best not to look behind the curtain.

Quote: "And what on earth are you using this for?"

Mwa ha ha! I'll post something when it's ready...

I'm still learning all the commands, but I have ‘dreams’ that I must fulfill. So I try and aim as big as my current level of understanding can take me, plan it all out on paper so I know that 'in theory' the program can be written... and then...

Hopefully the results will be a pleasant gaming experience…


"O God, I could be bounded in a nut-shell and count myself a king of infinite space, were it not that I have bad dreams."
-Shakespeare, Hamlet


“…Four centuries have passed since those words were written. We have begun to penetrate infinite space, bounded in our little nut shell space craft. But we still have our bad dreams.

I can sense, them coming across the midnight of space, can read the cryptic circuitry of their ship, decipher all the codes of fear in the hearts of it's crew of three. I wish I could tell them that all will be well, the future after all is not so terrible.

But that is not my nature. They’re very near now...

I know each name, each individual pain. Karne, Matlock, Kenzo. Three are coming, only two will leave. The bad dreams will always be with us, and now and again… dreams come true.”
- Martian Gothic: Unification


When I dream,
I carry a sword in one hand,
a gun in the other...
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 18th Jun 2006 10:12
Quote: "How badly is a large set of arrays going to slow down a program?
Lets say (10,10,10,10,10) as an example.
What kind of memory hit am I looking at here?
And what kind of hit would come off, say ten arrays all (10,10,10,10,10)?
(The answer to this question could drastically effect my current/future projects.)
What method should I use to calculate the memory use of the arrays I'm using? "


(BUMP)

I could really use answer to this one before I get buried in code that may or may not be memory efficient.

When I dream,
I carry a sword in one hand,
a gun in the other...
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 19th Jun 2006 00:19
Well, assuming it is an array of integers, each element takes 4 bytes of memory. 10x10x10x10x10x4 = 400000 bytes = 390Kb

Any computer will easily handle that array. But are you sure you don't just need 5 one-dimentional arrays?



Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 19th Jun 2006 20:58
Quote: "But are you sure you don't just need 5 one-dimensional arrays?"

Almost positive. Although, I could use a several sets of 1D arrays. Wouldn't it add up to the same amount in the end since I need to fill up all the coordinate with values anyway?

If I switch to several 1D arrays I'll have to recode a lot of my program at this point.


So (10,10,10,10,10) = 400,000 bytes,
and (10) = 40 bytes.

And that’s with them all storing 0 as there coordinate values?

So memories not a problem unless I've got a few hundred (10,10,10,10,10) arrays?

Excellent, then my code is still workable.

When I dream,
I carry a sword in one hand,
a gun in the other...
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 19th Jun 2006 22:38
OK, here is my last attemt to figure out if you need a 5-D array.
If your code looks like this, then you need 5-D:


if it looks like this, then you are wasting tons of memory


Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Jun 2006 01:01
A Chess board is this....

Dim ChessBoard(8,8)

8*8

I don't use zero but you can also do this

Dim ChessBoard(7,7)

and use 0 as the 8th.

So are you sure that you need 40000+?

Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 20th Jun 2006 07:12
I do not understand what you are doing with this code:


A series of loops that will each run ten times? (If I understand the "for 'X' to 'Y' next" commands) but what does it do???

Nor do I understand this one:


I see, I think, some kind of loop that will run 10 times... but I'm not sure what it does?


(Sorry, still learning. )

Alright... here comes the big question of doom!!!
I can use several (10,10,10,10,10) arrays and, even if there is a better way, the memory hit won't kill the program. (I hope... )

But, what if, the array was of this size: (10,10,10,70,52)
And... I may have to use more than one array of this size.
So... how much of a hit is this monster going to take out of the RAM?

Maybe I could only load them when I needed them somehow...
(Swap one out, swap one in?)

When I dream,
I carry a sword in one hand,
a gun in the other...
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Jun 2006 10:01
Why don't you just tell us what the array is for. I mean, how can an array be a secret?

Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 20th Jun 2006 11:05

Quoted from Crit!

Wandering Swordsman: The above code is a way to fill in each of the 100,000 values in a 5D array with a number. You will need to do something similar to reference the array. The other code is actually faulty (not the code itself, but the reasoning) - it is as if someone were using a 5D array as a 1D array by mistake (i.e. only using 10 values, because they are increasing all of the array indices at the same time) - Crit was trying to check how you would be referencing the array, and therefore whether you are mistaken by the size that you need.

Phew - sorry for long explanation. As Pincho says though, give us a little more detail - I'm sure that if you have come up with a secret new way of using arrays that will revolutionise computing, we'll still let you claim patent! In the mean time, we may be able to help correct or focus your thinking if you are wrong, or help you with details if you are sure that you need the 5D.

And by the way: memory size of a (10,10,10,70,52) array=
10*10*10*70*52 (number of indices) * 4bytes =
(3,640,000)*4b = 14,560,000b = (/1024 for Kb) = 14,219Kb (/1024 for Mb)=13.9Mb

You are using 14 Meg of memory for an array????

I really hope that the info you are holding is worthwhile!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Jun 2006 13:54 Edited at: 20th Jun 2006 13:55
An alternative explanation, which may help you.

For a chess board, you need a 2 dimensional array, 8*8 in size:

Dim Board(8,8)

That gives you 64 squares, as expected.
But what if you wanted two teams of 8 players? You might use 2 arrays:

Dim Team1(8)
Dim Team2(8)


How is this different? 2 arrays of 8 elements each is just 16 elements, or 25% of the chessboard solution.
Maybe the second solution is more appropriate for you?


* Element 0 has been ignored for clarity



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Jun 2006 14:00 Edited at: 20th Jun 2006 14:00
Now, on to types. I realise you don't have this option right now, but maybe DB Pro is more suited to your project.



With a type, you can add the equivalent of extra dimensions. But they can all be different data types for starters, which is a more flexible solution. Secondly, you can use dynamic arrays, which gives you scalability. So if one user creates a scenario needing 10 players, you create just 10 players. For a power user creating 10,000 players (on a higher spec PC ), you create 10,000 players. There is no memory wastage for the smaller game. You can also add and remove players from the game as necessary.



Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 20th Jun 2006 21:08 Edited at: 20th Jun 2006 21:17
Pincho Paxton:
Quote: "Why don't you just tell us what the array is for. I mean, how can an array be a secret?"

Isn't that the secret in it's self?

Dream And Death:
Quote: "You will need to do something similar to reference the array."

What is the meaning of the term 'reference the array'?
(Still learning the terminology. Thanks for explaining the code snippet.)

Dream And Death:
Quote: "As Pincho says though, give us a little more detail - I'm sure that if you have come up with a secret new way of using arrays that will revolutionise computing, we'll still let you claim patent!"

Lol, I'm not naive enough to think I've figured out some grand new thing. It's probably been done before. (If what I'm doing works that is.)

Dream And Death:
Quote: "In the mean time, we may be able to help correct or focus your thinking if you are wrong, or help you with details if you are sure that you need the 5D."

Hmmm... well, it could save 'us' a lot of work. The project I'm working on is simple, but massive. And I'm not working on it alone, I'll have to ask the other person working on it if I can post a code snippet... and he says yes, but limit it.

Ok, here's a 3D array. The # stands for a number (Not a random number.) between 0 & 35, I haven't included the coordinate values because I don't have the file they're stored in where I can easily copy/paste from it at the moment and I don't feel like rewriting 300 variables from the design notes.


The arrays we're working with are 'MUCH' bigger, but I thought a 3D array would help give an idea. Is this the correct use?

Dream And Death:
Quote: "You are using 14 Meg of memory for an array????"

Hmmm, 14 Megs... That's a lot... Ok, if I delete loaded images do I reclaim the ram they previously took up? (That way I can cycle the images in and out...) The images have nothing to do with the array, I'm just trying to make sure I have enough ram. I'd like to keep it below 256MB of ram for compatibility sake if I can.


Quote: "I really hope that the info you are holding is worthwhile! "

If it works, it will be.


BatVink, Thanks for the examples. I think I understand the chessboard array you described. Unfortunately, my programming terminology is still incomplete, Could you clarify the following terms for me please: 'dynamic arrays' 'power user'.

DBP with it’s ‘type’ command will definitely be something I look into using when it becomes an option again. (Faulty graphics card, had to swap back to a strong but older card… DX9 is currently out of my reach. )


My understanding of DarkBASIC is simple at the moment, the project undertaken is ambitious.

We’re trying to make something big, using the commands we know so far. (It all seems to work in the design notes though) Myself doing most of the programming where as the yet ‘unnamed’ (Don’t know if he wants his name mentioned, so I’ll omit it for now.) other person who is working with me is doing the art.

We’ll probably be releasing several smaller projects while we work on this one. It’s big, and entering all the data from the design notes is time consuming.

When I dream,
I carry a sword in one hand,
a gun in the other...
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 20th Jun 2006 21:41
The term 'referencing' means comes from using something as a reference. If you've ever read a magazine or book etc. where another article is quoted, that is a 'reference'. The other article holds much more information, so only a part is referenced.

So an array holds a lot of information, but you only ever 'reference' a small part of it. Each line of your code snippet above is a reference to your array e.g. MysteriousExampleArray(1,10,3) = #

It does look like you are referencing your array properly, we are just wondereng if you are using it for a valid purpose. For example, if you were going to use a massive 3D array to store all the x,y,zs of every model in your game, we might point out that you could just return OBJECT POSITION X(#) when you needed to.

Yes, using DELETE OBJECT will free up memory, but be careful when you use it. If you find yourself re-loading later, you'll slow your program/game down.

If you don't want to tell us any more, that is fine, we are just trying to help you!
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 20th Jun 2006 22:21
So.... you mentioned that your array will be this size: (10,10,10,70,52)

If you plan on coding it the same way you posted above, your program will be well over 3 MILLION lines long! My bet is it wouldn't even compile at that point. I suggest you find another way.

Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 20th Jun 2006 22:51
Thanks for explaining 'reference'.

Objects are occupying every one of the coordinates. It's not so much a question of where an object is, as to what object is currently at the coordinate set. (Does that make any sense?)

The program in question is 2D.
Would *Thumbs through his DBC manual...* 'Delete Sprite' & 'Delete Image' reclaim the memory taken by the image files?

Dream And Death:
Quote: "If you don't want to tell us any more, that is fine, we are just trying to help you! "

It's not that we're worried about anyone taking our code or technique (Technique, lol... still learning. ) It's more that if too much of a program is understood, it isn't as fun to play.

The feedback on this thread has been very helpful and is appreciate.

When I dream,
I carry a sword in one hand,
a gun in the other...
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 20th Jun 2006 22:52 Edited at: 20th Jun 2006 22:55
Crit:
Quote: "My bet is it wouldn't even compile at that point. I suggest you find another way."

*Panics* What? Why not?! Is there a line limit?

Won't it just take a really long time to compile?
(And I'm using more then one (10,10,10,70,51) if it's still possible.)

When I dream,
I carry a sword in one hand,
a gun in the other...
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 21st Jun 2006 00:18
A better way for you to do this is maybe make a dummy program, which will fill in the initial (i.e. starting) values of the array. Then use SAVE ARRAY to save it and its structure to a file.

In your main program you then DIM your array and then LOAD ARRAY.

Saves lots of lines (and time!) setting up your array line by line in your main program.
Slayer93
20
Years of Service
User Offline
Joined: 5th Aug 2004
Location: I wish I knew
Posted: 21st Jun 2006 00:50
If your just using numbers you can use a memblock

Your signature has been erased by a mod because it's larger than 600x120...
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 21st Jun 2006 00:53
Isn't 'Save Array' & 'Load Array' DBP only?

Hmmm. But perhaps, I can store the arrays in some form of data file separately from the program if it won't compile with them within it?

(Will it really not compile if it gets that big?)

When I dream,
I carry a sword in one hand,
a gun in the other...
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 21st Jun 2006 00:55
Slayer93:
Quote: "If your just using numbers you can use a memblock"

I do have DarkMATTER, but I haven't learned the memblock commands yet. Are they tricky to use?

When I dream,
I carry a sword in one hand,
a gun in the other...
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 21st Jun 2006 01:23
Sorry Wandering Swordsman, I only have DBP installed now - I thought off the top of my head that LOAD ARRAY and SAVE ARRAY were in there.

The idea of using data files is a very intelligent thought - this is what commercial games do - they load info from encrypted files, usually at the start of a level.
Slayer93
20
Years of Service
User Offline
Joined: 5th Aug 2004
Location: I wish I knew
Posted: 21st Jun 2006 03:29
memblocks are not hard to use when u know how to use them

Your signature has been erased by a mod because it's larger than 600x120...
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 25th Jun 2006 16:03
Quote: "The arrays we're working with are 'MUCH' bigger, but I thought a 3D array would help give an idea. Is this the correct use?"


I would suggest that you use FOR-NEXT loops.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Jun 2006 06:30
Though I doubt there's anything specifically wrong with the way you're counting the index in the array, it feels very backwards to me.



"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Jun 2006 11:21
Quote: "BatVink, Thanks for the examples. I think I understand the chessboard array you described. Unfortunately, my programming terminology is still incomplete, Could you clarify the following terms for me please: 'dynamic arrays' 'power user'."


A dynamic array is one that can shrink and grow as you need more array elements. For example, you might start with just one array element, and by the end of the game have 10,000 elements. In between, it can shrink and grow as the game dictates.

By Power User, take Civilisation as an example. One player may want to use a small world of 1,000 tiles, another may have a world of 1,000,000 tiles. Dynamic arrays allow you to create both games using the same logic.



Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 26th Jun 2006 15:36
Hello. I've been reading this, and trying to glean little pieces of what you're attempting to do. My understanding at the moment is that you think you want an array of (10,10,10,70,52).

This one line, coupled with your comment that # stands for a number between 0 and 35, and that you don't want to enter the coordinates from the file, confuses me somewhat. (I'm trying to figure out what you're trying to achieve, you see.)

Now, if each of those array entries is supposed to correspond to a coordinate (0-35) then you've got 1000 entries that correspond to a single number (0-35).

The only thing I can think of thats even similar, would be having 10 entities, with an X, Y and Z coordinate (from 0 to 35) and that would use a very different structure:
EntityXYZarray(10,2)

For example:


If I wanted 1000 entities, with an X,Y and Z coordinate, I could do this:
EntityXYZarray(1000,2)

So you see, I'm quite confused as why you might have 10 entities, of types 0 to 10, of completely different types 0 to 10, that correspond to a 'coordinate' from 0 to 35.

As for the extra array dimensions, it could be that you're trying to stash information in there about an entity - for example it's Size, or it's Attack-Value, or even its RGB values (I don't know).

Even so - 70 and 52 are not numbers that should feature in this system.

For example, I have 10 spaceships in a universe of coordinates 35*35*35. Each ship has a size (1-10) a speed (1-10) and a rank (1-5).

I would create the following:


So, as you can imagine from the above example, I can get a LOT of information in about those ships - if I wanted to add more information like Accelleration, Attack, Defence, Cost, RadarRange, WeaponType, CargoSpace etc etc, then each one would only require an extra element in my second dimension - not an extra dimension itself.

So I admit it - I'm flummoxed. Please, why do you need so many dimensions? There's nothing I can imagine (short of the DNA of the planet) that would require so many elements and so many dimensions.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Jun 2006 16:23
Well, Tinker me ol' gal, you've made it further than the rest of us...have a of

and a carrot



Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 26th Jun 2006 18:38
Ta, Batvink - that's at least two portions of my five-a-day sorted right there

X Trade
20
Years of Service
User Offline
Joined: 19th Feb 2004
Location: near bristol, UK
Posted: 26th Jun 2006 20:53
Quote: "Objects are occupying every one of the coordinates. It's not so much a question of where an object is, as to what object is currently at the coordinate set."


if you are trying to do that, then you could do it much simpler. example:


reading what you said, i don't think you understand for-next loops either.
These can be extremely useful, espciecally when it comes to arrays.
the for-next loop will increment each time it passes the 'next' command, and will start at the first number in the 'for' command.
when it reaches 'next' and the number is equal to the last number in the 'for' command, then it will exit the loop, thus you can limit the number of times the loop runs
the real use of this, though, is that you can find out what stage it is in, buy using the value that you specify in the 'for' command - so if you say 'for i = ', then you can use i as a variable. you can also change it, which could potentially really upset the loop.

before i discovered for-next loops, i used to use (in QBasic),
example:

im sure you get the idea..

now, if you think of what you *may* have just learnt, then it is easy now to enter the data from obejcts into an array,
example:

that code will fill the first 10 indexes of the array with the positions of objects 1 to 10


i really think you would get better help and attention if you would tell peopel what it is you are doing.. no-one can really help you if you leave them guessing.. to see how you are using the array can be useful


also, a note:
i think you get DarkEDIT on the DB disk.. if you use this, as far as i remember, it has support for types (by converting them into multi-dimensional arrays before it sends the code to be compiled)
and the editor is much better than the default DB IDE

www.AoFP.co.uk
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 29th Jun 2006 09:31 Edited at: 29th Jun 2006 09:35
After heavy debate, authorization has been given to disclose more of our project. But first, it seems polite that I respond to what’s been said thus far.


Slayer93:
Quote: "memblocks are not hard to use when u know how to use them"

I don't know how to use them at the moment, But I'll look into learning them.

Mr X:
Quote: "I would suggest that you use FOR-NEXT loops."

What would FOR-NEXT loops do to the array? The way I'm using it the data only needs enter the array once, and does not need to change. Not constantly anyway. As I said "Objects are occupying every one of the coordinates." it just a matter of determining what is where. These objects are mostly static.

Phaelax:
Quote: "Though I doubt there's anything specifically wrong with the way you're counting the index in the array, it feels very backwards to me."

What do the different dimensions of your array represent?


@BatVink,
Thanks for clarifying those terms.

Tinkergirl:
Quote: "MysteriousExampleArray(1,1,1) = # "

Quote: "This one line, coupled with your comment that # stands for a number between 0 and 35, and that you don't want to enter the coordinates from the file, confuses me somewhat. (I'm trying to figure out what you're trying to achieve, you see.)"

Alright, this is an error in my wording. I quickly typed up an example array in notepad. I did not want to type in all the different array coordinate values from my design note file for the example so I limited it to three dimensions and used # as a variable with a value ranging from 0 to 35.

Tinkergirl:
Quote: "EntityXYZarray(10,2)

"

*opens the code snippet.*
Interesting way of doing things, I'll remember it. (Thanks)

Tinkergirl:
Quote: "So you see, I'm quite confused as why you might have 10 entities,"

I'm not completely understanding the term: entities.

Tinkergirl:
Quote: "So, as you can imagine from the above example, I can get a LOT of information in about those ships - if I wanted to add more information like Accelleration, Attack, Defence, Cost, RadarRange, WeaponType, CargoSpace etc etc, then each one would only require an extra element in my second dimension - not an extra dimension itself."

Thanks, that’s very efficient I'll use that to store some of the game data. But it won't help with the (10,10,10,70,52) 5D array.

Tinkergirl:
Quote: "So I admit it - I'm flummoxed. Please, why do you need so many dimensions? There's nothing I can imagine (short of the DNA of the planet) that would require so many elements and so many dimensions."

'DNA of the planet', that gives me an idea. Can I have permission to use those words for inspiration? And, I'll elaborate on the use of the 5D array at the bottom of this post.

X Trade:
Quote: "if you are trying to do that, then you could do it much simpler. example:

"

I don't completely understand your code snippet, what are the bracketed 'i' doing after each variable? (I know 'i' is a variable for the for-next loop command.)

X Trade:
Quote: "reading what you said, i don't think you understand for-next loops either."

I have read of them, seen them in action. But, I do not know of a particular use for them as yet.

X Trade:
Quote: "you can also change it, which could potentially really upset the loop."

What exactly do you mean by 'upset the loop', could I potential increase the amount of times the loop would run through? Or crash the program by giving a higher value to the first number?

X Trade:
Quote: "then it is easy now to enter the data from obejcts into an array,"

Ah! I think I see the confusion. I'm entering data from paper notes and design note files. (One's I've written up by hand.) I have to get all the data out of these notes and into the source code's array before they can be manipulated. (This is not a problem, just time consuming.)

X Trade:
Quote: "i think you get DarkEDIT on the DB disk.. if you use this, as far as i remember, it has support for types (by converting them into multi-dimensional arrays before it sends the code to be compiled)"

Eh? where can I find information on how to use DarkEDIT in this manner?
(I've been using DarkEDIT for a while now, great program.)

X Trade:
Quote: "i really think you would get better help and attention if you would tell peopel what it is you are doing.. no-one can really help you if you leave them guessing.. to see how you are using the array can be useful "

Yes, true. And here comes more information about the massive system of arrays I'm working with:


Alright, I'm still going to be a bit vague.
The one word that will probably clue everyone one in is 'Overworld'.

For the moment, forget about 3-5 dimensions of the array. (There still there, fraught with mystery.) as Pincho Paxton mentioned, in vision a chess board. A Chess(10,10) array, (Or possibly a 1D Chess(100) array) although you could store the type of chess piece found in each coordinate. Or you could store information on the coordinate itself instead, defining something about that chess square by a variable who's value corresponds to different types of something. The later is what I am attempting, on a massive scale.

I hope that adds some clarity. (Hmmm, I’ve managed to give more information without divulging the core of the project. )


Now as for the remaining 3 dimensions... that gets complicated, and I am forbidden to speak of them at this time. (Do not argue with your projects VG artist. Artists make everything pretty and hold back the scourge that is 'programmer art'... my own stick figures scare even me! )

If I'm completely in the dark on something please continue to point me in the right direction, all the comments in this thread have helped immensely.


Oh, and will having giant arrays actually prevent DBC from compiling? If so, how big before this happens? And why does it prevent it?


I've been busy with the 'Text Adventure Competition' so I've been slightly side tracked from the project that uses the 5D array, it still slowly moves along towards it's conclusion though.

When I dream,
I carry a sword in one hand,
a gun in the other...
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 29th Jun 2006 10:44 Edited at: 29th Jun 2006 10:47
What you have written there without explaining the reason for the other dimensions sounds like a 3 dimensional array.

Dim Map(X,Y,Different_types_of_something)

So you see why we are confused.

Also, being as you do not know how For/Next loops work, and you do not understand Array(i) what the (i) does. Then it is likely that you are confused about the Dimensions.

Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 29th Jun 2006 16:29
Wandering Swordsman, you have to help us help you. Being so secretive is just wasting your time and ours.

This is all you can divulge after heavy debate?
Quote: "Or you could store information on the coordinate itself instead, defining something about that chess square by a variable who's value corresponds to different types of something.
"


Do me a favor: Take a look at your design notes, and count the number of values that you need to track. I'm going to assume the number you come up with will fall way short of 3,640,000. But that is the number of values that a (10,10,10,70,52) array handles. So to clarify, if you don't need to keep track of 3,640,000 seperate variables, then you DON'T need a 5D (10,10,10,70,52) array. And if you don't tell us what you are trying to do then we WON'T be able to help! Throw us a bone here. No fewer than 10 people are selflessly trying to help you out, but you're not making it easy.

X Trade
20
Years of Service
User Offline
Joined: 19th Feb 2004
Location: near bristol, UK
Posted: 29th Jun 2006 18:29 Edited at: 29th Jun 2006 18:30
Quote: "X Trade:

Quote: "if you are trying to do that, then you could do it much simpler. example:
+ Code Snippet
numberofobjects = 10

rem set the current position
x=10
y=5
z=2
for i = 1 to numberofobjects
if object position x(i)=x and object position y(i)=y and object position z(i)=z then result = i
next i
position object result, blah, blah, blah etc
"
I don't completely understand your code snippet, what are the bracketed 'i' doing after each variable? (I know 'i' is a variable for the for-next loop command.)"


try this code, then you will understand more:

that shows simply how you can use the for-next value in your loop usefully

similarly. the (i) is not after a variable in the code snippet you asked about.. it is after a function - the 'object position x' (and the y and z varieties) function. this means that:
'a = object position x(1)', will put the x co-ordinate of object 1 into the variable a. simiarly, you could do the following:

as opposed to:

so similarly you could do something with arrays.


I think the main point people are thinking about here, is that, if you want to store 50 different properties of a point in 3d space, try something like:

instead of



i imageine DBC would run VERY slowly with large arrays..

www.AoFP.co.uk
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 29th Jun 2006 23:21
*polite nod to Pincho, Crit and X Trade*
*rolls up sleeves*

Ok, let's do this.

Quote: "I'm not completely understanding the term: entities."

An entity is just a word for an object or thing - for example, a spaceship might be an entity, a goblin might be an entity - you are an entity! It's just a word I use when if I say 'object', people might get confused with the graphics, instead of the information.

Quote: "'DNA of the planet', that gives me an idea. Can I have permission to use those words for inspiration?"

Of course, feel free. Ideas are cheap.

As for the word "Overworld" you couldn't have been less helpful. According to Wikipedia, Overworld is the travel space between levels in (traditionally) an RPG, it is also the music that accompanies it. It's also a book (soon to be a film) about spies. So yes - very useless, thanks. It's certainly not...
Quote: "The one word that will probably clue everyone one in"


Ok now, I'm going create an example here - it's going to be based on the one I did above, (the spaceships).



This very heavily documented code snippet, I hope, will help to explain how you would use a multidimentional array to store object positions in the world, and (along with the other examples given by other forum users) help explain FOR-NEXT loops and what the (i) means.

Now, I'm going to let my head explode, and try to imagine a crazy situation where I'd need a >2 dimensional array. Hmm. *sound of head exploding* Ok, here we go. If I wanted to instead of defining the spaceships, if I wanted to define (ie. describe) the universe that held them. Say I had a 100*100*100 universe, and each one of those grid points could have up to 5 Red monsters, 5 Green monsters and 5 Blue monsters.

DIM UniverseWithMonsters (100,100,100,5,5,5)

Now, how I'd use that would be that if I wanted to write down the object number for the second green monster at grid coordinate 35,2,16, I'd do...

UniverseWithMonsters (35,2,15,0,2,0) = 205 'The object number

THIS IS THE WRONG WAY TO DO THIS. Just so you know. If I were to find myself writing this as code, I'd be tempted to slap myself silly. This is so wrong, it's unfunny.

If I were trying to describe a universe, with red and green monsters in it, I would be better to have THREE arrays:

DIM RedMonsters(NumOfRedMonsters,3)
DIM GreenMonsters(NumOfGreenMonsters,3)
DIM BlueMonsters(NumOfBlueMonsters,3)

Three, because I'd put an X,Y,Z value and an Object Number as the other element (array bit).

You could even do it in ONE monster array.

DIM Monsters(TotalNumOfMonsters,4)

That'd be X,Y,Z, Object Number and the last number would be 1,2 or 3 depending on if it was a Red, Green or Blue monster. With these arrays, there's no wasted space - if you define the universe as 100*100*100, and there's 400 monsters, then there'd be a minimum of 999,699 empty universe spaces - being wasted and taking up valuable memory.

Finally, I wonder what kind of a game you have where you're inputing numbers straight into code for your coordinates from your design document. This is just generally bad practice and I'm sure you're finding it a pain in the backside. Think about writing the numbers in a text file instead, and then having your code read the text file and put the numbers in itself - it means that you can change the data easier if you have to later, (because a textfile is easier to change than code) and it also means your code will be less bulky, and your game easier to expand.

Failing this - if my help has missed the mark again, then consider maybe asking for private help from someone here on the forum you trust. If you really really can't bear to reveal your 'great secret', despite NEEDING OUR HELP, then maybe there's someone you can email and whom you trust enough not to spill your beans. *shrugs* The very best of luck, to you, your artist and your 5D array

Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 30th Jun 2006 11:03 Edited at: 30th Jun 2006 11:07
Pincho Paxton:
Quote: "Also, being as you do not know how For/Next loops work, and you do not understand Array(i) what the (i) does. Then it is likely that you are confused about the Dimensions."

I really need to master these For/Next loops. I'll make it a priority.

Crit:
Quote: "This is all you can divulge after heavy debate?"

Yes. Many points were argued. There are reasons for our secrecy.

Crit:
Quote: "Take a look at your design notes, and count the number of values that you need to track."

3,640,000... *Quickly does some math* Excellent. I need almost all of that, one or two may end up blank but I require them to 'be' blank and there for the rest of the program to function. It's big, but I do have data to occupy all of it. (Save a necessary value of 0 occupying a set of coordinates here and there.)


@X Trade:
Thanks for your For/Next code snippets. So by using the variable of the decaying loop's limiting numbers as part of the math you can make use of the For/Next.

X Trade:
Quote: "I think the main point people are thinking about here, is that, if you want to store 50 different properties of a point in 3d space:
"

The 5D array is storing a single piece of data about a single coordinate/place. Not creature types, player stats, object speeds, etc... Hey, you can store strings/words/‘$’ in arrays? Thanks! You just made part of my job a lot easier. (I’m guessing you can only store words in arrays that have a ‘$’ on the end of the name and that numbers and words are mutually exclusive: Either Numbers(#,#,#) or Words$(#,#,#) but not both.)

@Tinkergirl:
Thanks for explaining 'Entities', and also thank you for the use of the 'DNA of the planet' an idea is forming that I can make use of it in.

I thought the word Overworld really would be a dead give away, I was referring to the first example you listed.

*Reads 'the spaceships' code snippet...* Wow! Thank you!!! I think I finally see the power of using For/Next loops. Instead of designing the program to leave the loop through some means you just build the loop to end when it's task is completed! The heavy documentation really helped, thanks for taking the time.

Example of how I've been doing it without the knowledge of For/Next:



Tinkergirl:
Quote: "THIS IS THE WRONG WAY TO DO THIS."

Don't worry, my creatures are partying up a storm in a different set of arrays then this one. And it's no where near as large (3,640,000 unique creatures made by hand? Keeping the balancing would be a nightmare.)

Thank you for your example, I will keep it in mind.

Tinkergirl:
Quote: "I wonder what kind of a game you have where you're inputing numbers straight into code for your coordinates from your design document."

Some of it is converting concept sketches into numbers. Example "Ah, this picture = 4 the next = 3 then another 4." If it was stored numerically and digitally I'd just dump it from the file into the program.

Tinkergirl:
Quote: "I'm sure you're finding it a pain in the backside"

I am. The data entry is taking awhile... but it's getting there. I’m working on a method to speed up the process. And my more recent notes are in a more ‘port to code’ friendly format.

Tinkergirl:
Quote: "because a textfile is easier to change than code) and it also means your code will be less bulky, and your game easier to expand."

I see what you mean, as it is I'm writing the engine and the data in two different files. I'm going to copy the contents of one into the other when I'm ready to compile it. It would be much easier to load from a file (Or set of files) if I wanted to edit the data but not the engine. Expand the game data beyond it's original state, the idea had not occurred to me. Storing the data in separate files would definitely make it possible.

Tinkergirl:
Quote: "then consider maybe asking for private help from someone here on the forum you trust."

I haven't been part of this community for very long so there isn't anyone on this board I trust enough to show the design notes. (No offence intended.) I don't know anyone here well enough yet.

Crit:
Quote: "Wandering Swordsman, you have to help us help you. Being so secretive is just wasting your time and ours."

Very well, I'll ask very specific questions then.

Alright, forget for the moment about deciding whether or not I need a (10,10,10,70,52) array. Or what the 3-5D of the array are.

For arguments sake just pretend the array has to be that way:

- Can it be that way?

- Will a DBC program run with an array of this size loaded?

- Will a DBC program run with more than one array of this size loaded?

- Crit mentioned that a very large program probably won't compile in DBC. Why not? And how large? (Is this dependant on the RAM of the computer compiling it?)

- X Trade mentioned a severe speed hit, how heavy a hit will it be?
(And will this be a constant speed loss, or only when certain things/commands are happening?)

- Can the speed hit be remedied via large amounts of RAM or a good CPU?

- X Trade mentioned using DarkEDIT to create Types in DBC, two questions. Will this allow greater then 5D arrays and where can I get information on how to do this in DarkEDIT?



My understanding of DB is growing. This program uses mostly simple math, though the data the math manipulates is very large in quantity. The project is ambitious and is taking a fair chunk of my time to code and the project's Artist's time to draw all the images needed. It would be nice to know if when it's all done in the source code and I click that wonderful Build Final .exe button. That it won't just freeze/crash/etc during the compiling phase.

As it stands, I've probably already said too much about the 5D array I'm working with. (Wish I could push it up to 6D in DBC... 7D would be even better...)

I'm pretty far along with the code as is. I'm not sure I’d want to port it to DBP (With my DX9 Graphics card busted it's not really an option ) Still, future projects may be very interesting if I can use arrays at 7D or even 9D! (That would allow some pretty cool features if what I'm doing works...)

The fact that no one has figured out what I'm doing worries me, (I may be doing something crazy that doesn't work.) but it also fills me with the hope that I may have stumbled onto something.

If you can dream it, you can build it...

All your suggestions, criticisms, examples and comments in this thread have been helping me make large jumps in my understanding of the DB language. This is really helping me thanks!

When I dream,
I carry a sword in one hand,
a gun in the other...
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Jun 2006 11:39
In any type of program, whether it's a game, application or business process, you would use a database if you had 3.6 million items of data to store. You would very rarely load that amount of data into memory, simply because of the calculations and access time to get to an individual element, as well as the many other complications.

I'm afraid I can't help with Database access in DBC.

Something else you may want to think about is this: If this is a square grid, or a cubic grid, and you are mapping out regular intervals, you can translate the position mathematically and use the array element number. So in a 10x10x10 grid...

X=1,Y=1,Z=1 = element 1
X=1,Y=1,Z=10 = element 10
X=1,Y=2,Z=1 = element 11
X=2,Y=1,Z=1 = element 101


...and so on. That removes 3 dimensions of your array.



Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 30th Jun 2006 12:18 Edited at: 30th Jun 2006 12:37
@BatVink:
I think I understand what your saying.

So for an Array(X,Y) I could instead do this:
Array(10,10) <---- Old
Array(100) <---- New

So every multiple of ten is the next row.

Makes the math a bit more complicated, but frees up a dimension.

Did I get it right?

(((EDIT - Text below this point is added)))

BatVink's Array:

*Slightly confused* I think I got it wrong...

Ok, is it like this?

Place-value = X,Y,Z.
Ones = X
Tens = Y
Hundreds = Z

So Array(1)=143 Is X4 Y5 Z2

That would reduce it to a 1D array, I think...


(((EDIT, again - Text below this point is added)))

So then to store a variable inside this... I could tack it on like this:

Variable = 32
X = 4
Y = 5
Z = 2
Array(1) = 14332

Also, I could make it except higher numbers then 9(10) by building it like this:

Array(1) = 01040332

Am I correct in my thinking?

When I dream,
I carry a sword in one hand,
a gun in the other...
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Jun 2006 13:45 Edited at: 30th Jun 2006 13:46
Not quite, but my explanation was slightly misleading. You can reduce your first 3 X,Y,Z elements to just one.

Quote: "Place-value = X,Y,Z.
Ones = X
Tens = Y
Hundreds = Z

So Array(1)=143 Is X4 Y5 Z2"


For a 10 x 10 x 10 array, that's exactly it. If it was anything else, you'd have to adjust to suit. For example, if it was 8 x 8 x 8, then row Y=2 would start at element 9 (8 + 1).

I don't know what your additional elements are, but let's say they are height, weight and health. Using your example above again(X/Y/Z = 4,5,2), and Tinkergirls's suggestion you now have:

Array(143,1) = 100 (Height)
Array(143,2) = 20 (Weight)
Array(143,3) = 99 (Health)




X Trade
20
Years of Service
User Offline
Joined: 19th Feb 2004
Location: near bristol, UK
Posted: 30th Jun 2006 20:14
I think i may understand now.. are you planning on being able to switch between 'planes of reality' during play? e.g. shift to an alternate level, kind of thing.. and you want to keep the data on the different levels in an array..
that would suggest a 4 or 5d array.. but not larger than that.


I think the problem with compiling was that you were inputting all the data by hand - if you had a external text file (and not millions of lines of statements filling your arrays) then it would work.. because, if im thinking right, more than 65536 lines would be a problem in an application.. possibly

www.AoFP.co.uk
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 30th Jun 2006 22:40
@BatVink
Ah, I see. So My array would have to look like this:
LargeArray(3,640,000) = 040404111321
(A 10,10,10,70,52 At coordinates 3,3,3,10,12 and a variable of 20)

Or possibly like this if I increased the dimensions to allow some weirdness...
EvenLargerArray(3,640,000) = 04040411130606030621
(A 10,10,10,70,52,10,10,3,6 At coordinates 3,3,3,10,12,5,5,2,5 and a variable of 20)

9D array would allow both the plane shifting X Trade mentioned (8th D) and the storage of all data types (9th D) that are related in the same massive array, along with two more dimensions that I can play with... (6 & 7 D)

The possibilities are quickly becoming endless now that I can expand farther and farther into different coordinate sets... Almost infinitely so...

Ack! But, won't the array for the 5D (10,10,10,70,52) still be the same length line wise, and the same size memory wise?

LargeArray(3,640,000) = 3,640,000 Lines
Large5DArray(10,10,10,70,52) = 3,640,000 Lines

Still opens up the ability of infinite D in DBC though.

@X Trade
The thought of some kind of plane shifting (Or a Darkworld Zelda 3 style.) had occurred to me. But it doesn't fit in with this project.

6D where the sixth dimension is the currant dimension/plane, and the seventh dimension is the data type. So I'd need to push 7 if I wanted to include all the coordinates + the data type being stored.

At the moment data type being stored & dimensions/planes are not part of this games array. (The 5D '10,10,10,70,52' array)


It may mean re-working a lot of the program coded so far... but infinite dimensions stored inside the variable itself could be very useful.

When I dream,
I carry a sword in one hand,
a gun in the other...

Login to post a reply

Server time is: 2024-11-26 16:33:06
Your offset time is: 2024-11-26 16:33:06