Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function RaidPlayer(playerController) {
- this.pc = playerController;
- }
- RaidPlayer.prototype = {
- act: function() {
- console.log('Round', this.pc.getGameRound());
- var idx = 0;
- var direction = this.pc.senseDirectionToExit();
- if(this.pc.canMove(direction))
- {
- console.log('trying to move', direction.toString());
- this.pc.move(direction);
- }
- else
- {
- console.log('cannot move');
- if(this.pc.canMove(direction.rotateLeft()))
- {
- console.log('rotating left!');
- direction = direction.rotateLeft();
- this.pc.move(direction);
- console.log('rotated left!');
- }
- else if(this.pc.canMove(direction.rotateRight()))
- {
- direction = direction.Right();
- this.pc.move(direction);
- console.log('rotated right!');
- }
- else
- this.pc.move(direction.randomDirection());
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement