Recording demo/playing it back

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

Post Reply
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Recording demo/playing it back

Post by Bilbo »

I thought about ability to record the session and being able to play it back later. Technically it should not be very hard, since the session would contain the savegame of state at start of the session, then appended stream of packets of world updates as it would come from network server (or even the exact stream that comes from network server if not playing locally.) Maybe add some extra info to the demo (viewport position, etc ...)

Replaying the demo would require just loading the map, then switch to spectator mode and start "receiving" the packets stored in the demo file as if they came from the server.

This may be invaluable to show someone how to do something or maybe to report some bugs ...

The demos will be probably incompatible between versions but ... it is still useful even in that way.
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Recording demo/playing it back

Post by Bilbo »

I wonder, IF the demo would be played by the exact version in which it was recorded ... would this "playback" work? In theory it should and basically, the demo will require same amount of data to record as is transfered over network if playing (or less if some compression is used) ... and since this is not much, the demos would be reasonably large, right?

Any insight from devs on feasibilty of coding this?
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Tom0004
Chairman
Chairman
Posts: 822
Joined: 01 Jul 2007 22:33
Location: Manchester, UK

Re: Recording demo/playing it back

Post by Tom0004 »

i believe someone attempt this awhile back, using sceenshots and putting them into a little video, but can't find the thread :roll:
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Recording demo/playing it back

Post by Bilbo »

0004tom wrote:i believe someone attempt this awhile back, using sceenshots and putting them into a little video, but can't find the thread :roll:
That would be awfully ineffective and lossy ...

What I thought of is a demo that will consist of a savegame (as received when starting game/connectiong to server), version info (to ensure it is played in same version as recorded) and stream of DoCommand packets as received from servers (and this stream will then build tracks, handle trains, etc ...) - or some similar stream generated when playing locally). Since OpenTTD is said to consume 1.2kbyte/second, this stream should have same size. So 1 hour demo will have about 4 megabytes. Which is IMHO reasonable and much less than 1 hour video. Also, such demos may be invaluable tool to hunt bugs and post bug reports ... :)
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
User avatar
RainierWatcher
Traffic Manager
Traffic Manager
Posts: 244
Joined: 14 Jan 2007 15:10
Location: West Norfolk, England

Re: Recording demo/playing it back

Post by RainierWatcher »

Bilbo wrote:Since OpenTTD is said to consume 1.2kbyte/second, this stream should have same size. So 1 hour demo will have about 4 megabytes. Which is IMHO reasonable and much less than 1 hour video. Also, such demos may be invaluable tool to hunt bugs and post bug reports ... :)
Well, once the initial map array is stored, the rate is that anyway. But bear in mind that a 2048*2048 map will be about 4MB before anything else.

But I see where you are coming from, storing that data as it happens and replaying it might work.
Ways of Preventing Death:
* Don't breathe air. Seriously. Everyone born before 1870 breathed the substance at some point in their life and every one of them is dead today. A coincidence? I think not.
Taken from uncyclopedia
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: Recording demo/playing it back

Post by TrueBrain »

I think this is close to what you mean:

http://devs.openttd.org/~darkvater/patches/demo_v8.diff
http://devs.openttd.org/~truelight/patc ... 2.01.patch

The first is DarkVater's continued work on my initial patch to record a demo of an OpenTTD game and replay it later, the second is a rewrite of me from the v8, also trying to keep track of the mouse-cursor, in order to allow tutorial recordings. But as many of my projects (or DarkVater's for that matter), they tend to die when they take too long ;)

