Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (opm), 778 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: How to save the contents of an array, WRS/resource [Re: Superku] #466040
05/22/17 15:39
05/22/17 15:39
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Originally Posted By: Superku
Go to
GStudio8 -> data -> options.scr,
open it with a text editor, find
EXCLUDE_RESOURCE = "WRS;TMP;AVI;MPG;MOV;DLL;C;H;XML;LOG;TXT;PNG"
, for me personally this is already correct (maybe I changed it earlier or cause of new version, cannot remember). Also kindy funny that you can remove wrs from it, so you can have wrs files within your wrs files. grin

Last edited by Reconnoiter; 05/22/17 15:40.
Re: How to save the contents of an array, WRS/resource [Re: Reconnoiter] #466044
05/22/17 19:30
05/22/17 19:30
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Hi friends.

A small update. I was having alot of trouble when it came to pathfinding and reading values from an array. When the level computes the paths in the beginning and fills the array, the AI's move normally laugh But when I saved out this same array to a txt file, thats where things got bad. (I wanted to save to TXT to save from having to compute the A* every time the level is loaded)

When my AI's were using the array that was filled from a TXT file, they glitched out and gave me a bunch of errors I've been wracking my brain trying to figure out. Tried alot of different things and still couldnt get it to work. Making sure it was filling the correct values, looking at huge notepads with too many numbers, seeing if the index was off etc etc frown

But then I tried game_save! with SV_INFO as the flag, and then renaming this big path array with an _i at the end, I was able to load the saved array into the level using memcpy, without having to reload the level.

I will do more testing, but here is pseudo code of what I plan to do:

main()

1.find the level_name of the level
2.see if there is a saved Node.sav that matches the level name
3.if there is a save file that exists, that means the paths were computed
4.Load the .sav game then memcpy the path array into the working path array
5.Run level
6.If there is no save file that matches the level name
7.Run path calculation and fill the array
8.Create a save file and save the _i arrays
9.Run level

The initial TXT file was also pretty big. I made a worse case scenario, with an array of 999999, with a 0 in every slot, and this txt file came out to be around 5 megs. But saving these arrays in a .sav, the .sav comes out to be only 461 kilobites! The manual says .savs are compressed laugh

Last edited by jumpman; 05/22/17 19:35.
Re: How to save the contents of an array, WRS/resource [Re: jumpman] #466046
05/22/17 22:32
05/22/17 22:32
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
@WretchedSid

Memcopy seems to only work when the array index is under 314. I have no idea why that number, but using memcopy with a huge array works until the array index is over 314. Is this a memory problem?

Re: How to save the contents of an array, WRS/resource [Re: jumpman] #466048
05/23/17 02:30
05/23/17 02:30
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
@jumpman that doesn't sound right, can you show us some code?


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: How to save the contents of an array, WRS/resource [Re: WretchedSid] #466050
05/23/17 04:24
05/23/17 04:24
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Hi wretchedsid:

//----------------These 2 arrays are the "working" arrays
var node_to_node[999999];
var visited[999999];

//----------------These 2 arrays are the ones saved in a .Sav file
var node_2_nodeCopy_i[999999];
var visited_i[999999];

Code:
memcpy(node_2_nodeCopy_i,node_to_node,999999); //
wait(1);
memcpy(visited_i,visited,999999);


Re: How to save the contents of an array, WRS/resource [Re: jumpman] #466053
05/23/17 05:43
05/23/17 05:43
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Are you aware of my pathfinding "solution" which does not need to precompute stuff (apart from WED paths) and has some other useful features as well?
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=463551#Post463551


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: How to save the contents of an array, WRS/resource [Re: Superku] #466059
05/23/17 13:46
05/23/17 13:46
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
hi Superku!

Can your solution do 3d pathfinding with vertical placement? How many nodes can yours do?

Re: How to save the contents of an array, WRS/resource [Re: jumpman] #466060
05/23/17 14:12
05/23/17 14:12
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
memcpy copies byte wise, var is 4 bytes.
You have to multiply the memcpy size by 4 => sizeof(var) to copy the whole array.

Last edited by Ch40zzC0d3r; 05/23/17 14:13.
Re: How to save the contents of an array, WRS/resource [Re: Ch40zzC0d3r] #466061
05/23/17 14:46
05/23/17 14:46
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Yes, it can deal with 3D stuff and multiple floors and stairs, as long as you set it up correctly (WED paths and regions - the region system is for bigger levels or when you know enemies won't leave that area - if they are supposed to move between different regions then there cannot be obstacles, think open world for example where regions are placed around houses or villages or forests). The number of nodes is not limited by my code, instead by Gamestudio limits/ max_paths or what that stuff is called (you would probably never hit that limit).
It finds the correct path in linear time so it's fine to use paths with a big number of nodes, however not necessarily the shortest path (in quants). It calculates the shortest path based on the number of nodes instead. Just place some extra nodes on long edges to equalize their "weight" in the pathfinding algorithm (- as a result you can make enemies avoid certain dangerous paths by placing extra nodes there).

Whoever thinks that's not acceptable that the path might not be the shortest 100% of the time... then you're probably not a game dev to begin with, at least not someone who fill finish and release a game. (which I know you are and you do, @jumpman - I got that feedback before though)

Last edited by Superku; 05/23/17 14:48.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: How to save the contents of an array, WRS/resource [Re: Superku] #466062
05/23/17 15:11
05/23/17 15:11
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Thank you @superku, I have downloaded your demo and I will look at how it works, thank you! Someone has commented that towards you before?

@chaoscoder how do I multiply the "count" ? just multiply that 999999 by 4?

Page 2 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1