Friday, April 15, 2011

pre-alpha-2 – 3 – Be done with it, would you kindly

I declare pre-alpha-2 done! Here is a short description of the cleanup process and two new features.

It has been a while since my last post. The primary reason is that the amount of work on DwarvesH was so much that I couldn't fit it in the Tuesday-ish posting window. The secondary reason is that this was a very busy week at work and in some days after getting home I was in no mood to do any kind of work.

The cleanup process went well and I have a healthy foundation with which I can boldly enter the final development stages for 0.1 version. The transition form 2D to 3D coordinates is 95% done. I am only going to be able to do the final 5% once I actually start doing 3D path finding. The floor system refactoring is not done, but I have abstracted it away so once I do it I will not have to modify the filters again. And countless smaller changes here and there, including a complete isolation of Irrlicht in a few key locations and the rest of the code is graphics library agnostic now.

The first new feature is a new time compression algorithm. The old one had a lot of problems. First, it looked strange. Second, it was far to aggressive. If you wanted to be very efficient you would have to pause the game and issue all the order that you would like to be executed at once or risk not having a chance to enter them again until a few hours of in game time have passed. Let us take the longest operation, sculpture sculpting, as an example. This takes 8 hours. but with the old algorithm, you had until your dwarf walks to the stone to enter new commands or pause and enter new commands. Because once the dwarf has reached his destination, if no other shorter task were queued and ready to be executed, there was a good chance that the task would be finished in a single frame render operation. So no time to react. The new system is still fast, but considerably slower and less aggressive. Long tasks are executed incrementally while still increasing the rate at which time passes. With the new system, sculpting a stone if this is the only task available does not take 10-20 ms, it takes around 9 seconds (plus the walking time). So you have plenty of time to react. Even if you do not reach fast enough, you will not loose 8 hours in which dwarves loose energy while idling, you loose a few minutes of in game time. The new system feels a lot better and you get a feeling for how long tasks actually take. Another advantage is that the old system was a love it or hate it algorithm, with its "feel" "hard-coded" in the specifics of the algorithm, the operations it was doing. The new system has several tweakable variables that it takes into consideration, and this will allow me to create a time scale slider in game. some people may like it fast, but others maybe would like to a very slow game that does not require pausing for any task. The slider will accommodate all these playing styles. Until I add the slider, I have defaulted the values to a fairly fast pace, but still manageable. There will a lot of trial and error before I figure out the right values for these variables so I am 100% happy with the feel of the game and its time passage. Also, the new algorithm allows a turbo mode, where walking happens at lightning pace (and everything else is very fast). This option is only useful on highly automated fortresses that are working on a mega project and you do not want to wait hours for your dwarves to finish.

I created a final stress test video. Here, I test path finding to fairly distant objects. In previous video, path finding was over short distances because stones were close to each other, and the only long distance walk was between to stones and the beds. But in this new video I am selecting every available plant, followed by every available tree for harvesting/cutting. I also test how much of a massive plant murder operation can be done with 150 dwarves in a day before they all need to go to bed. In this video I am using the new time compression algorithm. Please check it out and tell me what do you think about the new algorithm and the feel of time passage:



The second new feature is canceling. You can select an area, press "C" and all designated actions in hat area are canceled. This operation will not cancel task that are in progress, only tasks that are in the queue. So you can cancel a task only before a dwarf has started working on it. This is intentional. The operation is a little bit aggressive, as it will cancel everything. In the future I would like to add a window that pops up and asks you which taks do you want to cancel if the area includes several different task categories.

5 comments:

  1. that looks very effficent. How do the dwarves determine which task to do next? do they choose the nearest available task, or is there a hierarchy of importance?

    How do you envision this working in the finished product?

    You asked how the passage of time feels... I think that you've got it just right. The speed was probably faster then I'd play the game at, but the ration or travel to work time felt about right.

    ReplyDelete
  2. Yes, there is a hierarchy of importance. Each task has a priority, based on its length for now. A dwarf will try to choose the most important task, and if multiple tasks with the same importance are available, he will try to choose the closest one. This generally works fine, but some times an awkward (read mathematically pleasing but looking strange when viewed as a path by human eyes; counter intuitive path) choice is taken and I have some ideas on how to improve this.

    So if a low importance task is near, and a high importance task is far, the dwarf will go for the important one.

    I am considering making the priorities available so you can change the relative importance of tasks in an in-game window. Think of it as the expedition leader giving the order that from now on the fortress focuses on a given task.

    Another factor is labor and equipment. This is why sometimes a dwarf ignores an important task near him and another dwarf needs to walk a distance to get there: because the first dwarf has that labor dissembled or does not have the right tools or skill. This is not that important yet, but as the complexity of the game increases, this will come into play more.

    ReplyDelete
  3. You done a very big work, respect ;)
    Do you think for launching alpha or demo soon?

    ReplyDelete
  4. Go go power ranger

    ReplyDelete
  5. Regarding launching anything available to the public, the information in http://dwarvesh.blogspot.com/2011/03/release-schedule.html is still fairly up to date.

    ReplyDelete