Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- robot& robot::teleport(int num1, int num2) {
- int moves = 0;
- do moves = rand() % num2 - rand() % num1;
- while (moves == 0);
- (*this).print(); std::cout << " tp ";
- if (_my_position.X + moves >= _my_labirint.x_size() ||
- _my_position.Y + moves >= _my_labirint.y_size() ||
- _my_position.Z + moves >= _my_labirint.z_size())
- {
- std::cout << " no tp: target is on the border" << std::endl;
- return (*this);
- }
- if (_my_labirint.isBusy(_my_position.X + moves, _my_position.Y + moves, _my_position.Z + moves)) {
- std::cout << " no tp: target cell is busy" << std::endl;
- return (*this);
- }
- _my_position.X += moves;
- _my_position.Y += moves;
- _my_position.Z += moves;
- std::cout << " -> "; (*this).print(); std::cout << std::endl;
- if (_my_labirint.isExit(_my_position.X, _my_position.Y, _my_position.Z)) {
- if (std::find(_visited_exits.begin(), _visited_exits.end(), _my_position) == _visited_exits.end()) {
- _visited_exits.push_back(_my_position);
- std::cout << "EXIT IS FOUND!!! " << '(' << _my_position.X << ',' << _my_position.Y << ',' << _my_position.Z << ')' << std::endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement