Just a quick update on what I've accomplished.
I now have easy-to-create pathmaps. You can "
subscribe"
entities to pathmaps, and they automatically take care of them during calculation.
I've created (so far) a "
friendly-ground"
pathmap and a "
enemy-ground"
pathmap.
Entities such as Beethro and Stalwarts are subscribed to the "
friendly-ground"
pathmap, and target the "
enemy-ground"
pathmap.
Entities such as roaches and roach-queens do the exact opposite.
I've done some profiling, and the game is acceptably fast on 100x100 rooms, with any amount of entities.
Considering I'm not planning to support rooms that big, it's a success.
I'm thinking to have "
friendly-water"
"
friendly-air"
... and so on pathmaps for the other types of terrain.
Marking a tile (such as force arrows) not pathfindable is as easy as adding a tag to it.
I'm calculating valid tiles (obstacles/not obstacles) directly during the breadth-first search without performance issues. I could optimize this by calculating it once per turn, but it's not needed right now.
I've had some fun creating convoluted mazes where roaches pathfind to stalwarts (well, an even dumber version of stalwarts) and stalwarts pathfind to roaches at the same time. I find this behavior more interesting that the one present in DROD.
I've also kept the jump-point searching in the engine - it may be useful with certain kind of entities (Halph comes to mind), or when I will implement some sort of scripted NPCs (I'm planning to have a "
pathfind to x,y"
command).
I've done a lot of refactorings but I'm still unhappy with the code. I'm using lambda expressions pretty much everywhere. This makes the code easily readable but it's not helping with room serialization, since lambdas aren't serializable in C#. I will have to replace all of them, sadly, or find an alternative to serialization.
TFMurphy wrote:
And vittro, you really should make more of an effort to read through and figure out what the DROD source code is doing. Look up commands if you don't know what they do. Read through the comments in the code, compare what the code says to how things work in game. You're already familiar with programming itself, so this shouldn't be that alien to you.
I've been taking a look at the source code while developing my own engine. My approach is completely different from DROD's approach (I'm adopting a component-based entity system, for example) - but I've found useful code.
While I'm familiar with programming, I've started learning C++ seriously (got a book, doing exercises, etc) only a week ago. I've used managed languages my whole programming lifetime, mainly C#, some Java, some Javascript and some D.
I'm starting to get my head around C concepts like pointers, or C++ concepts like iterators, but they're still sort-of-alien to me (when I see the * and & operators I still have to stop and think about them for a minute).
When I look at the DROD source code it just screams "
messy"
to me. I'm sure, though, that it really isn't messy at all, I just have to get more used to the C++ syntax.
Click here to view the secret text
×
if (abs(static_cast<int>(this->wX - wSX)) <= 1 && abs(static_cast<int>(this->wY - wSY)) <= 1)
messy messy messy
Ah well, back to refactoring.
____________________________
http://vittorioromeo.com
[Last edited by vittro at 06-14-2012 01:54 AM]