Explorar el Código

algo tweaks of GPN bot

LH hace 1 año
padre
commit
3b8a4c41b6
Se han modificado 1 ficheros con 140 adiciones y 47 borrados
  1. 140 47
      QuickStuff/src/main/java/GPN/BotGame.java

+ 140 - 47
QuickStuff/src/main/java/GPN/BotGame.java

@@ -25,11 +25,15 @@ public class BotGame {
     int[][] boards;
     int[][] boardFF;
     int fuck = 0;
+    boolean danger = false;
     private int cx=0,cy=0,cw=1,ch=1;
     private String playerid;
+    int playercount = 0;
     boolean[][] headBuffer;
     int lastDir = 0;
+    String debugdir = " ";
     boolean gaming = false;
+    boolean switcheroo=false;
     public static void main(String[] args) {
         setupLogging(true,2);
         l.info("shizzlemork");
@@ -37,10 +41,15 @@ public class BotGame {
     }
     int lastcase=-1;
 
-    private int boardFF(int x, int y)
+    private int boardFF(int x, int y,int id)
     {
         if(boardFF[y][x]!=0)
         {
+            if(boardFF[y][x]>0&&boardFF[y][x]!=id)
+            {
+                l.info("1337#d");
+                return -1337;
+            }
             return 0;
         }
 
@@ -58,11 +67,11 @@ public class BotGame {
         {
             return 1;
         }
-        boardFF[y][x]=1;
-        rv+=boardFF(x,cni);
-        rv+=boardFF(x,csi);
-        rv+=boardFF(cwi,y);
-        rv+=boardFF(cei,y);
+        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;
     }
@@ -134,7 +143,31 @@ public class BotGame {
                             }
                             if(ln.contains("lose"))
                             {
-                                l.info("LOSER!!!1111elf");
+                                String boardview = "\nDumping Core....\nDone:\n";
+                                for(int i=0;i<ch;i++)
+                                {
+                                    for(int j=0;j<cw;j++)
+                                    {
+                                        boolean self =false;
+                                        if(i==cy&&j==cx)
+                                        {
+                                            self=true;
+                                            boardview+="XXX";
+                                        }
+                                        String number ="000"+boards[i][j]+"|";
+                                        String hbfr = headBuffer[i][j]?"#":"_";
+                                        if(self)
+                                        {
+                                            hbfr=debugdir;
+                                        }
+                                        boardview+=hbfr+
+                                                number.substring(number.length()-3,number.length());
+                                    }
+                                    boardview+="\n";
+                                }l.info("LOSER!!!1111elf");
+                                l.info(boardview+"\nEnd of Dump");
+
+
                                 gaming=false;
                             }
                             if(ln.contains("game"))
@@ -157,6 +190,11 @@ public class BotGame {
                             }
                             if(ln.contains("pos")&&gaming)
                             {
+                                if(playercount==0)
+                                {
+                                    headBuffer = new boolean[ch][cw];
+                                }
+                                playercount++;
                                 String[] ls = ln.split("\\|");
                                 int w = Integer.valueOf(ls[2]);
                                 int h = Integer.valueOf(ls[3]);
@@ -278,11 +316,11 @@ public class BotGame {
                                 int west=0,east=0,south=0,north=0;
                                 if(fuck>0) {
                                     if(fuck<0)
-                                    {east = boardFF(ce, cy);
-                                     west = boardFF(cw_, cy);
+                                    {east = boardFF(ce, cy,1);
+                                     west = boardFF(cw_, cy,2);
 
-                                     north = boardFF(cx, cn);
-                                     south = boardFF(cx, cs);
+                                     north = boardFF(cx, cn,3);
+                                     south = boardFF(cx, cs,4);
                                     }
                                     else
                                     {
@@ -302,43 +340,43 @@ public class BotGame {
                                         if(fuck%100==50) returnMsgs.add("chat|Red 5 standing by");
                                         if(fuck%100==75) returnMsgs.add("chat|rm -rf ~/botarmee*");
                                         l.info("lastdir"+lastDir);
-                                        boolean switcheroo = new File("/home/lh/switch").exists();
+                                        //boolean switcheroo = new File("/home/lh/switch").exists();
 
                                         switch(rnd)
                                         {
                                             case 3://prev=east
-                                                if(switcheroo) south = boardFF(cx, cs);
-                                                else north = boardFF(cx, cn);
-                                                east = boardFF(ce, cy);
-                                                north += boardFF(cx, cn);
-                                                south += boardFF(cx, cs);
-                                                west = boardFF(cw_, cy);
+                                                if(switcheroo) south = boardFF(cx, cs,1);
+                                                else north = boardFF(cx, cn,2);
+                                                east = boardFF(ce, cy,3);
+                                                if (switcheroo) north = boardFF(cx, cn,2);
+                                                else south = boardFF(cx, cs,1);
+                                                west = boardFF(cw_, cy,4);
                                                 l.info("lnesw"+lastDir+";"+north+";"+east+";"+south+";"+west);
 
                                                 break;
                                             case 1: //prev=west
-                                                if(switcheroo) north = boardFF(cx, cn);
-                                                else south = boardFF(cx, cs);
-                                                west = boardFF(cw_, cy);
-                                                south += boardFF(cx, cs);
-                                                north += boardFF(cx, cn);
-                                                east = boardFF(ce, cy);
+                                                if(switcheroo) north = boardFF(cx, cn,1);
+                                                else south = boardFF(cx, cs,2);
+                                                west = boardFF(cw_, cy,3);
+                                                if (switcheroo) south = boardFF(cx, cs,2);
+                                                else north = boardFF(cx, cn,1);
+                                                east = boardFF(ce, cy,4);
                                                 break;
                                             case 2://prev=down
-                                                if(switcheroo)west = boardFF(cw_, cy);
-                                                else    east = boardFF(ce, cy);
-                                                south = boardFF(cx, cs);
-                                                east += boardFF(ce, cy);
-                                                west += boardFF(cw_, cy);
-                                                north = boardFF(cx, cn);
+                                                if(switcheroo)west = boardFF(cw_, cy,1);
+                                                else    east = boardFF(ce, cy,2);
+                                                south = boardFF(cx, cs,3);
+                                                if(switcheroo)east = boardFF(ce, cy,2);
+                                                else west = boardFF(cw_, cy,1);
+                                                north = boardFF(cx, cn, 4);
                                                 break;
                                             case 0: //prev=up
-                                                if(switcheroo)east = boardFF(ce, cy);
-                                                else west = boardFF(cw_, cy);
-                                                north = boardFF(cx, cn);
-                                                west  +=boardFF(cw_, cy);
-                                                east  +=boardFF(ce, cy);
-                                                south = boardFF(cx, cs);
+                                                if(switcheroo)east = boardFF(ce, cy,1);
+                                                else west = boardFF(cw_, cy,2);
+                                                north = boardFF(cx, cn,3);
+                                                if(switcheroo) west  =boardFF(cw_, cy,2);
+                                                else east  =boardFF(ce, cy,1);
+                                                south = boardFF(cx, cs,4);
 
 
 
@@ -349,27 +387,74 @@ public class BotGame {
                                 }
                                 else{
                                     if(fuck<30) {
-                                        south = boardFF(cx, cs);
-                                        north = boardFF(cx, cn);
+                                        south = boardFF(cx, cs,1);
+                                        north = boardFF(cx, cn,2);
 
-                                        west = boardFF(cw_, cy);
-                                        east = boardFF(ce, cy);
+                                        west = boardFF(cw_, cy,3);
+                                        east = boardFF(ce, cy,4);
                                     }
 
                                 }
                                 fuck++;
 
                                 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)
+                                {
+                                    l.info(fuck<20);
+                                    l.info(((500+fuck-330)%500)<30);
+                                    l.info("remappingparty");
+                                    if(east==-1337)
+                                        east=highest;
+                                    if(west==-1337)
+                                        west=highest;
+                                    if(south==-1337)
+                                        south=highest;
+                                    if(north==-1337)
+                                        north=highest;
+                                }
+                                else
+                                {
+                                    {
+                                        if(east==-1337)
+                                            east=0;
+                                        if(west==-1337)
+                                            west=0;
+                                        if(south==-1337)
+                                            south=0;
+                                        if(north==-1337)
+                                            north=0;
+                                    }
+                                }
+                                if((highest<((cw*ch)/playercount)||playercount<3))
+                                {
+                                    l.info("Switcheroo zone reached");
+
+                                    if(fuck%10==0)
+                                    {
+                                        l.info("chkFlick");
+                                        if((fuck/10)%3<2)
+                                        {
+                                            l.info("flick");
+                                            switcheroo=!switcheroo;
+                                        }
+                                    }
+                                }
+                                l.info("switcheroo="+switcheroo);
                                 l.info("fnesw"+fuck+";"+north+";"+east+";"+south+";"+west);
-                                int rnd=-2;
+                                int rnd=(int)(Math.random()*4);
+                                if(fuck%300<25&&fuck>15)
+                                {
+                                    rnd=0;
+                                }
                                 int lastchoice=-1;
                                 int treshold=1;
                                 while(!randomDone)
                                 {
                                     //rnd = (int) (Math.random()*4);
-                                    rnd=lastchoice;
-                                    lastchoice+=1;
+                                    //rnd=lastchoice;
+                                    /*lastchoice+=1;
                                     if(lastchoice>3)
                                     {
                                         lastchoice=0;
@@ -378,7 +463,7 @@ public class BotGame {
                                     if(treshold>3)
                                     {
 
-                                    }
+                                    }*/
                                     //l.info("rnd="+rnd+"lastcse="+lastcase);
                                     /*if(rnd==lastcase)
                                     {
@@ -396,6 +481,7 @@ public class BotGame {
                                             if(west==highest)
                                             {
                                                 lastDir=1;
+                                                debugdir="<";
                                                 direction="left";
                                                 randomDone=true;
                                                 lastcase=3;}
@@ -406,13 +492,16 @@ public class BotGame {
                                             {
                                                 lastDir=3;
                                                 direction="right";
-                                            randomDone=true;
-                                            lastcase=1;}
+                                                randomDone=true;
+                                                debugdir=">";
+                                                lastcase=1;
+                                            }
                                             break;
                                         case 0:
                                             lastDir=0;
                                             //if(((board[cn][cx]*2)<treshold)){
                                             if(north==highest){
+                                                debugdir="^";
                                                 direction="up";
                                                 randomDone=true;
                                                 lastcase=2;}
@@ -422,14 +511,18 @@ public class BotGame {
                                             //if((board[cs][cx]<treshold))
                                             if(south==highest)
                                             {
+                                                debugdir="V";
                                                 direction="down";
                                                  randomDone=true;
                                                  lastcase=0;}
                                             break;
 
                                     }
+                                    rnd=(rnd+1)%4;
                                 }
-                                headBuffer = new boolean[ch][cw];
+                                //headBuffer = new boolean[ch][cw];
+                                l.trace("pc="+playercount);
+                                playercount=0;
                                 returnMsgs.add("move|"+direction);
 
                             }