This is going to be a relatively short post based on how late it has arrived. And while the number of lines may have not increased in such a steady rhythm as before, I have invested a comparable time to tweaking the new scheduling system.
With a a very simple map populated by plants that don't do that much yet, I needed to add something more dynamic. The first step was to add movement. For my movement related needs I used the good old A* algorithm. It is fast and very easy to implement once you understand the way it works. There is no good reason not to use it.
But the hard part was the scheduling algorithm. It is bare bones, but after a lot of tweaking it is capable of looking though the list of available tasks and the list of available dwarfs and tries to match them, plot a course, compute the durations and then "animate" the dwarves so that they move with a good speed and an OK feel to it. And all this while the user can still input some basic commands without pausing the game; in this case one can add new plants to the task list. Here we can see it in action:
Dwarves that are doing something are marked with red. The bottom left dwarf has already picked his assigned plant and is blue again signaling that he is available for other tasks. If I add new plants, he will be the first to work, followed by the rest of the dwarves:
This could have been the perfect opportunity to introduce some videos. Pictured will have a hard time showing you that those five dwarves are walking around and making plants disappear (they claim that they are picking them up and preparing them for stockpiling, but I saw no new food reserves – not implemented yet). Alas, I don't have a video capture program on hand and I'm far too lazy to find a free one on Google at this hour and then mess around with video upload. But it is something for the future.
As you can see in one of the screen shots, there is little panel around the bottom informing you on what you have selected with the mouse. For plants it now has two buttons. I'm thinking to introduce a single "Do it" button for a lot of simple tasks. Naturally, dwarves and buildings will have a lot of options, but for things like plants, trees and cave walls I'll try a default action buttons which designates them for gathering, cutting down or digging.
For the next post, I'll do my best and add the second dwarf related element (the first being the dwarves themselves): digable cave walls. I hope they will enjoy it!
2655 lines of code in 22 files (including data editor)
84.2 KiB (including 20.4 KiB image data)