nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
wander.h
Go to the documentation of this file.
1#ifndef NANOMMO_BOT_WANDER_H_
2#define NANOMMO_BOT_WANDER_H_
3
4#include <chrono>
5#include <limits>
6#include <optional>
7#include <random>
8
9#include "content/monsters.h"
10#include "protocol/nanommo.pb.h"
11#include "terrain/lands.h"
12
13namespace nanommo {
14
15protocol::Input RandomDirection(std::mt19937& random);
16
17std::chrono::milliseconds RandomHold(std::mt19937& random);
18
19/// Somewhere a bot heads for, across the island.
20struct Trip {
21 float to_x = 0.0f;
22 float to_z = 0.0f;
23 float closest = std::numeric_limits<float>::infinity();
24 int stuck = 0;
25 /// How close to the end counts as there, in metres.
26 float there = 3.0f;
27};
28
29/// One of the land's gates, at random, as players go through each of them.
30Place RandomGate(std::mt19937& random, int land);
31
32/// A place within 170 metres of the middle, where most of the island is, or
33/// on one trip in five, the middle of the gate, which takes the bot to
34/// another land, as players go there too.
35Trip RandomTrip(std::mt19937& random, const Place& gate);
36
37/// Running towards the end of the trip, from x and z, or nothing once the bot
38/// is there, or has stopped getting closer.
39std::optional<protocol::Input> Travel(Trip& trip, float x, float z);
40
41/// How far past the edge of a monster's skill on its way a bot keeps, in
42/// metres, so that it doesn't step back in as the skill lands.
43inline constexpr float kClear = 1.0f;
44
45/// Running out of the shape of a monster's skill on its way, while the bot at
46/// x and z is in it, or within kClear of its end, as players learn to:
47/// straight away from the monster, or out of a cone's side, where that's
48/// nearer, as it is in a narrow one. Or nothing, while it's clear of them all.
49std::optional<protocol::Input> StepOut(const MonsterTable& table,
50 const protocol::World& world, float x,
51 float z);
52
53} // namespace nanommo
54
55#endif // NANOMMO_BOT_WANDER_H_
Definition chat.cc:9
Trip RandomTrip(std::mt19937 &random, const Place &gate)
Definition wander.cc:47
std::optional< protocol::Input > Travel(Trip &trip, float x, float z)
Definition wander.cc:60
Place RandomGate(std::mt19937 &random, int land)
One of the land's gates, at random, as players go through each of them.
Definition wander.cc:35
protocol::Input RandomDirection(std::mt19937 &random)
Definition wander.cc:20
std::optional< protocol::Input > StepOut(const MonsterTable &table, const protocol::World &world, float x, float z)
Definition wander.cc:80
constexpr float kClear
Definition wander.h:43
std::chrono::milliseconds RandomHold(std::mt19937 &random)
Definition wander.cc:30
The kinds of monster, by id, and where they spawn.
Definition monsters.h:17
In metres from the middle of a land.
Definition lands.h:13
Somewhere a bot heads for, across the island.
Definition wander.h:20
float there
How close to the end counts as there, in metres.
Definition wander.h:26
float to_z
Definition wander.h:22
float closest
Definition wander.h:23
float to_x
Definition wander.h:21