[Making a maze game by uisng c++] Hello! First of all, thank you for helping my
ID: 3748571 • Letter: #
Question
[Making a maze game by uisng c++]
Hello! First of all, thank you for helping my stuff.
Actually, I try to make a maze game in using c++.
I have some problems in my code.
["I have to keep my format that function conditions void create_maze(int &row_robot, int &column_robot );
void show_maze(int row_robot, int column_robot);
bool robot_move(int &row_robot, int &column_robot); ]
1) In bool robot_move(int &row_robot, int &column_robot) function, I made a random number but it is not working as well. I will attached my coding result below. As you can see, the Random number is always same.
2) When I run it, I only want to keep only one map, but it showed lots of maps.
3) The robot("X") delete the wall("+") even I made a if condition in bool robot_move() function.
Could you help me how to deal with those issues? I will paste my code below and the result image.
/Users/jeonj iwan/CLionProjects/CIS25/cmake-build-debug/CIS25 RANDOM NUMBER: 3 How many moves: 0 RANDOM NUMBER: 3 How many moves: 1 RANDOM NUMBER: 3 How many moves: 2 RANDOM NUMBER: 3 How many moves: 3 RANDOM NUMBER: 3Explanation / Answer
1) write srand(time(0)); at the top of main function before using random functions. So that you'll get different numbers.
2) write clrscr(); at the top of the show_maze function, it clears the screen every time show_maze is called. So that you'll get only one map.
3) bool robot_move() function is not returning any value, It should return either true or false based on logic. Look at the code and return bool values, your problem gets sorted.
and the #include<string> is not needed in this code. So you can remove it happily.
//I could've made changes to the code and posted but my cpp compilier is showing some warnings like
#error This file requires compiler and library support for the
ISO C++ 2011 standard.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.