void solve() { Zero(ans); Zero(cnt); int r = b - 1; int c = 0; int dir = 0; for (int i = 0; i < b; ++i) for (int j = 0; j < w; ++j) if (maze[i][j] == '0') ++ans[0]; while (true) { while (! can_move(r, c, dir)) dir = move_left(dir); r += dd[dir][0]; c += dd[dir][1]; if (cnt[r][c] <= 4) --ans[cnt[r][c]]; ++cnt[r][c]; if (cnt[r][c] <= 4) ++ans[cnt[r][c]]; if (r == b - 1 && c == 0) break; if (! wall_right(r, c, dir)) dir = move_right(dir); } }
//Done By Daniel(Leader) //check the monster location and the direction they go void monster(COORD& monster1,int& g_idirection) { bool bcollision = false; //check the condition met if(bcollision == false) { if(g_idirection == 0) { //when the condition met if(wall_left(monster1) == true) { bcollision = true; } else { monster1.X--; } } if(g_idirection == 1) { if(wall_right(monster1) == true) { bcollision=true; } else { monster1.X++; } } if(g_idirection==2) { if(wall_down(monster1) == true) { bcollision=true; } else { monster1.Y++; } } if(g_idirection == 3) { if(wall_up(monster1) == true) { bcollision=true; } else { monster1.Y--; } } //check what wall they hit if(wall_up(monster1) == false && wall_down(monster1) == false && wall_left(monster1) == false && wall_right(monster1) == false) { bcollision=true; } if(wall_up(monster1) == false && wall_down(monster1) == false && wall_left(monster1) == false) { bcollision=true; } if(wall_up(monster1) == false && wall_down(monster1) == false && wall_right(monster1) == false) { bcollision=true; } if(wall_up(monster1) == false && wall_left(monster1) == false && wall_right(monster1) == false) { bcollision=true; } if(wall_down(monster1) == false && wall_left(monster1) == false && wall_right(monster1) == false) { bcollision=true; } } //if the monster is going against the wall re-roll the direction if(bcollision == true) { reroll(g_idirection); } }