Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Entities;
- import Map.Location;
- import Map.Map;
- public class FlexBot extends Bot{
- int speed;
- public static final int FAST=5, MEDIUM=3, SLOW=1;
- static int nextID=1;
- public FlexBot(){
- super();
- setLoc(new Location(0,0));
- setID(nextID);
- nextID++;
- speed=SLOW;
- setDir(Directions.RIGHT);
- }
- public FlexBot(Location l, int id, Directions d, int s) {
- super(l, id, d);
- speed=s;
- }
- @Override
- public boolean move(Map m){
- int movesMade=0;
- int turnCount=0;
- while (movesMade<speed&&turnCount<4){
- if(super.move(m)){
- movesMade++;
- turnCount=0;
- }
- else{
- turn();
- turnCount++;
- }
- }
- return movesMade==speed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement