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.

DarkBASIC Professional Discussion / 5 dimensions Array weird problem!

Author
Message
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 31st Mar 2010 01:33 Edited at: 31st Mar 2010 01:34
Hi all,
I am trying to use this array:



Ok, when i compile my 5 dimension array code i get a txt file error (when are present my project .EXEs) that contain these informations:


What the hell is happening??
Can DBPro handle a 5 dimension array like that?
Please help!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 31st Mar 2010 02:23
40 byte UDT + 4 bytes overhead multiplied by 201 x 3 x 102 x 51 x 101 comes to just under 13GB of memory required within your programs 2GB address space.

So no, DBPro can't handle an array like that.

luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 31st Mar 2010 02:32 Edited at: 31st Mar 2010 02:37
why you need so much dimensions?
i try your code and it works if you put lower numbers in every dimension.


produce crash.


works fine.do not produce crash.

I think that there maybe is limit how big dimensions you can assing.I use single dimension arrays and there was no need of making multi.What are you trying to achieve ?Maybe there is workaround to do it.If people know more can help you better.

EDIT: Now i`m sure there is limit!I just look at IanM above post, which he posted at the same time i write mine.So tell us what are you trying to do and we can help you because the multi dimension array is not working for your case.

Where there is a will, there is a way.
I often edit my posts, that`s who i am
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 31st Mar 2010 02:35
Thankyou IanM, now it's all clear.

I am on troubles because I NEED a 5 dimensions array.

I just watched my project going without problem with same array but with 4 dimensions.

Thanks again
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 31st Mar 2010 02:39
Well today everyone is faster than me.What are you trying to do?There must be better way to do it.

Where there is a will, there is a way.
I often edit my posts, that`s who i am
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 31st Mar 2010 02:41 Edited at: 31st Mar 2010 02:44
Hi luskos, i need my 5dimension array:

Pedine_mil rapresents the military units of my war engine.

pedine_mil(war number,war group, ID nation ,scenario number, unit number)

In the 5th war there are 2 war groups fighting. Both have some nations in their group so i need to have the ID nation, the war is composed by many war scenarios and in finish the military unit must have own number.


these variables are strictly for 2D coords and some other things to store for each military units:
TYPE type_my_array
tipo_unita as integer
quantita as integer
quantita_distrutti as integer
morale as integer
cas_attuale_X_real as integer
cas_attuale_Y_real as integer
cas_attuale_X_target as integer
cas_attuale_Y_target as integer
cas_vert_Y as integer
cas_oriz_X as integer
ENDTYPE



SO I NEED 5 dimensions!
Now i try to reduce number as your example do.
dark coder
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 31st Mar 2010 04:46
Quote: "SO I NEED 5 dimensions!"


No, you don't.

The correct way to handle this would be to have an array that stores a list of wars, this array references a second array that contains a list of war groups with associated nations. The nations themselves will be stored as a separate array where you can store more in depth data such as their flag, description and what not. The scenario itself would probably contain a lot of data so you wouldn't want to store every single one in RAM, instead, just load them up from file when you need them, this data would just contain a list of units and the nation they're associated with.

luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 31st Mar 2010 10:17
dark coder have answer for you allready, but it was just as i think that you do not need 5 dimensions.Multydimensional arrays can be used for extremly complicated stuff, and they are also hard to manage if do not understand them well.
2 dimnesional array like this :

have 100 units in the first dimension and 100 units to store data in the second dimension, but correct me if i`m wrong because i never used this kind of arrays and single dim arrays allways satisfy me, but for every unit of the first dimension you have preserved space of 100 units in second one, which is a lot and 5 dimensional array can make you insane when you try to imagine every possible combination even if it`s small one.

Btw dark coder i like your signature with the earth and the cat.At certain angle the cat is just not there

Where there is a will, there is a way.
I often edit my posts, that`s who i am
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 31st Mar 2010 10:28 Edited at: 31st Mar 2010 10:44
Hi Dark coder and hi again luskos, I understand the logic behind your words but is not easy. The 5 dimension array would be the ideal thing to do because with a single 5D array i can handle all the principal characteristics of the single military units.

In other words with a single 5D array i can understand all of my single units (the war in witch it is fighting, the group of belongings -attacker or defender- ,the nation of the unit ,the scenarios number in witch it is present, and the number of the unit) making the handle of these characteristics easy and fast thinking about FOR LOOP situations on my code.


