|
@@ -12,13 +12,14 @@ import java.net.InetAddress;
|
|
|
import java.net.Socket;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.Queue;
|
|
|
+import java.util.concurrent.ConcurrentLinkedQueue;
|
|
|
|
|
|
public class BotGame {
|
|
|
|
|
|
private static boolean respawn = true;
|
|
|
private boolean kill = false;
|
|
|
private boolean switchItharder = false;
|
|
|
- private Queue<String> returnMsgs = new LinkedList<>();
|
|
|
+ private Queue<String> returnMsgs = new ConcurrentLinkedQueue<>();
|
|
|
Object syncer = new Object();
|
|
|
static Logger l = LogManager.getLogger();
|
|
|
private int[] []board = new int[1][1];
|
|
@@ -40,30 +41,8 @@ public class BotGame {
|
|
|
l.info("shizzlemork");
|
|
|
while(true)
|
|
|
{
|
|
|
- l.info("LOOP");
|
|
|
- if(respawn)
|
|
|
- {
|
|
|
- l.info("Respawning");
|
|
|
- respawn=false;
|
|
|
- try {
|
|
|
- Thread.sleep(1);
|
|
|
- } catch (InterruptedException e) {
|
|
|
-// throw new RuntimeException(e);
|
|
|
- }
|
|
|
- try{
|
|
|
- new BotGame().game();
|
|
|
- }
|
|
|
- catch(Throwable t)
|
|
|
- {
|
|
|
- l.info("catch");
|
|
|
- respawn=true;
|
|
|
- }
|
|
|
- }
|
|
|
- try {
|
|
|
- Thread.sleep(1000);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- //throw new RuntimeException(e);
|
|
|
- }
|
|
|
+ l.info("LOOP, spawning new bot");
|
|
|
+ new BotGame().game();
|
|
|
}
|
|
|
}
|
|
|
int lastcase=-1;
|
|
@@ -170,22 +149,28 @@ public class BotGame {
|
|
|
}
|
|
|
|
|
|
public void game(){
|
|
|
- mösenpilze=0;
|
|
|
- möseon=false;
|
|
|
- submöse2=0;
|
|
|
- submöse=0;
|
|
|
- returnMsgs.add("join|Red5|mösenpilze-8=====D-fdewcugewgw");
|
|
|
+ if(System.getProperties().containsKey("botdebug"))
|
|
|
+ {
|
|
|
+ returnMsgs.add("join|Red5-devel|mösenpilze-8=====D-fdewcugeww");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ returnMsgs.add("join|Red5|mösenpilze-8=====D-fdewcugewgw");
|
|
|
+ }
|
|
|
try {
|
|
|
- Socket sck=new Socket("gpn-tron.duckdns.org", 4000);
|
|
|
+ Socket sck=new Socket(InetAddress.getByName("2a0e:c5c1:0:20d:29a9:3142:d2da:33fd"), 4000);
|
|
|
BufferedReader r = new BufferedReader(new InputStreamReader(sck.getInputStream()));
|
|
|
PrintStream out = new PrintStream(sck.getOutputStream(),true,"UTF-8");
|
|
|
- Thread t = new Thread(()->{
|
|
|
+ String jm = returnMsgs.poll();
|
|
|
+ System.out.print(jm+'\n');
|
|
|
+ out.print(jm+'\n');
|
|
|
+ out.flush();
|
|
|
+ //Thread t = new Thread(()->{
|
|
|
while(sck.isConnected())
|
|
|
{
|
|
|
- if(boards==null)
|
|
|
+ if(sck.isClosed())
|
|
|
{
|
|
|
- kill=true;
|
|
|
- respawn=true;
|
|
|
+ return;
|
|
|
}
|
|
|
if(kill)
|
|
|
{
|
|
@@ -205,6 +190,12 @@ public class BotGame {
|
|
|
}
|
|
|
if(ln.contains("lose"))
|
|
|
{
|
|
|
+ if(boards==null)
|
|
|
+ {
|
|
|
+ l.info("Boards nulled?");
|
|
|
+ kill=true;
|
|
|
+ respawn=true;
|
|
|
+ }
|
|
|
String boardview = "\nDumping Core....\nDone:\n";
|
|
|
for(int i=0;i<ch;i++)
|
|
|
{
|
|
@@ -252,7 +243,8 @@ public class BotGame {
|
|
|
boards=new int[h][w];
|
|
|
boardFF=new int[h][w];
|
|
|
headBuffer = new boolean[h][w];
|
|
|
- returnMsgs.add("chat|Red 5 standing by");
|
|
|
+ out.print("chat|Red 5 standing by"+'\n');
|
|
|
+ out.flush();
|
|
|
tickets = new int[h][w];
|
|
|
}
|
|
|
if(ln.contains("pos")&&gaming)
|
|
@@ -376,6 +368,8 @@ public class BotGame {
|
|
|
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*");
|
|
|
+ out.print(returnMsgs.poll()+'\n');
|
|
|
+ out.flush();
|
|
|
l.info("lastdir"+lastDir);
|
|
|
//boolean switcheroo = new File("/home/lh/switch").exists();
|
|
|
|
|
@@ -518,6 +512,8 @@ public class BotGame {
|
|
|
if(highest<10)
|
|
|
{
|
|
|
returnMsgs.add("chat|godmayFUCKingdamnit");
|
|
|
+ out.print(returnMsgs.poll()+'\n');
|
|
|
+ out.flush();
|
|
|
}
|
|
|
switch(rnd)
|
|
|
{
|
|
@@ -568,15 +564,22 @@ public class BotGame {
|
|
|
//headBuffer = new boolean[ch][cw];
|
|
|
l.trace("pc="+playercount);
|
|
|
playercount=0;
|
|
|
- returnMsgs.add("move|"+direction);
|
|
|
+
|
|
|
+ out.print("move|"+direction+'\n');
|
|
|
+ System.out.print("move|"+direction+'\n');
|
|
|
+ out.flush();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ l.info("SCK:");
|
|
|
+ l.info(sck.isClosed());
|
|
|
+ l.info(sck.isConnected());
|
|
|
+ l.info(sck.isInputShutdown());
|
|
|
kill=true;
|
|
|
respawn=true;
|
|
|
- throw new Error();
|
|
|
+ throw new Error();
|
|
|
}
|
|
|
|
|
|
} catch (IOException ex) {
|
|
@@ -587,16 +590,17 @@ public class BotGame {
|
|
|
//l.trace(request);
|
|
|
|
|
|
}
|
|
|
- });
|
|
|
- t.setName("InputCruncher");
|
|
|
- t.start();
|
|
|
- Thread t2 = new Thread(()->{
|
|
|
+ //});
|
|
|
+ //t.setName("InputCruncher");
|
|
|
+ //t.start();
|
|
|
+ /*Thread t2 = new Thread(()->{
|
|
|
//System.out.println("Gefangen!");
|
|
|
try {
|
|
|
while(sck.isConnected())
|
|
|
{
|
|
|
if(kill)
|
|
|
{
|
|
|
+ l.info("time to say goodbye");
|
|
|
return;
|
|
|
}
|
|
|
synchronized(syncer)
|
|
@@ -630,14 +634,17 @@ public class BotGame {
|
|
|
if(submöse2==4)
|
|
|
{
|
|
|
l.trace("Hodentasche");
|
|
|
- kill=true;
|
|
|
- respawn=true;
|
|
|
- sck.close();
|
|
|
- return;
|
|
|
+ submöse2=0;
|
|
|
+ returnMsgs = new ConcurrentLinkedQueue<>();
|
|
|
+ //kill=true;
|
|
|
+ //respawn=true;
|
|
|
+ //sck.close();
|
|
|
+ //return;
|
|
|
}
|
|
|
}
|
|
|
continue;
|
|
|
- }
|
|
|
+ } out.print(returnMsg+'\n');
|
|
|
+ out.flush();
|
|
|
l.trace("PKT="+returnMsg);
|
|
|
out.print(returnMsg+'\n');
|
|
|
out.flush();
|
|
@@ -657,7 +664,7 @@ public class BotGame {
|
|
|
System.exit(1337);
|
|
|
});
|
|
|
t2.setName("OutputCruncher");
|
|
|
- t2.start();
|
|
|
+ t2.start();*/
|
|
|
l.info("asdfqwxix");
|
|
|
}
|
|
|
catch (IOException ex)
|
|
@@ -672,8 +679,8 @@ public class BotGame {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- int submöse2=0;
|
|
|
- int submöse=0;
|
|
|
- boolean möseon=false;
|
|
|
- long mösenpilze = 0;
|
|
|
+ //int submöse2=0;
|
|
|
+ //int submöse=0;
|
|
|
+ //boolean möseon=false;
|
|
|
+ //long mösenpilze = 0;
|
|
|
}
|