Beispiel #1
0
 private void initializeBotArray()
 {
     bots = new Robot[botQty];
     for (uint i = 0; i < bots.Length; i++) {
         bots[i] = new Robot(i + 1);
     }
 }
Beispiel #2
0
 private void deploy(Robot curBot)
 {
     if (isValidMove(curBot.X, curBot.Y)) {
         curBot.Deployed = true;
     }
     else {
         string logString = "Robot " + curBot.Id + " not deployed: Coords are out of bounds or collide with a previously activated robot. Continuing to next bot, if applicable.\n";
         missionLog.addEntry(logString);
     }
 }
Beispiel #3
0
        private void followCurrentStepOfDirections(Robot curBot, char step)
        {
            if (step == 'M') {
                int[] proposedCoords = calcNewCoords(curBot.X, curBot.Y, curBot.Heading);

                if (isValidMove(proposedCoords[0], proposedCoords[1])) {
                    curBot.X = proposedCoords[0];
                    curBot.Y = proposedCoords[1];
                }
                else {
                    string logString = "Robot " + curBot.Id + " movement step ignored: Results in collision or go out of bounds. Continuing to next step, if applicable.\n";
                    missionLog.addEntry(logString);
                }
            }
            else {
                curBot.Heading = determineNewFacing(step, curBot.Heading);
            }
        }
Beispiel #4
0
 private void activateRobot(Robot curBot)
 {
     if (curBot.Deployed == false) {
         this.deploy(curBot);
     }
     foreach (char step in curBot.directions) {
         this.followCurrentStepOfDirections(curBot, step);
     }
 }