Posts: 777
Threads: 11
Joined: Apr 2012
(March 8th, 2013, 12:59)novice Wrote: A rough idea for an observer mode in Civ:
Add a mod to Civ that outputs the map state to an open format (xml, json) on disk.
Add a web viewer that displays the information on the web.
Worth doing?
Yes it's absolutely worth doing and I would love whoever pulls this off.
Posts: 7,766
Threads: 94
Joined: Oct 2009
I would love an observer mode. I'm not sure what's the best way to do it though. Seems like it would be hard to make a web interface display all the info we'd like to see.
In one sense an ideal solution would be to allow the game to output some sort of saves that can be loaded up in single player or multiplayer. This could also be used to continue playing aborted PBEMs against AI from any point, which would be kind of cool. If executed accurately, it could also be used to edit things in the middle of a multiplayer game without having to compile a custom DLL each time. Not sure how to do this though. The code that loads and saves files, including the part that marks saves as multiplayer, isn't accessible in the DLL.
However the web interface sounds cool too if you focus on providing a turn-by-turn history.
Posts: 6,094
Threads: 36
Joined: Jul 2010
(March 8th, 2013, 12:59)novice Wrote: A rough idea for an observer mode in Civ:
Add a mod to Civ that outputs the map state to an open format (xml, json) on disk.
Add a web viewer that displays the information on the web.
Worth doing?
That sounds awesome.
Configure it to update after the last player in turn order hits end turn (PB) or sends on the save (PBEM, requires an additional forward from the tracker).
Post the URL of the "State of the World" website in the Lurker thread.
Easy updates for Lurkers that are player invisible.
fnord
Posts: 13,563
Threads: 49
Joined: Oct 2009
On a related note, how is civstats implemented?
I have to run.
Posts: 13,563
Threads: 49
Joined: Oct 2009
Is anybody interested in contributing to this experiment? I was thinking of doing a proof of concept with a python mod dumping the map state to a text file whenever the game is saved, and a simple web viewer displaying the info. If somebody wanted to contribute on the mod part that would be cool, it's not really my area of expertise.
I tried adding some simple code to hook into the game and output info to a file, but I seem to have run into issues where the python code has very limited permissions. We don't really want to have to run Civ in Administrator mode or anything. Maybe there's a better way to output the info, I notice Civ has message logs and debug logs but I don't know how that framework functions. Well we know there's a good way to solve this, since e.g. the spanish AptMod does the same thing conceptually - I just don't know what the best practice is, personally.
By the way, Seven: The file \Beyond the Sword\Assets\Python\EntryPoints\CvAppInterface.py has methods onSave() and onLoad() that look like hooks into the save process to me. I don't know if studying them will reveal any information about the save file format itself, maybe it won't.
I have to run.
Posts: 875
Threads: 3
Joined: Mar 2011
If you want to hook all the underlying stuff, my guess is you're going to have to delve into the C++. But I'm not familiar with the code base.
Alternatively, just having a per-turn save snapshot should provide enough delta info to generate a timeline. So if you can reverse engineer how each save is stored for a PBEM I'd say you're golden. Just have to manipulate the data into something reasonable for your purposes, then display them.
Now if only I had globs of time to sink into a project like this...
MP
Pitboss Demo - Darrell's Tropical Trolls
PBEM45G - Sareln
Posts: 6,730
Threads: 131
Joined: Mar 2004
Unfortunately, the save format has not yet been reverse engineered, as far as I know. That's because the save format is not really defined in the first place. The C++ just gets a stream object from the .exe, and each game entity serializes its state into the stream in turn. The process is reversed on loading. So to load a saved game from some other framework, you'd have to replicate the exact structure and order of all the game entities. It's nowhere near as simple as looking at hex offset 80 for city name #1 and that sort of thing.
So emitting the game state from Python might be more manageable, and that comes with the advantage that the game itself doesn't need to run with a DLL mod, you can swap that Python in anytime. Python should make it pretty easy to loop over map and city and player elements and print out text or XML or whatever format you want. Is the limiting factor there just getting access to the file system to write out anything?
Posts: 13,563
Threads: 49
Joined: Oct 2009
(March 12th, 2013, 13:23)T-hawk Wrote: Is the limiting factor there just getting access to the file system to write out anything?
For a n00b like me, yes. I'm able to use the Python open() command and write to a file from the Debug console if I run Civ in Administrator mode (on Windows 7). Trying to open files from the python scripts in the mod folder fails.
Maybe it's actually easier to just push the data to a web service.
I have to run.
Posts: 6,730
Threads: 131
Joined: Mar 2004
Are you trying to write somewhere under Program Files (which the Mods folder would be)? Windows doesn't like that, that requires admin rights in Vista and later. See if you can write into the current user's My Documents or Desktop folder, or maybe something like c:\temp.
Posts: 13,563
Threads: 49
Joined: Oct 2009
I'm trying c:\temp, having given the Everyone group Full control over that folder.
I have to run.
|