Author Topic: Saved Games are coming  (Read 2331 times)

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Saved Games are coming
« on: 13 March 2012, 15:28:32 »
I have quite a bit of this funcationality working in svn, the main thing left (i think) is restoring particles on game load, but nearly everything else works. Currently the code in svn saves the game when you exit, so to test do some things (build and execute some commands) and exit the game, then reload like this:

Code: [Select]
./megaglest --load-saved-game
Thanks

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: Saved Games are coming
« Reply #1 on: 13 March 2012, 16:08:19 »
And the glest community rejoices!     Thank you softcoder!
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

Pizza90

  • Draco Rider
  • *****
  • Posts: 282
    • View Profile
Re: Saved Games are coming
« Reply #2 on: 13 March 2012, 17:29:10 »
Wow great job :)
I translated Megaglest in italian and i keep the translation updated.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Saved Games are coming
« Reply #3 on: 15 March 2012, 18:11:28 »
What about scenarios and LUA? Is it also possible to save the whole lua state?
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Saved Games are coming
« Reply #4 on: 15 March 2012, 20:10:01 »
What about scenarios and LUA? Is it also possible to save the whole lua state?
http://www.lua.org/about.html#name
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Saved Games are coming
« Reply #5 on: 17 March 2012, 01:15:48 »
OMG! Titi! You misspelled it!
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Saved Games are coming
« Reply #6 on: 17 March 2012, 20:48:30 »
well sorry , back to topic  :P

currently we try to save the whole game state. My son came up with another idea which maybe is no as bad as one might think first!
He said, why donÄt we save all commands given to units up to the moment where you want to play.....

Then you "replay" the whole game again ( without displaying ) until you reach the save point. The trick is that youget a VERY exact copy of the game state. This would even allow a reconnect to already running games! The only problem is, I don't know how many commands are executed in a game ....
What do you think about this idea?
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Saved Games are coming
« Reply #7 on: 18 March 2012, 01:15:31 »
currently we try to save the whole game state. My son came up with another idea which maybe is no as bad as one might think first!
He said, why donÄt we save all commands given to units up to the moment where you want to play.....

Then you "replay" the whole game again ( without displaying ) until you reach the save point. The trick is that youget a VERY exact copy of the game state. This would even allow a reconnect to already running games! The only problem is, I don't know how many commands are executed in a game ....
What do you think about this idea?
From a non-programming perspective, that sounds like the best way to "get it right", since you're including everything as a whole instead of trying to remember every little thing individually.

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: Saved Games are coming
« Reply #8 on: 18 March 2012, 01:27:46 »
well sorry , back to topic  :P

currently we try to save the whole game state. My son came up with another idea which maybe is no as bad as one might think first!
He said, why donÄt we save all commands given to units up to the moment where you want to play.....

Then you "replay" the whole game again ( without displaying ) until you reach the save point. The trick is that youget a VERY exact copy of the game state. This would even allow a reconnect to already running games! The only problem is, I don't know how many commands are executed in a game ....
What do you think about this idea?
I know nothing about programing so forgive me, but woulden't this make Megaglest much more cpu intensive? And how fast can the game be played out if the save is an hour or two into the game?

If it wont make Megaglest more cpu intensive than I agree with replicating all commands from the start, as its the most thorough.
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

TotalNoob

  • Guest
Re: Saved Games are coming
« Reply #9 on: 18 March 2012, 09:13:33 »
Think of all the commands that pathfinder had to calculate again. Restoring would take at least a couple of minutes if savegame would be from 2 hours game. As for the savefile size I think it might be as big as the log file created by verbose command. Afterall quite alot of events are already saved there and it usually takes around 40MB. Fortunately if you 7zip it, it shrinks to 2MB.

treba

  • Guest
Re: Saved Games are coming
« Reply #10 on: 18 March 2012, 21:46:07 »
actually that's the way how replays for other games work and they are usually quite small (hardly bigger than 100kb in sc2). don't know how saving works, but suprise, save files are about the same size, as long as there's no scripting involved. than it goes up to more than 3mb.
seriously, this is a good way to go

p.s.: as we are already talking about it: replays would be a nice feature, too  :P
sorry for that

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Saved Games are coming
« Reply #11 on: 19 March 2012, 06:12:00 »
I'm quite happy with how it is implemented now. Is there a problem with this approach, and a good reason why discussing alternative implementations is needed?
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

TotalNoob

  • Guest
Re: Saved Games are coming
« Reply #12 on: 19 March 2012, 21:06:12 »
Except for the commands themselves also result of random damage caused by every hit should be saved. I have no idea how they make it so small in other games. Maybe unit number limit helps ;)

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: Saved Games are coming
« Reply #13 on: 20 March 2012, 04:55:03 »
We now have both working in svn. To try the command method (where all commands are saved to a separate file), add this to glestuser.ini:

Code: [Select]
SaveCommandsForReplay=true
This will create a file with the name of the saved game + .replay appended on the end. This is an xml file containing all of the commands and the frame they are executed in. By setting that ini setting, we will save and load from the replay file.

Let me know what issues you find.

Bloodwurm

  • Guest
Re: Saved Games are coming
« Reply #14 on: 20 March 2012, 14:29:14 »
This kind of recording is both great for replay value and debugging purposes.

But yeah, the cost in memory might get enormous. I regularly read posts where people state they've played for HOURS for one particular game!
So unless you dump the records to file from time to time... you'll get in trouble...

You can get away with some of the recordings if the engine is truly deterministic. for instance, you might not have to store all the results of the pathfinding if said result is always the same.
Just record the move command (so Move + Target destination).

I would also revisit the data dump that presented earlier, there seemed to have some duplicates in there, and even some data that didn't really need to be saved at all (i saw a position x,y,z at least twice, something that looked like which animation was being played and the likes).

For scripts, it might be a good idea too to let each script decide what data they want to save. I'm willing to bet that some variables in there don't need to be reloaded. Should be more lightweight than say saving the complete lua context.

My 2 cents


victorj

  • Guest
Re: Saved Games are coming
« Reply #15 on: 23 March 2012, 23:40:18 »
So I have to thank a great job, really wanted this in MegaGlest.

 

anything