EXAMPLE:
I need to search and to store the coords X of units of group 1 of 2nd war in all scenarios but only of the nation 34:



This is just a fast and stupid example for make you understanding the mode i am following to use 5 dimension array.


Please, can you provide me a little example of your idea?

Thank you
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Mar 2010 12:48
Even if you were able to create a 5 dimension array of the size you gave earlier you really shouldn't organise your data that way. Most of the array entries would be completely unused - as is clear from IanM's calculation. Make a rough estimate of how many entries you are likely to need and you will probably see how things should be organised.

I wonder whether a single list of "entities" with various "attributes" is all you need - plus the extra suggestions by Dark Coder.

For example, using IanM's numerical example you might find that of the 316817406 possible combinations you are only likely to need, say, 20000. So you only need a one dimensional UDT array of size 20000 in which the type is something like



You can then use the values in these variables to look up other quantities in other small UDT arrays, etc. You don't need to fix the size 20000 in advance - just use the array insertion commands to extend the list as necessary. Also, it will be MUCH faster to search a list containing only those combinations actually used rather than the zillions of unused combinations.

The main point is to organise your code so that you only set aside roughly as much memory as you will need (within reason of course - if you are going to use as much as, say, 90% of the possible entries in a 5-dimensional array then you might as well use the 5 dim array assuming it's within sensible limits of course).
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 31st Mar 2010 14:16 Edited at: 31st Mar 2010 14:34
hi Green Gandalf, if you take my previous example you will understand the advantages of 5D array.

So if i store all variables inside type as you suggest, you will see how many difficulty will be to handle my example:

EXAMPLE:
I need to search and to store the coords X of units of group 1 of 2nd war in all scenarios but only of the nation 34:




If you try to transform this example with an array as you suggest, you can understand that is very hard to use my example FOR LOOPS easly like now
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 31st Mar 2010 14:37
Quote: "easly like now"

Who on earth told you that programming was easy?

Anyway, out comes my trusty linked-list example...

The following code creates a grid of 5x5, and allows you to place any number of units within a tile - it was created as an example for someone who wanted to create some kind of war-gaming system - see what you can do with it:


Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 31st Mar 2010 14:48 Edited at: 31st Mar 2010 14:49
Thank you IanM for example!. Sure, nobody has said to me that programming is easy!! But sure is much better to find the better way to handle a routine/code/situation!.
Just if i can use a 5Dimension Array i can "easly" and "faster" find a particular units with a little code, as in my example. Just that.
I am a not too good programmer (in spite of everything my engagement) so i need of a code much easly and basic i can do!

Sure i have to considerate the "limits" of language so i have to modify my 5D array in the way you and other dudes suggest to me.

Thank you very much for the help to all!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 31st Mar 2010 14:56
Quote: ""limits" of language"

Limits of the machine and the OS. You would have exactly the same problem with any other 32 bit language that you might use in a 32 bit wintel system.

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 31st Mar 2010 15:02 Edited at: 31st Mar 2010 15:02
Yes right! I swear to you i meant machine limits! For me DBPro remain a pure "light in the dark" for my project objectivies!! and i think no other language can be "FOR ME" like that!
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Apr 2010 01:59
Please pardon the expression, but it's what's known as "lazy coding". You are overloading the system to make coding easier, and that's really not a good approach. You really should listen to IanM and the other advice you've been given. This is just the data for your game, once you start coding the rest you will find very quickly that you have no room for the good stuff.

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 1st Apr 2010 10:29 Edited at: 1st Apr 2010 10:31
Hi BatVink, mission accomplished!

The old 5 dimension array has become two 2dimension arrays:


I am sure this it can seem still wrong for professional coders but
in this way i found the right mix between my desperate demands of an easy code and a not "over limit" system request.

Thank you again to all for precious help!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Apr 2010 14:00
Sounds like a good start. Good luck with your project.
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 1st Apr 2010 15:01
Thank you very much Green Gandalf!
This is the 6th year of programmation of my project and the things getting hard and very complex! Sure without help of this forum I could not think to succeed to develop a real complex project like my game. Go.

Login to post a reply

Server time is: 2026-07-26 21:12:27
Your offset time is: 2026-07-26 21:12:27