33 std::vector<std::string>
code;
56 std::ifstream file(
"trainer.phx", std::ifstream::in);
59 while (std::getline(file, line)) {
65 std::cerr <<
"loadCode() -> file trainer.phx does not exist" << std::endl;
73 std::stack<int> jumps;
74 for (std::vector<std::string>::iterator it =
code.begin(); it !=
code.end(); ++it) {
75 size_t found = it->find_first_of(
" ");
76 if (found != std::string::npos) {
77 std::string type = it->substr(0, found);
78 std::string args = it->substr(found + 1);
79 if (type.compare(
"do") == 0) {
81 jumps.push(address + 1);
84 }
else if (type.compare(
"wait") == 0) {
85 int wait = atoi(args.c_str());
94 }
else if (type.compare(
"change_to") == 0) {
98 }
else if (type.compare(
"say") == 0) {
104 if ((*it).compare(
"recover") == 0) {
108 }
else if ((*it).compare(
"end_do") == 0) {
116 if (jumps.size() > 0) {
117 std::cerr <<
"generateCode() -> " << jumps.size() <<
" loops unclosed" << std::endl;
148 for (std::list<Player*>::iterator it = players.begin(); it != players.end(); ++it) {
149 std::clog <<
" - " << (*it)->getTeam() <<
"(" << (*it)->getUniformNumber() <<
"): [" << ((*it)->getPosition()).toString() <<
"," << ((*it)->getVelocity()).toString() <<
"]";
151 std::clog << std::endl;
159 accums.push(line.
accum);
173 if (accums.top() > 0) {
std::list< Player * > getPlayers()
void changeMode(std::string mode)
Used by Player and Goalie.
void execute(WorldModel world)
Commands The Commans lorem Ipsum
WorldModel The WorldModel lorem Ipsum
static std::string PLAY_MODE
void say(std::string message)
static unsigned int GAME_TIME
std::vector< execution_line > program
std::list< Player > players
Trainer(Commands *commands)
std::vector< std::string > code
static bool TRAINER_LOGGING