10 #include <fmt/format.h> 12 #include <torchcraft/client.h> 24 std::string
curTimeString(
char const* format =
"%Y-%d-%m %H:%M:%S");
26 std::string
commandString(State* s, tc::Client::Command
const& command);
30 return std::string(
"None");
32 return std::string(
"Create");
34 return std::string(
"Move");
36 return std::string(
"Delete");
38 return std::string(
"Gather");
40 return std::string(
"Scout");
42 return std::string(
"Cancel");
44 return std::string(
"Harass");
46 return std::string(
"Flee");
47 case Command::SetCreatePriority:
48 return std::string(
"SetCreatePriority");
49 case Command::ReturnCargo:
50 return std::string(
"ReturnCargo");
52 return std::string(
"MAX");
54 return std::string(
"?");
60 std::ostringstream oss;
68 std::ostringstream oss;
70 oss << (unit->
isMine ?
"Friendly" : unit->
isEnemy ?
"Enemy" :
"Neutral")
75 template <
typename Units>
77 std::ostringstream oss;
79 for (
auto unit : units) {
88 std::ostringstream oss;
89 oss << resources.ore <<
" ore, " << resources.gas <<
" gas, " 90 << resources.used_psi / 2 <<
"/" << resources.total_psi / 2 <<
" psi/2";
95 std::ostringstream oss;
104 std::ostringstream oss;
105 oss <<
"u" <<
id <<
" (";
107 for (
const auto& c : upc->command) {
114 if (upc->command.empty()) {
115 oss <<
"no commands";
126 return {task ? task->getName() :
"No task"};
132 auto uct = tc::BW::UnitCommandType::_from_integral_nothrow(commandType);
133 return uct ? uct->_to_string() :
"???";
139 {tc::BW::Command::DrawLine,
140 a.
x * tc::BW::XYPixelsPerWalktile,
141 a.
y * tc::BW::XYPixelsPerWalktile,
142 b.
x * tc::BW::XYPixelsPerWalktile,
143 b.
y * tc::BW::XYPixelsPerWalktile,
151 {tc::BW::Command::DrawUnitLine, a->
id, b->
id, color},
kRootUpcId);
157 {tc::BW::Command::DrawUnitPosLine,
159 b.
x * tc::BW::XYPixelsPerWalktile,
160 b.
y * tc::BW::XYPixelsPerWalktile,
184 {tc::BW::Command::DrawCircle,
185 a.
x * tc::BW::XYPixelsPerWalktile,
186 a.
y * tc::BW::XYPixelsPerWalktile,
195 {tc::BW::Command::DrawUnitCircle,
210 {tc::BW::Command::DrawText, text, a.
x, a.
y},
kRootUpcId);
216 {a.
x * tc::BW::XYPixelsPerWalktile, a.
y * tc::BW::XYPixelsPerWalktile},
223 const std::vector<std::string>& lines) {
226 for (
auto line : lines) {
227 int lineWidth =
static_cast<int>(kCharacterWidthAvg * line.length());
228 pixelWidth = std::max(pixelWidth, lineWidth);
231 const int x = a.
x - pixelWidth / 2;
232 int y = a.
y - pixelWidth / 2;
234 for (
auto line : lines) {
249 const std::string& text) {
251 {tc::BW::Command::DrawTextScreen,
253 kCharacterWidthMax * (xCharacter + 1),
254 kCharacterWidthMax + yLine * kLineHeight},
269 {unit->
x * tc::BW::XYPixelsPerWalktile,
270 unit->
y * tc::BW::XYPixelsPerWalktile},
271 {commandCpiName, commandBwName, taskName});
276 std::string
const& sourcePath = std::string());
std::string upcTaskString(State *state, UpcId upcId)
Definition: debugging.h:124
Game state.
Definition: state.h:42
T bottom() const
Definition: basetypes.h:221
Command
Abstract "meta" commands for UPCTuples.
Definition: basetypes.h:314
std::string unitsString(Units &&units)
Definition: debugging.h:76
void drawBox(State *state, Position const &a, Position const &b, int color=255)
Definition: debugging.h:166
T right() const
Definition: basetypes.h:215
T y
Definition: basetypes.h:44
std::map< std::string, std::string > gflagsValues(std::string const &sourcePath)
Retrieves current gflags values, optionally restricted to a source file.
Definition: debugging.cpp:95
void drawUnitCommand(State *state, Unit *unit, Command commandCpi, int commandBw, UpcId upcId)
Definition: debugging.h:258
UpcId constexpr kRootUpcId
Definition: basetypes.h:24
void drawTextScreen(State *state, int xCharacter, int yLine, const std::string &text)
Definition: debugging.h:245
std::string curTimeString(char const *format)
Definition: debugging.cpp:107
std::string name
Definition: buildtype.h:44
T left() const
Definition: basetypes.h:212
UnitId id
Definition: unitsinfo.h:36
std::shared_ptr< Task > taskForId(UpcId id) const
Definition: blackboard.cpp:192
Represents a unit in the game.
Definition: unitsinfo.h:35
T top() const
Definition: basetypes.h:218
std::string visualizeHeatmap(torch::Tensor inp)
Definition: debugging.cpp:115
bool isEnemy
Definition: unitsinfo.h:54
constexpr int kLineHeight
Definition: debugging.h:202
Blackboard * board() const
Definition: state.h:99
std::string buildTypeString(BuildType const *buildType)
Definition: algorithms.h:176
void drawLine(State *state, Position const &a, Position const &b, int color=255)
Definition: debugging.h:137
void drawText(State *state, Position const &a, const std::string &text)
Definition: debugging.h:213
std::string upcString(UpcId id)
Definition: debugging.h:94
constexpr int kCharacterWidthMax
Definition: debugging.h:203
void drawTextCenteredLinesPx(State *state, Position const &a, const std::vector< std::string > &lines)
Definition: debugging.h:220
std::string unitString(Unit const *unit)
Definition: debugging.h:65
void killUnit(State *state, Unit *u)
Definition: debugging.cpp:86
void drawTextCenteredPx(State *state, Position const &a, const std::string &text)
Definition: debugging.h:241
constexpr double kCharacterWidthAvg
Definition: debugging.h:205
bool isMine
Definition: unitsinfo.h:53
int PlayerId
Definition: basetypes.h:21
std::string resourcesString(T &&resources)
Definition: debugging.h:87
T x
Definition: basetypes.h:43
Main namespace for bot-related code.
Definition: areainfo.cpp:17
std::string commandBwString(int commandType)
Definition: debugging.h:131
const BuildType * type
Definition: unitsinfo.h:56
void postCommand(tc::Client::Command const &command, UpcId sourceId)
Definition: blackboard.cpp:266
Definition: basetypes.h:41
int x
Definition: unitsinfo.h:37
int UpcId
Definition: basetypes.h:23
void drawTextPx(State *state, Position const &a, const std::string &text)
Definition: debugging.h:208
void spawnUnit(State *state, PlayerId team, BuildType const *typ, Position loc)
Definition: debugging.cpp:66
void drawCircle(State *state, Position const &a, int radius, int color=255)
Definition: debugging.h:182
int y
Definition: unitsinfo.h:38
std::string positionString(Vec2T< T > position)
Definition: debugging.h:59
Vec2T< int > Position
Definition: basetypes.h:178
std::string commandString(State *state, tc::Client::Command const &cmd)
Definition: debugging.cpp:23