|
@@ -7,12 +7,10 @@ import org.apache.logging.log4j.LogManager;
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
import org.apache.logging.log4j.core.LoggerContext;
|
|
|
import org.apache.logging.log4j.core.config.LoggerConfig;
|
|
|
-import org.yaml.snakeyaml.Yaml;
|
|
|
|
|
|
import javax.swing.*;
|
|
|
import java.io.*;
|
|
|
import java.net.Socket;
|
|
|
-import java.nio.charset.Charset;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.Queue;
|
|
|
|
|
@@ -24,7 +22,8 @@ public class BotGame {
|
|
|
private int[] []board = new int[1][1];
|
|
|
int[][] boards;
|
|
|
int[][] boardFF;
|
|
|
- int fuck = 0;
|
|
|
+ int ticksSinceStart = 0;
|
|
|
+ int[][] tickets = null;
|
|
|
boolean danger = false;
|
|
|
private int cx=0,cy=0,cw=1,ch=1;
|
|
|
private String playerid;
|
|
@@ -41,39 +40,67 @@ public class BotGame {
|
|
|
}
|
|
|
int lastcase=-1;
|
|
|
|
|
|
- private int boardFF(int x, int y,int id)
|
|
|
+ private int boardFF(int x, int y, int id)
|
|
|
{
|
|
|
- if(boardFF[y][x]!=0)
|
|
|
+ return boardFF(x,y,id,0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Queue<int[]> FFQueue = new LinkedList<>();
|
|
|
+ private int boardFF(int x, int y,int id,int g)
|
|
|
+ {
|
|
|
+ FFQueue.add(new int[]{x,y,g});
|
|
|
+ return boardFF(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ private int boardFF(int id)
|
|
|
+ {
|
|
|
+ int rv_r=0;
|
|
|
+ while(!FFQueue.isEmpty())
|
|
|
{
|
|
|
- if(boardFF[y][x]>0&&boardFF[y][x]!=id)
|
|
|
+ int rv=0;
|
|
|
+ int[] ffq = FFQueue.remove();
|
|
|
+ int x=ffq[0];
|
|
|
+ int y=ffq[1];
|
|
|
+ int g=ffq[2];
|
|
|
+ if(boardFF[y][x]!=0)
|
|
|
+ {
|
|
|
+ if(boardFF[y][x]>0&&boardFF[y][x]!=id&&g==0)
|
|
|
+ {
|
|
|
+ l.info("1337#d");
|
|
|
+ rv_r += -1337;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ rv_r+=0;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ rv = 2 ;
|
|
|
+ int cni = y-1;
|
|
|
+ if(cni==-1)
|
|
|
+ cni=ch-1;
|
|
|
+ int csi=(y+1)%ch;
|
|
|
+
|
|
|
+ int cwi = x-1;
|
|
|
+ if(cwi==-1)
|
|
|
+ cwi=cw-1;
|
|
|
+ int cei=(x+1)%cw;
|
|
|
+ if(headBuffer[y][cwi]||headBuffer[y][cei]||headBuffer[csi][x]||headBuffer[cni][x])
|
|
|
{
|
|
|
- l.info("1337#d");
|
|
|
- return -1337;
|
|
|
+ rv_r+= g==0?1:0;
|
|
|
+ continue;
|
|
|
}
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ boardFF[y][x]=id;
|
|
|
+ if(g<15) {
|
|
|
|
|
|
- int rv = 2 ;
|
|
|
- int cni = y-1;
|
|
|
- if(cni==-1)
|
|
|
- cni=ch-1;
|
|
|
- int csi=(y+1)%ch;
|
|
|
-
|
|
|
- int cwi = x-1;
|
|
|
- if(cwi==-1)
|
|
|
- cwi=cw-1;
|
|
|
- int cei=(x+1)%cw;
|
|
|
- if(headBuffer[y][cwi]||headBuffer[y][cei]||headBuffer[csi][x]||headBuffer[cni][x])
|
|
|
- {
|
|
|
- return 1;
|
|
|
+ FFQueue.add(new int[]{x, cni, g + 1});
|
|
|
+ FFQueue.add(new int[]{x, csi, g + 1});
|
|
|
+ FFQueue.add(new int[]{cwi, y, g + 1});
|
|
|
+ FFQueue.add(new int[]{cei, y, g + 1});
|
|
|
+ }
|
|
|
+ rv_r+=rv;
|
|
|
}
|
|
|
- boardFF[y][x]=id;
|
|
|
- rv+=boardFF(x,cni,id);
|
|
|
- rv+=boardFF(x,csi,id);
|
|
|
- rv+=boardFF(cwi,y,id);
|
|
|
- rv+=boardFF(cei,y,id);
|
|
|
-
|
|
|
- return rv;
|
|
|
+ return rv_r;
|
|
|
}
|
|
|
|
|
|
static void setupLogging(boolean verbose,int verbosityLevel)
|
|
@@ -146,24 +173,27 @@ public class BotGame {
|
|
|
String boardview = "\nDumping Core....\nDone:\n";
|
|
|
for(int i=0;i<ch;i++)
|
|
|
{
|
|
|
+ String secondaryline = "";
|
|
|
for(int j=0;j<cw;j++)
|
|
|
{
|
|
|
boolean self =false;
|
|
|
if(i==cy&&j==cx)
|
|
|
{
|
|
|
self=true;
|
|
|
- boardview+="XXX";
|
|
|
+ boardview+="XXXX";
|
|
|
}
|
|
|
String number ="000"+boards[i][j]+"|";
|
|
|
+ String ticket = "000"+tickets[i][j]+"|";
|
|
|
String hbfr = headBuffer[i][j]?"#":"_";
|
|
|
if(self)
|
|
|
{
|
|
|
hbfr=debugdir;
|
|
|
}
|
|
|
boardview+=hbfr+
|
|
|
- number.substring(number.length()-3,number.length());
|
|
|
+ number.substring(number.length()-4,number.length());
|
|
|
+ secondaryline+=ticket.substring(ticket.length()-5,ticket.length());
|
|
|
}
|
|
|
- boardview+="\n";
|
|
|
+ boardview+="\n"+secondaryline+"\n";
|
|
|
}l.info("LOSER!!!1111elf");
|
|
|
l.info(boardview+"\nEnd of Dump");
|
|
|
|
|
@@ -174,7 +204,8 @@ public class BotGame {
|
|
|
{
|
|
|
|
|
|
gaming=true;
|
|
|
- fuck=0;
|
|
|
+ ticksSinceStart =0;
|
|
|
+
|
|
|
lastcase=-1;
|
|
|
l.info(ln);
|
|
|
String[] ls = ln.split("\\|");
|
|
@@ -187,6 +218,7 @@ public class BotGame {
|
|
|
boardFF=new int[h][w];
|
|
|
headBuffer = new boolean[h][w];
|
|
|
returnMsgs.add("chat|Red 5 standing by");
|
|
|
+ tickets = new int[h][w];
|
|
|
}
|
|
|
if(ln.contains("pos")&&gaming)
|
|
|
{
|
|
@@ -215,7 +247,7 @@ public class BotGame {
|
|
|
boardFF[cni][cei]=-1;
|
|
|
boardFF[csi][cwi]=-1;
|
|
|
boardFF[csi][cei]=-1;
|
|
|
-
|
|
|
+ tickets[h][w]= ticksSinceStart;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -231,12 +263,12 @@ public class BotGame {
|
|
|
{
|
|
|
int death = Integer.valueOf(lns[k])+1;
|
|
|
l.info("wiping"+death);
|
|
|
- for(int i=0;i<cw;i++) {
|
|
|
- for (int j = 0; j < ch; j++) {
|
|
|
+ for(int i=0;i<ch;i++) {
|
|
|
+ for (int j = 0; j < cw; j++) {
|
|
|
if(boards[i][j]==death)
|
|
|
{
|
|
|
boards[i][j]=0;
|
|
|
-
|
|
|
+ tickets[i][j]=-ticksSinceStart;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -260,39 +292,16 @@ public class BotGame {
|
|
|
cwi=cw-1;
|
|
|
int cei=(j+1)%cw;
|
|
|
|
|
|
- board[i][j]=0; //wi
|
|
|
- //l.info(i+"|"+cni+"|"+csi+"|");
|
|
|
- boolean denseField = (boards[cni][j]!=0&&boards[csi][j]!=0);
|
|
|
- denseField |= (boards[cwi][j]!=0&&boards[cei][j]!=0);
|
|
|
-
|
|
|
- denseField |= (boards[cni][j]!=0&&boards[cei][j]!=0);
|
|
|
- denseField |= (boards[cei][j]!=0&&boards[csi][j]!=0);
|
|
|
- denseField |= (boards[csi][j]!=0&&boards[cwi][j]!=0);
|
|
|
- denseField |= (boards[cwi][j]!=0&&boards[cni][j]!=0);
|
|
|
- if(denseField)
|
|
|
- {
|
|
|
- // l.info("Dense spot...");
|
|
|
- //board[i][j]=1;
|
|
|
- }
|
|
|
- boolean denserField = false;
|
|
|
- denserField |= (boards[cni][j]!=0&&boards[cei][j]!=0&&boards[csi][j]!=0);
|
|
|
- denserField |= (boards[cei][j]!=0&&boards[csi][j]!=0&&boards[cwi][j]!=0);
|
|
|
- denserField |= (boards[csi][j]!=0&&boards[cwi][j]!=0&&boards[cni][j]!=0);
|
|
|
- denserField |= (boards[cwi][j]!=0&&boards[cni][j]!=0&&boards[cei][j]!=0);
|
|
|
- if(denserField)
|
|
|
- {
|
|
|
- // l.info("Dense spot...");
|
|
|
- //board[i][j]=2;
|
|
|
- }
|
|
|
+ board[i][j]=0;
|
|
|
board[i][j]+=(boards[i][j]!=0)?10:0;//||(boards[cni][j]!=0&&boards[csi][j]!=0)||(boards[i][cwi]!=0&&boards[j][cei]!=0));
|
|
|
boardFF[i][j]=(boards[i][j]!=0)?-1:0;//||(boards[cni][j]!=0&&boards[csi][j]!=0)||(boards[i][cwi]!=0&&boards[j][cei]!=0));
|
|
|
if(j==cx&&i==cy)
|
|
|
{
|
|
|
- boardview+="X";
|
|
|
+ //boardview+="X";
|
|
|
}
|
|
|
- boardview+=boardFF[i][j]+";"+boards[i][j]+"|";
|
|
|
+ //boardview+=boardFF[i][j]+";"+boards[i][j]+"|";
|
|
|
}
|
|
|
- boardview+="\n";
|
|
|
+ //boardview+="\n";
|
|
|
}
|
|
|
int cn = cy-1;
|
|
|
if(cn==-1)
|
|
@@ -314,8 +323,8 @@ public class BotGame {
|
|
|
lastcase=3;
|
|
|
}
|
|
|
int west=0,east=0,south=0,north=0;
|
|
|
- if(fuck>0) {
|
|
|
- if(fuck<0)
|
|
|
+ if(ticksSinceStart >0) {
|
|
|
+ if(ticksSinceStart <0)
|
|
|
{east = boardFF(ce, cy,1);
|
|
|
west = boardFF(cw_, cy,2);
|
|
|
|
|
@@ -328,17 +337,9 @@ public class BotGame {
|
|
|
//int rnd=(fuck/13)%4;
|
|
|
|
|
|
int rnd=lastDir;
|
|
|
- if(fuck<15||fuck%100==0||new File("/home/lh/random").exists())
|
|
|
- {
|
|
|
- //rnd = (int) (Math.random()*4);
|
|
|
- }
|
|
|
- if(fuck<10)
|
|
|
- {
|
|
|
- //rnd=3;
|
|
|
- }
|
|
|
- if(fuck%100==0) returnMsgs.add("chat|All Hail the User!!!!!!");
|
|
|
- if(fuck%100==50) returnMsgs.add("chat|Red 5 standing by");
|
|
|
- if(fuck%100==75) returnMsgs.add("chat|rm -rf ~/botarmee*");
|
|
|
+ if(ticksSinceStart %100==0) returnMsgs.add("chat|All Hail the User!!!!!!");
|
|
|
+ if(ticksSinceStart %100==50) returnMsgs.add("chat|Red 5 standing by");
|
|
|
+ if(ticksSinceStart %100==75) returnMsgs.add("chat|rm -rf ~/botarmee*");
|
|
|
l.info("lastdir"+lastDir);
|
|
|
//boolean switcheroo = new File("/home/lh/switch").exists();
|
|
|
|
|
@@ -386,7 +387,7 @@ public class BotGame {
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
- if(fuck<30) {
|
|
|
+ if(ticksSinceStart <30) {
|
|
|
south = boardFF(cx, cs,1);
|
|
|
north = boardFF(cx, cn,2);
|
|
|
|
|
@@ -395,15 +396,15 @@ public class BotGame {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- fuck++;
|
|
|
+ ticksSinceStart++;
|
|
|
|
|
|
int highest=Math.max(Math.max(north,south),Math.max(west,east));
|
|
|
|
|
|
l.info("hnesw"+highest+";"+north+";"+east+";"+south+";"+west);
|
|
|
- if(((fuck<20||(fuck>40&&fuck<60)||(500+fuck-330)%500<30)||(playercount<3&&(fuck%100<50)))&&highest>1000)
|
|
|
+ if(((ticksSinceStart <20||(ticksSinceStart >40&& ticksSinceStart <60)||(500+ ticksSinceStart -330)%500<30)||(playercount<3&&(ticksSinceStart %100<50)))&&highest>1000)
|
|
|
{
|
|
|
- l.info(fuck<20);
|
|
|
- l.info(((500+fuck-330)%500)<30);
|
|
|
+ l.info(ticksSinceStart <20);
|
|
|
+ l.info(((500+ ticksSinceStart -330)%500)<30);
|
|
|
l.info("remappingparty");
|
|
|
if(east==-1337)
|
|
|
east=highest;
|
|
@@ -431,10 +432,10 @@ public class BotGame {
|
|
|
{
|
|
|
l.info("Switcheroo zone reached");
|
|
|
|
|
|
- if(fuck%10==0)
|
|
|
+ if(ticksSinceStart %10==0)
|
|
|
{
|
|
|
l.info("chkFlick");
|
|
|
- if((fuck/10)%3<2)
|
|
|
+ if((ticksSinceStart /10)%3<2)
|
|
|
{
|
|
|
l.info("flick");
|
|
|
switcheroo=!switcheroo;
|
|
@@ -442,9 +443,9 @@ public class BotGame {
|
|
|
}
|
|
|
}
|
|
|
l.info("switcheroo="+switcheroo);
|
|
|
- l.info("fnesw"+fuck+";"+north+";"+east+";"+south+";"+west);
|
|
|
+ l.info("fnesw"+ ticksSinceStart +";"+north+";"+east+";"+south+";"+west);
|
|
|
int rnd=(int)(Math.random()*4);
|
|
|
- if(fuck%300<25&&fuck>15)
|
|
|
+ if(ticksSinceStart %300<25&& ticksSinceStart >15)
|
|
|
{
|
|
|
rnd=0;
|
|
|
}
|
|
@@ -549,15 +550,14 @@ public class BotGame {
|
|
|
{
|
|
|
synchronized(syncer)
|
|
|
{
|
|
|
- try {
|
|
|
- Thread.sleep(50);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
//l.trace("MSG sent");
|
|
|
while(!returnMsgs.isEmpty())
|
|
|
{
|
|
|
String returnMsg = returnMsgs.poll();
|
|
|
+ if(returnMsg == null)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
l.trace("PKT="+returnMsg);
|
|
|
out.print(returnMsg+'\n');
|
|
|
out.flush();
|