Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Minelayer extends Bot{
- public Minelayer() {
- this.name="Minelayer";
- }
- private int mines;
- private void countMines(int[][] map){
- mines=0;
- if(p.y==63||map[p.x][p.y+1]==-1)mines++;
- if(p.y==0||map[p.x][p.y-1]==-1)mines++;
- if(p.x==0||map[p.x-1][p.y]==-1)mines++;
- if(p.x==63||map[p.x+1][p.y]==-1)mines++;
- }
- @Override
- public Action action(int[][] map) {
- countMines(map);
- if(mines==0)return Action.MINE;
- if(p.y<63&&map[p.x][p.y+1]!=-1&&Math.random()>0.14)return Action.DOWN;
- if(p.y>0&&map[p.x][p.y-1]!=-1&&Math.random()>0.13)return Action.UP;
- if(p.x>0&&map[p.x-1][p.y]!=-1&&Math.random()>0.12)return Action.LEFT;
- if(p.x<63&&map[p.x+1][p.y]!=-1&&Math.random()>0.08)return Action.RIGHT;
- return Action.PASS;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement