Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Chaingun

Pages: [1]
1
DF Adventure Mode Discussion / Re: Re-Populated towns
« on: March 18, 2012, 04:19:42 am »
I suspect a more boring but accurate theory is DF wouldn't be able to store the whole world population on disk, so the underlings get thrown out of memory on every fast travel. :/

2
DF Suggestions / Re: multithreading
« on: May 03, 2009, 12:33:55 pm »
Quote
while(true) {
Start A();
Start B();
Wait for A() to finish;
Wait for B() to finish;
Any processing needed to put everything together;;
}

Essentially, yes, you can do this IF you start off by designing your entire application with such parallelization in mind.

At the beginning of the frame you need to assign work every thread. Then you need to make sure is that the world state is not written to by any thread while they're running in parallel. All results computed by a thread need to be stored until all threads are finished; then the results need to be applied in a world write pass at the end of the frame run in serial on the coordinating thread.

Looking like this in complete & unrealistically simple pseudo-code:
Code: [Select]
PROC DO_FRAME:
   WORK = DIVIDE_WORK(WORLD, THREAD_COUNT)
   RESULTS = EXECUTE_AND_WAIT_FOR_WORKER_THREADS(WORLD, WORK)
   WRITE_RESULTS_AND_VERIFY(WORLD, RESULTS)

NOTE: The big ass problem here is when computations inside worker threads depend on intermediate results calculated by other threads. One must use algorithms  dependent on only the last frame's data with this scheme. This is pretty much an unrealistic assumption for a game that wasn't coded with parallel execution in mind...

As for assigning work to each thread; that's not a trivial task. You want such an equal workload as possible. If one thread takes long time to compute its assigned work, all others threads will be idle waiting for this last one to finish. In game terms, you can try to assign certain tile ranges to various threads (though I don't think this'd work very well given that a fort is contrated in a small area of a map). You can try split object update lists (each thread A compute 33 of 100 dwarves, B 33, C 34).

Note that there's an important non-parallel stage; application of results. This also must resolve conflicts to maintain internal consistency (example: "Dwarf A tries to marry dwarf B in the same frame as dwarf C tries to marry A", assuming monogamy). Furthermore, in these kinds of games, a huge amount of data may be modified (for instance water may have flowed all over the map affecting every tile). Like Amdahl's law tells us the entire frame computation will be delayed by this stage if it's slow, so a large set of resuls may ruin performance.

Then there's the option which I see discussed a lot above; to "outsource" computations like pathing to worker threads, doing main updating in a single thread. Of course, that means timing will primarily depend on that single thread, but if 90% of computations are pathing related that'd still mean a great improvement. ;)

Code: [Select]
...double buffering...
While that's nice in it's own way, that implies you don't have a separate result buffer for each thread, instead requiring each thread to obtain a lock when writing to the common output buffer. These locks will occur in an arbitrary order... Threads trying to acquire lock at same time will be waiting to output their results also; then again, there's no special world write stage in this scheme which may compensate. An advantage is that you use the same type of data structure for output as for input, and don't have to write special structures for partial buffered thread output.

Writes occuring in an arbitrary order is not impossible to deal with, but there are definately downsides as well as upsides with this approach.

3
DF General Discussion / Re: What turns you off about DF?
« on: April 27, 2009, 10:33:59 pm »
I find the lack of indication of what to do the hardest thing to deal with.

Make a tutorial (accessable from main menu & using a preloaded map) where one command at a time is introduced (everything else hidden until it appears for first time), in the order you'd use these commands to make a simple functioning fortress...

Examples of order of introduction:

1. Teach how to look around in 3D with the default view and with the with v, u views.
2. Teach how to dig. (Including stairs.)
3. Teach how to designate food stockpile indoors.
4. Teach how to designate meeting hall inside.
5. Teach how to set up mason and carpentry workshops.
6. Teach how to manage labour.
etc.

My other major inital hurdle was (surprise surprise), the lack of mouse support. A complex micromanagement strategy game is NOT cool without it...

-----------

I find the biggest long term obstacle for my enjoyment of the game to be the fact it's ridiculously easy after a certain point. Enemies aren't equipped to deal with hitech dwarven defences; traps are overpowered. Economy is endless; just trade those worthless rock crafts with the caravans; the merchants will not adjust the price according to the laws of economics. There aren't enough design considerations for a fort (having to deal with ventilation & proper cave in risk for poorly unsupported sections would be start). As it is right now you can just dig out a big square space and place most of your buildings there, with some exceptions.

Pages: [1]