diff options
author | RossTheRoss <msattr@gmail.com> | 2019-03-31 21:43:55 -0500 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-03-31 21:43:55 -0500 |
commit | c25f2f0342e9b8e652aafd56781ee4195d12f1e2 (patch) | |
tree | 87d1154092ebea892ea88289fafb33e20740db89 /ee1301/wk5/hw5_directory | |
parent | Merge branch 'master' of github.com:RosstheRoss/TestingFun (diff) | |
download | homework-c25f2f0342e9b8e652aafd56781ee4195d12f1e2.tar homework-c25f2f0342e9b8e652aafd56781ee4195d12f1e2.tar.gz homework-c25f2f0342e9b8e652aafd56781ee4195d12f1e2.tar.bz2 homework-c25f2f0342e9b8e652aafd56781ee4195d12f1e2.tar.lz homework-c25f2f0342e9b8e652aafd56781ee4195d12f1e2.tar.xz homework-c25f2f0342e9b8e652aafd56781ee4195d12f1e2.tar.zst homework-c25f2f0342e9b8e652aafd56781ee4195d12f1e2.zip |
DO not much really
Diffstat (limited to '')
-rw-r--r-- | ee1301/wk5/hw5_directory/mazeRunner_v1.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ee1301/wk5/hw5_directory/mazeRunner_v1.cpp b/ee1301/wk5/hw5_directory/mazeRunner_v1.cpp index 8e6c3ee..d915549 100644 --- a/ee1301/wk5/hw5_directory/mazeRunner_v1.cpp +++ b/ee1301/wk5/hw5_directory/mazeRunner_v1.cpp @@ -1,4 +1,5 @@ #include <iostream> +#include <iomanip> #include <fstream> #include <string> using namespace std; @@ -6,6 +7,7 @@ using namespace std; const char BLANK = '-'; const char ROBOT = 'X'; const char GOAL = 'O'; +const char WALL = 'W'; const int screen_num_lines = 25; const int lengthX = 10; // for now we only support square boards const int lengthY = 10; // it "should" work with non-square, YMMV @@ -25,6 +27,7 @@ void updateGrid(char board[lengthX][lengthY], int &xPos, int &yPos, char action) int main() { + srand(time(NULL)); char board[lengthX][lengthY] = {0}; int xPos = 0, yPos = 0; @@ -51,9 +54,15 @@ int main() void initBoard(char board[lengthX][lengthY], int &xPos, int &yPos) { for(int curRow=0; curRow < lengthY; curRow++) { for(int curCol=0; curCol < lengthX; curCol++) { - board[curCol][curRow] = BLANK; + if ( (rand() % 5) + 1 == 4 || (rand() % 10) + 1 == 7) { + //Procedural generation is best for a game like this even if it makes the game impossible + board[curCol][curRow] = WALL; + } else { + board[curCol][curRow] = BLANK; + } } } + board[0][0] = GOAL; board[lengthX/2][lengthY/2] = ROBOT; |