-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ai-battle cli #1652
base: master
Are you sure you want to change the base?
Add ai-battle cli #1652
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few remarks to fix compilation
This will likely glitch on Windows though:
`printf("\x1b[%dA", 8 + world_.GetNumPlayers()); // Move cursor back up`
|
||
try | ||
{ | ||
unsigned random_init = std::chrono::high_resolution_clock::now().time_since_epoch().count(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsigned random_init = std::chrono::high_resolution_clock::now().time_since_epoch().count(); | |
auto random_init = static_cast<unsigned>(std::chrono::high_resolution_clock::now().time_since_epoch().count()); |
if(replay_.IsRecording()) | ||
{ | ||
replay_.StopRecording(); | ||
printf("Replay written to %s\n", canonical(replayPath_).c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printf("Replay written to %s\n", canonical(replayPath_).c_str()); | |
bnw::cout << "Replay written to " << canonical(replayPath_) << '\n'; |
save.sgd.MakeSnapshot(game_); | ||
save.Save(path, "AI Battle"); | ||
|
||
printf("Savegame written to %s\n", canonical(path).c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printf("Savegame written to %s\n", canonical(path).c_str()); | |
bnw::cout << "Savegame written to " << canonical(path) << '\n'; |
|
||
#include <boost/filesystem.hpp> | ||
#include <boost/nowide/args.hpp> | ||
#include <boost/nowide/iostream.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <boost/nowide/iostream.hpp> | |
#include <boost/nowide/filesystem.hpp> | |
#include <boost/nowide/iostream.hpp> |
|
||
int main(int argc, char** argv) | ||
{ | ||
bnw::args _(argc, argv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bnw::args _(argc, argv); | |
bnw::nowide_filesystem(); | |
bnw::args _(argc, argv); |
|
||
#include <boost/nowide/iostream.hpp> | ||
|
||
#include <chrono> | ||
#include <sstream> | ||
|
||
std::vector<PlayerInfo> GeneratePlayerInfo(const std::vector<AI::Info>& ais); | ||
std::string ToString(const std::chrono::milliseconds& time); | ||
std::string HumanReadableNumber(unsigned num); | ||
|
||
namespace bfs = bfs; | ||
using bfs::canonical; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <boost/nowide/iostream.hpp> | |
#include <chrono> | |
#include <sstream> | |
std::vector<PlayerInfo> GeneratePlayerInfo(const std::vector<AI::Info>& ais); | |
std::string ToString(const std::chrono::milliseconds& time); | |
std::string HumanReadableNumber(unsigned num); | |
namespace bfs = bfs; | |
using bfs::canonical; | |
#include <boost/nowide/iostream.hpp> | |
#include <chrono> | |
#include <sstream> | |
std::vector<PlayerInfo> GeneratePlayerInfo(const std::vector<AI::Info>& ais); | |
std::string ToString(const std::chrono::milliseconds& time); | |
std::string HumanReadableNumber(unsigned num); | |
namespace bfs = boost::filesystem; | |
namespace bnw = boost::nowide; | |
using bfs::canonical; |
Adds an optional binary that runs headless (no UI) AI battles.
This can be useful when creating training data or testing new AIs.
I'm not sure if this is placed correctly or whether it should even be part of the master branch.
In any case, I would like your feedback on this tool. It aims to reuse as much of s25main as possible in order to create accurate replays.