Friday, April 24, 2009

Plague 3.31 update

I fixed the mem leak, but I didnt add the cleanup code to the game, just the test environment (Whoops!). This release of 3.31 removes the major mem leaks from the battle scenario as well.

Thursday, April 23, 2009

Plague 3.31

  • Fixed mem leak
  • garbage collection debugging code added by Droid - thanks!

Sunday, April 12, 2009

Plague 3.30

  • Changed shadowing algorithm - removed artifacts, nice clean code
  • bugfix: shrubs now leave behind burnt shrubs when burnt - not sure when I broke this
  • bugfix: AI sims try to pick up guns (again)
  • bugfix: AI sims now switch weapons if they run out of ammo (again)
  • tidied for world.add_sim so that force is used where appropriate, and other checks removed
  • added a key (j) so you can see the new shadow maps - I think they are kinda cool  (and they were good for debugging) .

Saturday, April 11, 2009

Plague 3.29

This is a minor bug fix for the current shadowing algorithm to remove some pretty common artifacts. It would be possible (and easy) to make sure there are no artifacts by blindly recalculating everything from scratch whenever something changes, but thats computationally expensive, so I have tried to do something more selective but this can (and does) lead to artifacts. In doing this and accounting for all the weird and wonderful things that can go wrong I have learnt three things:
  1. The code is becoming ugly due to all the checks
  2. There are an arbitrary number of things that can go wrong, so there will ALWAYS be artifacts
  3. A fundamental re-design is required somewhere
I have decided on the redesign. I can change from using "sets" to "dicts" to store shadow info and this should lead to no artifacts (by adding shadow "depth" to each square instead of just seeing if it is in shadow). I will start coding that up now, but I thought I'd put up a minor fix to the current shadow algorithm.

One of the neat new things that shadow depth can do is differentiate between "completely visible" and "completely occluded", so Plague will be able to have things like smoke/bushes that gradually blocks LOS. Thats going to be pretty sweet. 

It's actually been really good having these artifacts since it never would have occured to me to come up with this new implementation if I hadnt had to tackle them, and Plague likely never would have gotten partial occlusion. I was chatting with Tom Forsyth a few months back and he asked me if Plague could have partial line of sight through shrubs, and I said it would probably lead to spaghetti code (which is what I have now anyway due to artifact removal) or a redesign (which I wasnt keen on since I had no idea how to redesign it better at that time) and so I stored that idea in the "too hard basket". It's funny how things work out. I'm also now wondering if my new "additive" shadow solution is fairly well known to the games industry... anyone know?
  • Changed the way the game checks for the addition and removal of shadows. 

Friday, April 10, 2009

Plague 3.28 released

Details in previous post.

Wednesday, April 8, 2009

Plague Line of Sight

So I was talking with a friend, Rowan, and he suggested that I store line of sight data on the grid instead of calculating it for sims. This is an obviously good idea so I've been spending my evenings coding that up. 

It's done now, and Plague is substantially faster than before - to put some numbers behind that, I used to get about 3fps with 400 sims, now I get 14fps.
The grid code has also been substantially tidied up which is nice because it used to be a bit convoluted. I'll be tidying up the remaining parts of the code tomorrow night. I'll upload v3.28 when thats done. 

After that I'll retackle the problem again seeing how much I can pre-calculate and store as a data file so that calaculations at runtime are minimised. I'll also add an option (in the options menu) to calculate map LOS during map startup - at the moment stuff is only calculated on an as needed basis, which is nice, but pre-calculating leads to the fastest Plague experience when you are playing. 

Friday, April 3, 2009

Plague 3.28

I've finished the new LOS algorithm based on squares as opposed to sims. Plague is faster now in general, and realtime calcs can be made pretty small by precalculating the majority of the level (as level geometry is relatively static in comparison to the number of movings sims). Theres also more options in the menu options and some other minor tweaks.
  • New LOS algorithm that is more speedy and much more flexible (bug reports welcome!)
  • Weapon recock bar now only shows for "manual" weapons.
  • Shotgun is now more like a double-barrelled shotgun to provide weapon differentiation.
  • You can now pick the screen resolution you want (yes, you can enter non-integer values...)
  • You can now pick the volume you want (only in the options menu though for now)
  • Shrubs now only partially block sight as opposed to rock which fully block sight.
  • Added an option in the options menu to pre-calc Line of Sight (takes some initial time, but Plague is fast after that).  
    1. A max sight radius of 15 takes 30 seconds on my computer, max sight radius of 30 takes 386 seconds (youch!). Theres still an ocassional slowdown, not sure why, help tracking this down would be appreciated. 
    2. I've just done a bunch more precalculation, now the LOS pre-calcs takes 74 seconds for a max sight radius of 15. Hmmm. The precalc time is kinda annoying now.
    3. Further improvements around precalculation to come like pre-calcing all combinations and storing results in a file. 
    4. Suggestions welcome!