News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Game Data -- Export/Dump

Started by Casteele, January 17, 2009, 04:00:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Casteele

Add an option to export/dump various bits of game data into one or more simple file formats (comma/tab separated, xml, etc) for easy import into external tools (such as spreadsheets, etc.)

Of course, only export/dump data which makes sense and can be useful in writing external tools to aid gameplay, logistics planning, etc. Things like the current list of goods prices, costs (and availability at the time of data dump/export) of new vehicles, station locations (and possibly distances between? Or maybe node lists for pathways..), lists of vehicles in operation/storage, industries, lines, financial data, etc.

Basically, I started looking for game data tables to put into a spreadsheet to help me plan convoy configurations and line planning. But much of the game data is specific to each game, it's pak, and other settings, so there are no 'universal' tables.

isidoro

If I'm not wrong, now you can do that.  You can save games in XML format.  You then uncompress the resulting file and there it is the XML file.

Casteele

Yes, you can save games in XML format.. However.. a newly created 512x512 map, immediately saved as XML is 109+ megabytes on my system. It also has every last detail of the game data, of which 99% is probably useless to the purposes I am proposing. Further complicating things, the data is not self-documenting, so extracting the data wanted would require enough code that I would just devote the time to writing a new game rather than a tool to extend and enrich SimuTrans.

Extracting the data from a binary save file might be easier, if the save file format is clear and well-documented/well-structured.

But ultimately, the game already has code to extract most if not all of the desired data.. the same code that puts it on the game screen could be modified to dump it to a file instead. (Without having seen the source code, I do not know how difficult such mods would be.. but if it's too difficult, then maybe the code needs to be re-written anyhow!)

VS

Uhm. Prissi has a family to feed, plus a job to do so. Perhaps you can try?

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Casteele

Perhaps I can. But I, too, have a family and a job, and a lot less investment or incentive in the game to improve it at this point. Plus, there is a development forum for those who wish to join development and write code. I would thusly assume the extension requests forum is for those who wish to request an extension and discuss them more fully.

So, I would kindly ask that you post something useful to the discussion, rather than a curt "do it yourself" type reply. Do you (or others) like the idea? Would you find it useful? Are there any technical issues you can foresee that I have missed? Is there something you think might improve the suggestion and make it even better for the game? Would it detract from the game? Et cetera.

Perhaps, once these questions are answered, I'll have the incentive and motivation to start learning the code and try..

prissi

You don not have to parse all 109MB. Just look for spieler_t records. The entries with sint64 are the player statistics. Those are first per year and then per month the following categories:

COST_CONSTRUCTION=0,// Construction
COST_VEHICLE_RUN,   // Vehicle running costs
COST_NEW_VEHICLE,   // New vehicles
COST_INCOME,        // Income
COST_MAINTENANCE,   // Upkeep
COST_ASSETS,        // value of all vehicles and buildings
COST_CASH,          // Cash
COST_NETWEALTH,     // Total Cash + Assets
COST_PROFIT,        // COST_POWERLINES+COST_INCOME-(COST_CONSTRUCTION+COST_VEHICLE_RUN+COST_NEW_VEHICLE+COST_MAINTENANCE)
COST_OPERATING_PROFIT, // COST_POWERLINES+COST_INCOME-(COST_VEHICLE_RUN+COST_MAINTENANCE)
COST_MARGIN,        // COST_OPERATING_PROFIT/(COST_VEHICLE_RUN+COST_MAINTENANCE)
COST_ALL_TRANSPORTED, // all transported goods
COST_POWERLINES,   // revenue from the power grid
COST_TRANSPORTED_PAS, // number of passengers that actually reached destination
COST_TRANSPORTED_MAIL,
COST_TRANSPORTED_GOOD,
COST_ALL_CONVOIS, // number of convois
COST_SCENARIO_COMPLETED,// scenario success (only useful if there is one ... )


Since the code is object oriented, documenting the savegame is not easy, as every version could change its entry complete (although usually only one or two thing in an entry are changed; but 101 is very different from 100, as nearly everything is changed.) A similar tactic works for convois and cities too.

Since I would not use this funtion, I have no incentive to do it. But some other players requested it, maybe you can motivate somebody. But there will be hassles, like what format and how to create a file.

VS

I apologize if you feel that I went too far. My (slight) irritation stemmed from the following:

1) One can imagine so many kinds of data that adding export capability everywhere is somewhat daunting prospect.
2) Processing hundreds of MB does not seem impossible, as I have witnessed. Thus it seems you already have all...?

However you have a very valid point that extension request is not exactly an invitation to take a free shot at the poster ;)




I can't see the casual player running over numbers and charts outside the game. I do not simulate or analyse something that already is a simulation, I simply run it. If something goes too wrong, there is the "load" button. If I need to assess some factor, I simply observe. Do the vehicles cluster together? Is another convoy needed? Can I afford constructing something? Sometimes there is some factor, like price, that can be done with a calculator.

If presented in this general way... I see in this idea something else. What would you do with these data anyway? What kind of analysis would you perform? Perhaps that is the part that might be more worthy addition than export itself. If some functionality useful for all can be bundled inside, why take it outside?




Anyway, the things that can be done already:

For all game objects, there is a definition, separate from the program, in a text file, which is later mangled together with picture and turned into something the game can directly use. These data can be easily analysed. If there is a way to get your hands on the text data (which is not really copyright-worthy), you have all you need to calculate speeds etc. You can probably get them if you ask the right person. Just name the pakset you play with and somebody will steer you in the right direction...

Goods prices never change. What changes is speed bonus. Generally income per tile is a function of maximal vehicle speed (constant), good revenue (constant) and bonus speed (variable with year). Thus all you have to do is: look at slowest part of convoy (-> max speed), open goods window and change the number until speed shown there matches. Then the table shows correct revenues for the given speed. This is where some improvement would be possible, by allowing direct input of the speed, instead of bonus multiplier.

Buying/constructing all kinds of things: price per item is shown. To find sum, use a calculator (formula input helps, too) :P

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!