(ps: as you can see, the patches are from REALLY long ago, and won't apply anymore :))
The only thing necessary for the triumph of evil is for good men to do nothing.
Torrasque
Engineer
Engineer
Posts: 94
Joined: 19 Aug 2004 13:33
Contact:

Re: Recording demo/playing it back

Post by Torrasque »

RainierWatcher wrote:
Well, once the initial map array is stored, the rate is that anyway. But bear in mind that a 2048*2048 map will be about 4MB before anything else.

But I see where you are coming from, storing that data as it happens and replaying it might work.
No, if you record an entire game, you juste have to send the seed used when generating land, wich is a few byte.
User avatar
RainierWatcher
Traffic Manager
Traffic Manager
Posts: 244
Joined: 14 Jan 2007 15:10
Location: West Norfolk, England

Re: Recording demo/playing it back

Post by RainierWatcher »

Torrasque wrote:
RainierWatcher wrote:
Well, once the initial map array is stored, the rate is that anyway. But bear in mind that a 2048*2048 map will be about 4MB before anything else.

But I see where you are coming from, storing that data as it happens and replaying it might work.
No, if you record an entire game, you juste have to send the seed used when generating land, wich is a few byte.

What if it isn't a random one? Plus the location of roads, buildings vehicles at the start, if you don't tart recording at the very beginning.
Ways of Preventing Death:
* Don't breathe air. Seriously. Everyone born before 1870 breathed the substance at some point in their life and every one of them is dead today. A coincidence? I think not.
Taken from uncyclopedia
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Recording demo/playing it back

Post by Bilbo »

RainierWatcher wrote:
Torrasque wrote:
RainierWatcher wrote:
Well, once the initial map array is stored, the rate is that anyway. But bear in mind that a 2048*2048 map will be about 4MB before anything else.

But I see where you are coming from, storing that data as it happens and replaying it might work.
No, if you record an entire game, you juste have to send the seed used when generating land, wich is a few byte.

What if it isn't a random one? Plus the location of roads, buildings vehicles at the start, if you don't tart recording at the very beginning.
It will be solved same way as when joining network game. Start with sending (saving) entire map, then send (save) only commands after that.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1357
Joined: 15 Feb 2003 17:32
Location: Vergezac, France

Re: Recording demo/playing it back

Post by MagicBuzz »

Sorry, I didn't read all.

The big problem with demo playback is... the random factor.

Many parts of the game are using random numbers, so you can't reproduce exactely the same thing.

The best exemple is about the original Transport Tycoon game.
There were a button "tutorial", that just launched a saved game and let the computer playing to show the player the basis of the game.

Bad news, when the tutorial started, a news message was poping, and the tutorial mouse cursor accidentally click on it (because it was recorded without this message poping), then the screen scrolled to another area and the tutorial was completery stuck.

With this exemple, I can say the demo play back concept is quite easy, but the border effects can be huge and hard to predict ;)
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Re: Recording demo/playing it back

Post by richk67 »

Actually, there are no truly random numbers in OTTD. It uses a seeded pseudo-random number generator. Reload the generator with the current seed, and the sequence after that is identical. Its the only way we can reliably do testing...
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Recording demo/playing it back

Post by Bilbo »

richk67 wrote:Actually, there are no truly random numbers in OTTD. It uses a seeded pseudo-random number generator. Reload the generator with the current seed, and the sequence after that is identical. Its the only way we can reliably do testing...
Also the only way how networking can work - the seed is maintained same between server and client - if client gets different seed than server somehow (like due to some bug), desync will occur.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Recording demo/playing it back

Post by DaleStan »

MagicBuzz wrote:The best exemple is about the original Transport Tycoon game.
There were a button "tutorial", that just launched a saved game and let the computer playing to show the player the basis of the game.

Bad news, when the tutorial started, a news message was poping, and the tutorial mouse cursor accidentally click on it
That has nothing to do with random numbers. That's the news settings. The demo assumes that you don't know how to change the news settings before you watch the demo.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Recording demo/playing it back

Post by Bilbo »

DaleStan wrote: That has nothing to do with random numbers. That's the news settings. The demo assumes that you don't know how to change the news settings before you watch the demo.
Still, the developers should have taken a bit precaution and disable the news for the demo. Well, there are many games when demo or tutorial will fail because on of the key characters dies or gets lost or stuck ....

I tired out of curiosity the demos in TTDPatch .. all of them fails because controls are a bit different than in original TTD ... :)
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Recording demo/playing it back

Post by DaleStan »

And *that* is because you didn't turn everything off first.

The demos in TTD are really weak, and we see no reason to fix them. If you actually want to watch, ensure that all news messages are set to "summary", and that all patches, except win2k, are off.

This isn't documented well, but since it comes up only once every couple of years, no one's bothered to actually do so.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Zephyris
Tycoon
Tycoon
Posts: 2897
Joined: 16 May 2007 16:59

Re: Recording demo/playing it back

Post by Zephyris »

If they dont work surely its time to fix/remove them?
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Recording demo/playing it back

Post by DaleStan »

They do work. Provided you do things correctly.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 42 guests