113 lines
2.6 KiB
C++
113 lines
2.6 KiB
C++
#include "api.h"
|
|
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
|
|
int API::mazeWidth() {
|
|
std::cout << "mazeWidth" << std::endl;
|
|
std::string response;
|
|
std::cin >> response;
|
|
return atoi(response.c_str());
|
|
}
|
|
|
|
int API::mazeHeight() {
|
|
std::cout << "mazeHeight" << std::endl;
|
|
std::string response;
|
|
std::cin >> response;
|
|
return atoi(response.c_str());
|
|
}
|
|
|
|
bool API::wallFront() {
|
|
std::cout << "wallFront" << std::endl;
|
|
std::string response;
|
|
std::cin >> response;
|
|
return response == "true";
|
|
}
|
|
|
|
bool API::wallRight() {
|
|
std::cout << "wallRight" << std::endl;
|
|
std::string response;
|
|
std::cin >> response;
|
|
return response == "true";
|
|
}
|
|
|
|
bool API::wallLeft() {
|
|
std::cout << "wallLeft" << std::endl;
|
|
std::string response;
|
|
std::cin >> response;
|
|
return response == "true";
|
|
}
|
|
|
|
void API::moveForward(int distance) {
|
|
std::cout << "moveForward ";
|
|
// Don't print distance argument unless explicitly specified, for
|
|
// backwards compatibility with older versions of the simulator
|
|
if (distance != 1) {
|
|
std::cout << distance;
|
|
}
|
|
std::cout << std::endl;
|
|
std::string response;
|
|
std::cin >> response;
|
|
if (response != "ack") {
|
|
std::cerr << response << std::endl;
|
|
throw;
|
|
}
|
|
}
|
|
|
|
void API::turnRight() {
|
|
std::cout << "turnRight" << std::endl;
|
|
std::string ack;
|
|
std::cin >> ack;
|
|
}
|
|
|
|
void API::turnLeft() {
|
|
std::cout << "turnLeft" << std::endl;
|
|
std::string ack;
|
|
std::cin >> ack;
|
|
}
|
|
|
|
void API::setWall(int x, int y, char direction) {
|
|
std::cout << "setWall " << x << " " << y << " " << direction << std::endl;
|
|
}
|
|
|
|
void API::clearWall(int x, int y, char direction) {
|
|
std::cout << "clearWall " << x << " " << y << " " << direction << std::endl;
|
|
}
|
|
|
|
void API::setColor(int x, int y, char color) {
|
|
std::cout << "setColor " << x << " " << y << " " << color << std::endl;
|
|
}
|
|
|
|
void API::clearColor(int x, int y) {
|
|
std::cout << "clearColor " << x << " " << y << std::endl;
|
|
}
|
|
|
|
void API::clearAllColor() {
|
|
std::cout << "clearAllColor" << std::endl;
|
|
}
|
|
|
|
void API::setText(int x, int y, const std::string& text) {
|
|
std::cout << "setText " << x << " " << y << " " << text << std::endl;
|
|
}
|
|
|
|
void API::clearText(int x, int y) {
|
|
std::cout << "clearText " << x << " " << y << std::endl;
|
|
}
|
|
|
|
void API::clearAllText() {
|
|
std::cout << "clearAllText" << std::endl;
|
|
}
|
|
|
|
bool API::wasReset() {
|
|
std::cout << "wasReset" << std::endl;
|
|
std::string response;
|
|
std::cin >> response;
|
|
return response == "true";
|
|
}
|
|
|
|
void API::ackReset() {
|
|
std::cout << "ackReset" << std::endl;
|
|
std::string ack;
|
|
std::cin >> ack;
|
|
}
|