Advertisement
SuperJedi224

Minelayer Bot

Apr 11th, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. public class Minelayer extends Bot{
  2.     public Minelayer() {
  3.         this.name="Minelayer";
  4.     }
  5.     private int mines;
  6.     private void countMines(int[][] map){
  7.         mines=0;
  8.         if(p.y==63||map[p.x][p.y+1]==-1)mines++;
  9.         if(p.y==0||map[p.x][p.y-1]==-1)mines++;
  10.         if(p.x==0||map[p.x-1][p.y]==-1)mines++;
  11.         if(p.x==63||map[p.x+1][p.y]==-1)mines++;
  12.     }
  13.  
  14.     @Override
  15.     public Action action(int[][] map) {
  16.         countMines(map);
  17.         if(mines==0)return Action.MINE;
  18.         if(p.y<63&&map[p.x][p.y+1]!=-1&&Math.random()>0.14)return Action.DOWN;
  19.         if(p.y>0&&map[p.x][p.y-1]!=-1&&Math.random()>0.13)return Action.UP;
  20.         if(p.x>0&&map[p.x-1][p.y]!=-1&&Math.random()>0.12)return Action.LEFT;
  21.         if(p.x<63&&map[p.x+1][p.y]!=-1&&Math.random()>0.08)return Action.RIGHT;
  22.         return Action.PASS;
  23.     }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement