Advertisement
Guest User

Untitled

a guest
Dec 30th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function RaidPlayer(playerController) {
  2.   this.pc = playerController;
  3. }
  4. RaidPlayer.prototype = {
  5.   act: function() {
  6.    
  7.     console.log('Round', this.pc.getGameRound());
  8.     var idx = 0;
  9.     var direction = this.pc.senseDirectionToExit();
  10.    
  11.     if(this.pc.canMove(direction))
  12.     {
  13.      
  14.       console.log('trying to move', direction.toString());
  15.       this.pc.move(direction);
  16.      
  17.     }
  18.     else
  19.     {
  20.        console.log('cannot move');
  21.        
  22.          if(this.pc.canMove(direction.rotateLeft()))
  23.           {
  24.            console.log('rotating left!');
  25.            direction = direction.rotateLeft();
  26.            this.pc.move(direction);
  27.            console.log('rotated left!');
  28.           }
  29.           else if(this.pc.canMove(direction.rotateRight()))
  30.           {
  31.             direction = direction.Right();
  32.             this.pc.move(direction);
  33.             console.log('rotated right!');
  34.            
  35.           }
  36.           else
  37.           this.pc.move(direction.randomDirection());
  38.           }
  39.   }
  40.   };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement