QcPathPlanner Class
Path searches of all creatures within a budget per tick (decision E-400). More...
| Header: | #include <server/pathing/QcPathPlanner.h> |
Public Functions
| const QcPathCellTable & | cells() const |
| bool | enabled() const |
| int | nodesLastTick() const |
| void | request(QcCreature &mob) |
| qint64 | searches() const |
| int | searchesLastTick() const |
| void | serve(const QcBlockAccess &world, std::span<QcCreature> mobs, const std::function<QcPathRules (const QcCreature &)> &rulesOf) |
| void | setLimits(qint64 nodesPerTick, qint64 nodesPerSearch, qint64 pathLength) |
| int | villagerNodesLastTick() const |
| qsizetype | waiting() const |
Static Public Members
| const int | maxWidening |
| const int | otherCreaturesShare |
Detailed Description
Creatures ask for a path (QcMobNavigator); at the start of the next tick the waiting searches run in the order they were asked for until the next would overrun the tick's node budget (QcServerLimits pathNodesPerTick); the rest wait for the next tick at the front of the queue, so every creature gets its turn. While other creatures wait, villagers' searches use at most all but a quarter of the budget (otherCreaturesShare, decision E-490), except the first villager search of a tick, which always runs. A search expands at most pathNodesPerSearch nodes (a wanderer a quarter of that) and a path keeps at most pathLength waypoints. A budget of 0 switches path finding off: creatures then walk straight at their goals.
Member Function Documentation
const QcPathCellTable &QcPathPlanner::cells() const
Returns the path cells of the blocks.
bool QcPathPlanner::enabled() const
Returns whether searches run at all (a budget per tick above 0).
int QcPathPlanner::nodesLastTick() const
Returns the nodes expanded in the last tick (tests, debug).
void QcPathPlanner::request(QcCreature &mob)
Queues a search for the goal of mob (QcMobPath) unless one is waiting.
qint64 QcPathPlanner::searches() const
Returns the searches run since the start (tests).
int QcPathPlanner::searchesLastTick() const
Returns the searches run in the last tick.
void QcPathPlanner::serve(const QcBlockAccess &world, std::span<QcCreature> mobs, const std::function<QcPathRules (const QcCreature &)> &rulesOf)
Runs the waiting searches of mobs in world within this tick's budget. rulesOf gives the rules of a creature's kind.
void QcPathPlanner::setLimits(qint64 nodesPerTick, qint64 nodesPerSearch, qint64 pathLength)
Sets the budgets: nodesPerTick nodes per tick, nodesPerSearch per search, paths of at most pathLength cells (QcServerLimits).
int QcPathPlanner::villagerNodesLastTick() const
Returns the nodes of villagers' searches among them (measurements of the shared budget, decision E-424).
qsizetype QcPathPlanner::waiting() const
Returns the searches waiting after the last tick.
Member Variable Documentation
const int QcPathPlanner::maxWidening
A search that failed this many times in a row has 2^maxWidening times the nodes of one search (at most a tick's budget); wanderers never widen.
const int QcPathPlanner::otherCreaturesShare
One in this many nodes of the budget is kept for creatures other than villagers while any of them waits.