@
Dream And Death:
*Reads the code snippet*
Ok, I think I see what your saying.
If I understand this correctly by adding the math to the end of the array without placing an = you effect the last digit of the array instead of the value held at the coordinates.
Example:
Array(1,1)+1 Becomes Array(1,2)
If so, how do I alter the coordinates before the last coordinate? I was unaware you could perform math on an array like this.
X Trade:
Quote: "i think really it would be easier here just to write:
ArrayXVar = ExampleArray2DIsXYZ(1,0)
ArrayYVar = ExampleArray2DIsXYZ(1,1)
ArayZVar = ExampleArray2DIsXYZ(1,2)"
I see what you mean, but what if it was much larger in the number of types of data stored in the 2D.
Example: (I'm still using XYZ as the For/Next variable. Changing it to match the letters of the retrieved coordinates would just be cosmetic: XYZABCDEF)
REM Create The Array
DIM ExampleArray2DIsXYZ(1,2)
REM For/Next loop extracts XYZ from array to variables.
FOR XYZ = 0 to 8
IF XYZ = 0 THEN ArrayXVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 1 THEN ArrayYVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 2 THEN ArrayZVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 3 THEN ArrayAVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 4 THEN ArrayBVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 5 THEN ArrayCVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 6 THEN ArrayDVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 7 THEN ArrayEVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 8 THEN ArrayFVar = ExampleArray2DIsXYZ(1,XYZ)
NEXT XYZ
REM Calculations involving variables taken from array take place here.
REM For/Next loop inserts XYZ back from variables to array.
FOR XYZ = 0 to 8
IF XYZ = 0 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayXVar
IF XYZ = 1 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayYVar
IF XYZ = 2 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayZVar
IF XYZ = 3 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayAVar
IF XYZ = 4 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayBVar
IF XYZ = 5 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayCVar
IF XYZ = 6 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayDVar
IF XYZ = 7 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayEVar
IF XYZ = 8 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayFVar
NEXT XYZ
END
It would then be possible to retrieve specific coordinates only by changing the For/Next loop decay (I don't know the term it's called) variables.
Example: (FNFirst FNLast variables added to For/Next.)
REM Create The Array
DIM ExampleArray2DIsXYZ(1,2)
REM For/Next loop extracts XYZ from array to variables.
FOR XYZ = FNFirst to FNLast
IF XYZ = 0 THEN ArrayXVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 1 THEN ArrayYVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 2 THEN ArrayZVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 3 THEN ArrayAVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 4 THEN ArrayBVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 5 THEN ArrayCVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 6 THEN ArrayDVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 7 THEN ArrayEVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 8 THEN ArrayFVar = ExampleArray2DIsXYZ(1,XYZ)
NEXT XYZ
REM Calculations involving variables taken from array take place here.
REM For/Next loop inserts XYZ back from variables to array.
FOR XYZ = FNFirst to FNLast
IF XYZ = 0 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayXVar
IF XYZ = 1 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayYVar
IF XYZ = 2 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayZVar
IF XYZ = 3 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayAVar
IF XYZ = 4 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayBVar
IF XYZ = 5 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayCVar
IF XYZ = 6 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayDVar
IF XYZ = 7 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayEVar
IF XYZ = 8 THEN ExampleArray2DIsXYZ(1,XYZ) = ArrayFVar
NEXT XYZ
END
And the current object being worked on by the For/Next could be determined by a For/Next encompassing that, allowing objects to be worked on in sequence.
Example: (Variables CurrentObject, FNCOF & FNCOL added & 2nd For/Next loop.)
REM Setting 'For Next Current Object First/Last' Loop variables.
FNCOF = 1
FNCOL = 1
REM Current Object for data extraction.
For CurrentObject = FNCOF to FNCOL
REM Create The Array
DIM ExampleArray2DIsXYZ(1,2)
REM For/Next loop extracts XYZ from array to variables.
FOR XYZ = FNFirst to FNLast
IF XYZ = 0 THEN ArrayXVar = ExampleArray2DIsXYZ(CurrentObject,XYZ)
IF XYZ = 1 THEN ArrayYVar = ExampleArray2DIsXYZ(CurrentObject,XYZ)
IF XYZ = 2 THEN ArrayZVar = ExampleArray2DIsXYZ(CurrentObject,XYZ)
IF XYZ = 3 THEN ArrayAVar = ExampleArray2DIsXYZ(CurrentObject,XYZ)
IF XYZ = 4 THEN ArrayBVar = ExampleArray2DIsXYZ(CurrentObject,XYZ)
IF XYZ = 5 THEN ArrayCVar = ExampleArray2DIsXYZ(CurrentObject,XYZ)
IF XYZ = 6 THEN ArrayDVar = ExampleArray2DIsXYZ(CurrentObject,XYZ)
IF XYZ = 7 THEN ArrayEVar = ExampleArray2DIsXYZ(CurrentObject,XYZ)
IF XYZ = 8 THEN ArrayFVar = ExampleArray2DIsXYZ(CurrentObject,XYZ)
NEXT XYZ
REM Calculations involving variables taken from array take place here.
REM For/Next loop inserts XYZ back from variables to array.
FOR XYZ = FNFirst to FNLast
IF XYZ = 0 THEN ExampleArray2DIsXYZ(CurrentObject,XYZ) = ArrayXVar
IF XYZ = 1 THEN ExampleArray2DIsXYZ(CurrentObject,XYZ) = ArrayYVar
IF XYZ = 2 THEN ExampleArray2DIsXYZ(CurrentObject,XYZ) = ArrayZVar
IF XYZ = 3 THEN ExampleArray2DIsXYZ(CurrentObject,XYZ) = ArrayAVar
IF XYZ = 4 THEN ExampleArray2DIsXYZ(CurrentObject,XYZ) = ArrayBVar
IF XYZ = 5 THEN ExampleArray2DIsXYZ(CurrentObject,XYZ) = ArrayCVar
IF XYZ = 6 THEN ExampleArray2DIsXYZ(CurrentObject,XYZ) = ArrayDVar
IF XYZ = 7 THEN ExampleArray2DIsXYZ(CurrentObject,XYZ) = ArrayEVar
IF XYZ = 8 THEN ExampleArray2DIsXYZ(CurrentObject,XYZ) = ArrayFVar
NEXT XYZ
NEXT CurrentObject
END
X Trade:
Quote: "(using types here just to make it easier to read)"
I don't completely understand types yet. I don't have DBP up and running at the moment. (Not an option, my DX9 capable graphics card needs to be replaced so I'm running off an older DX8 capable card.
)
If I understand this correctly:
"pos(x, y, z, 3) = pos(x, y, z, 2) + (12*5) - obj(i, 12)"
The array 'pos(x, y, z, 3)'s stored value is now 'pos(x, y, z, 2)' + 60 - the array 'obj(i,12)
...
I'm not understanding this. Is this changing the value of the array coordinates or the value contained at those coordinates?
wschramm:
Quote: "10 element array to simulate a 10 digit grid cooridnte"
True I am building a form of 10x10 grid for this project.
wschramm:
Quote: "for a form of navel simulation??"
That 'is' on my list of things to do, and I was planning on using arrays to store the map data for it. But it isn't the goal of this project.
For the 'navel simulation' I figure I'll be using some kind of X,Y,DataType 3D Array where the data types hold information such as depth of the water, type of water, temperature of area, etc... (Got sidetracked,
Concept design is still rough and no actual code has been written on that project.)
wschramm:
Quote: "this can track a 5000x5000 map using about 227megs of ram that is 25,000,000 points!!!! on a map or such so use this instead of a 10 element array."
*Reads through the code snippet several times... then runs it via DBC.*
Odd, 'DATA retrieved :' always equals 0 when I run the program.
*Scans over the code snippet repeatedly...*
Ack, I can't see why it's doing that.
Alright. I think I see what your doing:
rem at 5000 this program took 227 megs of ram to run.
rem at 8000 it took 571 megs
rem at 9000 the program started to slow and was using around 700 megs of ram
REM Map quadrant size, used to gain Full X, Y size.
REM (Changed to 10 for easy calculation)
mapsize = 10
rem this is how big the map is on a side exp 10000x10000 10 digit grid 5 ns 5 ew
REM datapoints = 10 * 100 + 10 = 110
datapoints = mapsize + (mapsize * mapsize)
REM Build global 1D array using datapoints as max coordinate value.
dim LOCATION(datapoints)
rem only 1 deminsion needed to store info?
rem ok now to store and retrive points test
REM Begin Loop & Clear Screen
do
cls
REM Print "X: 0 to 'mapsize's value' --",
REM Then dump keyboard input into XX variable.
input "X: 0 to "+STR$(mapsize)+" --", XX
REM Same as above except this time with Y
input "Y: 0 to "+STR$(mapsize)+" --", YY
REM XX + 'Value of YY * mapsize'
datapoints = XX+(YY*mapsize)
REM Print "DATA to store: 1 to 35 --",
REM Then dump keyboard input into the LOCATION() array
REM at the coordinate location of datapoints.
input "DATA to store: 1 to 35 --", LOCATION(datapoints)
REM Move down a line then print "Retrieving data"
print
print "Retrieving data"
REM NYY = datapoints / mapsize.
NYY=datapoints/mapsize
REM NXX = datapoints - 'Value of NYY * mapsize'
NXX=datapoints-(NYY*mapsize)
REM Print "X: " and the value of NXX
print "X: "+STR$(NXX)
REM same as above except this time using Y
print "Y: "+STR$(NYY)
REM datapoints = NXX + 'value of NYY * mapsize'
datapoints = NXX+(NYY*mapsize)
REM Print "DATA retrived : --" Then print the value
REM stored at the coordinats refranced by the datapoints
REM variable in the LOCATION array.
print "DATA retrived : --"+STR$(LOCATION(datapoints))
REM Print "PRESS A KEY" wait for input then restart loop.
print "PRESS A KEY"
wait key
loop
You first assign the size of the total map by giving the value of one of its NW,NE,SW,SE quadrants. This is placed into the variable mapsize.
This value is then expanded to the full map size and a global 1D array is created with that value in it as it's maximum coordinate value.
A set of 'X' & 'Y' coordinates are selected and the variables for them are dumped to XX & YY.
The value of the variable 'datapoints'
is changed to the value of YY * mapsize + XX. datapoints was used previously to determine the maximum value for the 1D array, here it is being used to determine a coordinate set within the already created array.
Then the value stored in the 1D array at the datapoints coordinate(s) is entered.
Now the process of retrieving the information begins.
Two new variables are created NYY & NXX.
NYY's value is that of the variable 'datapoints' divided by the value of 'mapsize'.
Then NXX's value is determined by subtracting the value of 'NYY' multiplied by 'mapsize' from datapoints.
The coordinate(s) to retrieve the data from the 1D array are then placed in the datapoints variable. The value of which is determined by multiplying NYY by mapsize then adding the value of NXX.
The value of the 1D array at the coordinate(s) of datapoints are then printed to the screen.
(Should be anyway... always prints 0 when I run the program?)
After that the program waits for a key press then restarts the loop/process.
Do I have the process of your method correct? (Why doesn't it return the stored data value.)
I found it a little more complicated then a normal Array command, had to work through it slowly to figure out how it was doing everything. I've got to brush up on my math.
If I understand correctly this method uses less RAM then a regular Array command?
*Whips out a calculator and uses the method for finding ram use described in previous posts on this thread.*
25,000,000 (number of positions) * 4(bytes) = 100,000,000(bytes) = (/1024 for Kb) = 97656.25(Kb) (/1024 for Mb)=95.367431640625(Mb)
95.3Mb vs 227Mb
Alright, now I’m confused. Is your method less memory efficient? Or have I calculated the RAM data wrong.
wschramm:
Quote: "I think I understand why you want the array this way, kind of a zoom element to the map each level of the map is 10x10 and as it goes down each square on the bigger map has has 10x10 squares of a lower map??"
So in for example:
DIM Array(10,10,10,10,10,10)
Array(X,Y,A,B,C,D)
So: X,Y would be a coordinate and A,B would be a coordinate in X,Y and C,D would be a coordinate in A,B?
I'm not using a 'zooming' feature of that nature in this project.
wschramm:
Quote: "if so it is best to make the map 1 big map and use math to extrapulate the 7d coor to display to player."
Wouldn't that only be possible in 3D? (I don't mean a 3D array, I mean graphics.)
Crit:
Quote: "You can delete it and it should still run correctly."
Ok.
Code changed to this for convenience:
SYNC ON
HIDE MOUSE
Print GoneThroughNumber
numlines=1000000
open to write 1, "d:test.dba"
write string 1, "dim a(10,10,10,70,52)"
for x=1 to numlines
write string 1, "a(1,1,1,1,1)=10"
ARun=ARun+1
IF ARun = 10000
ARun = 0
GoneThroughNumber = GoneThroughNumber + 1
CLS
Print GoneThroughNumber
Print " ";
Print x;
Print " / 1000000"
SYNC
ENDIF
next x
close file 1
PRINT "IT IS FINISHED"
SUSPEND FOR KEY
END
*File built, opens file in DBC Editor... took a second but no problems. Selects Build Final .Exe and waits... and waits... waiting... Status bar with 10% appears, 20%, 30%, 10%?, 20%, 30%, 40%, 50%, 10%?, 20%, 30%, 40% ,50%, 60%, ETC, 100%... waits... waits, waits... waits some more... 30mins later: Attempts ALT-TAB, ALT-F4, CTRL-ALT-DEL... sadly hits the reset button on his case...*
Alright well that's not going to work.
But if I store the data in an external file there won't be a problem right?
Any suggestions on a way to load the information from an external file into a 5D array in DBC?
Crit:
Quote: "What does your timeline look like?"
Timeline? Do you mean the timeline for the projects completion?
*Thinks about it for a second or two...*
This projects pretty big, a lot still needs to be done. I’ve still got to finish pieces of the engine (Until I get all the data entered there isn’t much point in finishing it.) and enter in all the data from the concept notes/files. Then some stat balancing...
the sprites/art... stories not a problem so far, although editing the dialog together could take a bit...
It’s going to take quite sometime before it’s done but it ‘will’ be done eventually.
Three months would be being very optimistic for a working demo of the first areas.
*Shrugs*
Plus, I hope to be releasing other games in the meantime while I work on this project.
(I have a smaller project, an ‘almost-finished’ dungeon crawl/RPG that I may be releasing in a bit. Just need to finish the engine, almost all of the data the engine calls is already entered.
)
A few of my other projects designs also call for the use multi-coordinate arrays, although mostly not for the same reasons. And none of the others on this scale (Which is good, because I figure one massive project at a time is enough.)
Going is slow because of the size of it. A lot gets done every day.
When I dream,
I carry a sword in one hand,
a gun in the other...