// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: packimports(3) // Source File Name: Imperia3.java import java.applet.Applet; import java.awt.*; public class Imperia3 extends Applet { public Imperia3() { } public void SomethingElseForTotalBackBoard() { } public void SomethingElseForTotalSaveBoard() { } public void SomethingElseForUnBackBoard() { } public void SomethingElseForLoadSavedBoard() { } public boolean SomeInitialConditionForKeydown(){ return false; } public boolean keyDown(Event e, int k) { if (humanizing==true){return false;} if (SomeInitialConditionForKeydown()==true){return true;} Graphics g=getGraphics(); oopsKey=getParameter("OOPS").charAt(0); saveKey=getParameter("SAVE").charAt(0); loadKey=getParameter("LOAD").charAt(0); if (k==oopsKey) { PromotingAPawn=false; GameOver=false; UnBackBoard();TotalMaybeBoard(NowBoard, MaybeBoard); markingAPiece=true; whoseMove=who_backed; SayWhoIsHuman(g); whatpiecescanmove(g); TotalMaybeBoard(NowBoard, MaybeBoard); GenerateAttackersArrays(); CountAllThePieces(); DrawNowBoard(g); return true; } if (k==saveKey) { TotalSaveBoard();TotalMaybeBoard(NowBoard, MaybeBoard); who_saved=whoseMove; } if (k==loadKey) { PromotingAPawn=false; GameOver=false; LoadSavedBoard();TotalMaybeBoard(NowBoard, MaybeBoard); markingAPiece=true; whoseMove=who_backed; SayWhoIsHuman(g); whatpiecescanmove(g); TotalMaybeBoard(NowBoard, MaybeBoard); GenerateAttackersArrays(); CountAllThePieces(); DrawNowBoard(g); return true; } System.out.println("kurwa"); return false; } public void TotalBackBoard(){back_turncounter=turncounter;back_fifty_move_rule=fifty_move_rule; for(xxx=0; xxx < 17; xxx++) for(yyy=0; yyy < 17; yyy++) { BackBoard.sq_[yyy][xxx].side_=NowBoard.sq_[yyy][xxx].side_; BackBoard.sq_[yyy][xxx].piece_=NowBoard.sq_[yyy][xxx].piece_; SomethingElseForTotalBackBoard(); } } public void TotalSaveBoard(){saved_fifty_move_rule=fifty_move_rule;saved_turncounter=turncounter; for(xxx=0; xxx < 17; xxx++) for(yyy=0; yyy < 17; yyy++) { SaveBoard.sq_[yyy][xxx].side_=NowBoard.sq_[yyy][xxx].side_; SaveBoard.sq_[yyy][xxx].piece_=NowBoard.sq_[yyy][xxx].piece_; SomethingElseForTotalSaveBoard(); } } public void UnBackBoard(){turncounter=back_turncounter;fifty_move_rule=back_fifty_move_rule;ShowStatusNothing(); for(xxx=0; xxx < 17; xxx++) for(yyy=0; yyy < 17; yyy++) { NowBoard.sq_[yyy][xxx].side_=BackBoard.sq_[yyy][xxx].side_; NowBoard.sq_[yyy][xxx].piece_=BackBoard.sq_[yyy][xxx].piece_; SomethingElseForUnBackBoard(); } } public void LoadSavedBoard(){turncounter=saved_turncounter;fifty_move_rule=saved_fifty_move_rule;ShowStatusNothing(); for(xxx=0; xxx < 17; xxx++) for(yyy=0; yyy < 17; yyy++) { NowBoard.sq_[yyy][xxx].side_=SaveBoard.sq_[yyy][xxx].side_; NowBoard.sq_[yyy][xxx].piece_=SaveBoard.sq_[yyy][xxx].piece_; SomethingElseForLoadSavedBoard(); } } public void ShowStatusQ(String stringo){ if (turncounter==0){showStatus(stringo);return;} showStatus(stringo+" ["+turncounter+"]"); } public void CastleStuff(){ if(NowBoard.sq_[mover_rank][mover_file].piece_==-2) { if (moveto_file==11) { NowBoard.sq_[mover_rank][12].piece_=0; NowBoard.sq_[mover_rank][12].side_=0; NowBoard.sq_[mover_rank][10].piece_=5; NowBoard.sq_[mover_rank][10].side_=whoseMove; } if (moveto_file==7) { NowBoard.sq_[mover_rank][5].piece_=0; NowBoard.sq_[mover_rank][5].side_=0; NowBoard.sq_[mover_rank][8].piece_=5; NowBoard.sq_[mover_rank][8].side_=whoseMove; } if (moveto_rank==11) { NowBoard.sq_[12][mover_file].piece_=0; NowBoard.sq_[12][mover_file].side_=0; NowBoard.sq_[10][mover_file].piece_=5; NowBoard.sq_[10][mover_file].side_=whoseMove; } if (moveto_rank==7) { NowBoard.sq_[5][mover_file].piece_=0; NowBoard.sq_[5][mover_file].side_=0; NowBoard.sq_[8][mover_file].piece_=5; NowBoard.sq_[8][mover_file].side_=whoseMove; } } } public void SeeIfHeCanMove(Graphics g, int whoishe){} public int partner(int whoami){ switch(whoami){ case 1:{return 3;} case 2:{return 4;} case 3:{return 1;} case 4:{return 2;} } return 0; } public boolean IsThisAGoodMove(){ if (goodmove10==moveCounter){return true;} if (goodmove9==moveCounter){return true;} if (goodmove8==moveCounter){return true;} if (goodmove7==moveCounter){return true;} if (goodmove6==moveCounter){return true;} if (goodmove5==moveCounter){return true;} if (goodmove4==moveCounter){return true;} if (goodmove3==moveCounter){return true;} if (goodmove2==moveCounter){return true;} if (goodmove1==moveCounter){return true;} return false; } public void NegateGMCounts(){GM1count=0;GM2count=0;GM3count=0;GM4count=0;GM5count=0;GM6count=0;GM7count=0;GM8count=0;GM9count=0;GM10count=0;} public void AssignGoodMove1(){GM1count++;if ((Math.random()*GM1count<1)|(GM1count==1)){goodmove1 = moveCounter;}} public void AssignGoodMove2(){GM2count++;if ((Math.random()*GM2count<1)|(GM2count==1)){goodmove2 = moveCounter;}} public void AssignGoodMove3(){GM3count++;if ((Math.random()*GM3count<1)|(GM3count==1)){goodmove3 = moveCounter;}} public void AssignGoodMove4(){GM4count++;if ((Math.random()*GM4count<1)|(GM4count==1)){goodmove4 = moveCounter;}} public void AssignGoodMove5(){GM5count++;if ((Math.random()*GM5count<1)|(GM5count==1)){goodmove5 = moveCounter;}} public void AssignGoodMove6(){GM6count++;if ((Math.random()*GM6count<1)|(GM6count==1)){goodmove6 = moveCounter;}} public void AssignGoodMove7(){GM7count++;if ((Math.random()*GM7count<1)|(GM7count==1)){goodmove7 = moveCounter;}} public void AssignGoodMove8(){GM8count++;if ((Math.random()*GM8count<1)|(GM8count==1)){goodmove8 = moveCounter;}} public void AssignGoodMove9(){GM9count++;if ((Math.random()*GM9count<1)|(GM9count==1)){goodmove9 = moveCounter;}} public void AssignGoodMove10(){GM10count++;if ((Math.random()*GM10count<1)|(GM10count==1)){goodmove10 = moveCounter;}} public void start(){ if (NowBoard==null){init();repaint();ShowStatusQ("Applet Re-Started");} } public int FirstEnemy(int i){ switch(i){ case 1:{return 2;} case 2:{return 3;} case 3:{return 4;} case 4:{return 1;} } return 0; } public int SecondEnemy(int i){ switch(i){ case 1:{return 3;} case 2:{return 4;} case 3:{return 1;} case 4:{return 2;} } return 0; } public int ThirdEnemy(int i){ switch(i){ case 1:{return 4;} case 2:{return 1;} case 3:{return 2;} case 4:{return 3;} } return 0; } public void DesignateTheGoodMoves(Chsq chsq) { if((whoseMove != chsq.side_) | ((skipDtGM) | (depth > 1))) return; if((chsq.piece_ < 0) & (NowBoard.sq_[d[depth]][c[depth]].side_ == chsq.side_)) return; IncrediblyGoodMove(chsq); if ( DCAssailants(chsq.rank_,chsq.file_,chsq.side_)>Attackers[chsq.rank_][chsq.file_][chsq.side_] ) { if (AmIUnderAttack(d[depth],c[depth],SecondEnemy(chsq.side_))==true) AssignGoodMove1(); } if((chsq.piece_ < 0) & (NowBoard.sq_[d[depth]][c[depth]].side_ == chsq.side_)) return; if((DCAssailants(d[depth], c[depth], chsq.side_) == 0) & (dcishuman()) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) && Math.random() * 100D < 99D) AssignGoodMove9(); if(chsq.piece_ == -69 ) goodmove10=moveCounter; if((NowBoard.sq_[d[depth]][c[depth]].strength() > 1 + chsq.strength()) & (dcishuman()) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove9(); if(NowBoard.sq_[d[depth]][c[depth]].strength() > 2 + chsq.strength() && !worried) AssignGoodMove9(); if((chsq.strength() > 3) & (DCAssailants(chsq.rank_, chsq.file_, chsq.side_) > 0) & (DCAssailants(d[depth], c[depth], chsq.side_) == 0) && (Math.random() * 100D <98D && !worried)) {AssignGoodMove8();if (NowBoard.sq_[d[depth]][c[depth]].piece_!=0){AssignGoodMove9();}} if((DCAssailants(d[depth], c[depth], chsq.side_) == 0) & (NowBoard.sq_[d[depth]][c[depth]].side_ != chsq.side_) & (dcishuman()) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) && (Math.random() * 100D <98D && !worried)) AssignGoodMove7(); if((chsq.strength() < 3) & (dcishuman()) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) && (Math.random() * 100D <98D && !worried)) AssignGoodMove6(); if((chsq.strength() > 2) & (DCAssailants(chsq.rank_, chsq.file_, chsq.side_) > 0) & (DCAssailants(d[depth], c[depth], chsq.side_) == 0) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove5(); if((DCAssailants(d[depth], c[depth], chsq.side_) == 0) & (dcishuman()) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 1) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove4(); if((chsq.strength() < NowBoard.sq_[d[depth]][c[depth]].strength()) & (dcishuman()) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove3(); if( (DCAssailants(d[depth], c[depth], chsq.side_) == 0) &( (IsMySideInCheck(FirstEnemy(chsq.side_))) |(IsMySideInCheck(SecondEnemy(chsq.side_))) |(IsMySideInCheck(ThirdEnemy(chsq.side_))) ) & (dcishuman()) & (Math.random() * 100D <98D) & (!worried) ) AssignGoodMove2(); /* if ((StrongestAttacker[d[depth]][c[depth]][3-chsq.side_]==0) &(NowBoard.sq_[d[depth]][c[depth]].piece_!=0) &(Math.random() * 100D < 98D)) { switch(NowBoard.sq_[d[depth]][c[depth]].strength()) { case 5:{AssignGoodMove9();break;} case 4:{AssignGoodMove7();break;} case 3:{AssignGoodMove5();break;} case 2:{AssignGoodMove3();break;} case 1:{AssignGoodMove2();break;} } } if ((StrongestAttacker[chsq.rank_][chsq.file_][3-chsq.side_]>0) &(StrongestAttacker[chsq.rank_][chsq.file_][3-chsq.side_]0) &(Attackers[chsq.rank_][chsq.file_][chsq.side_]==0) &(StrongestAttacker[d[depth]][c[depth]][3-chsq.side_]==0) &(Math.random() * 100D < 98D) ) { switch(chsq.strength()){ case 5:{AssignGoodMove9();break;} case 4:{AssignGoodMove7();break;} case 3:{AssignGoodMove5();break;} case 2:{AssignGoodMove3();break;} case 1:{AssignGoodMove2();break;} } } */ if((fifty_move_rule > 4) & (chsq.pawn()) & (Math.random() * 100D < (double)(100 - 10 * PawnCount[chsq.side_])) & (!worried) & (Attackers[d[depth]][c[depth]][FirstEnemy(chsq.side_)]+Attackers[d[depth]][c[depth]][SecondEnemy(chsq.side_)]+Attackers[d[depth]][c[depth]][ThirdEnemy(chsq.side_)] == 0)) AssignGoodMove1(); /* if((WeakestAttacker[d[depth]][c[depth]][3-chsq.side_]>=chsq.strength())&(DCAssailants(d[depth], c[depth], chsq.side_) < Attackers[d[depth]][c[depth]][chsq.side_]) & (NowBoard.sq_[d[depth]][c[depth]].piece_ != 0) & (dcishuman()) && (Math.random() * 100D <98D && !worried)) AssignGoodMove1(); */ MoreGoodMoves(chsq); NightMoves(chsq); if((chsq.piece_ < 0) & (fifty_move_rule > 10)) { if((chsq.side_ == 1) & (c[depth] >= chsq.file_) & (d[depth] >= chsq.rank_) & (Math.random() * 100D < 98D) && !worried) AssignGoodMove2(); if((chsq.side_ == 2) & (c[depth] >= chsq.file_) & (d[depth] <= chsq.rank_) & (Math.random() * 100D < 98D) && !worried) AssignGoodMove2(); if((chsq.side_ == 3) & (c[depth] <= chsq.file_) & (d[depth] >= chsq.rank_) & (Math.random() * 100D < 98D) && !worried) AssignGoodMove2(); if((chsq.side_ == 4) & (c[depth] <= chsq.file_) & (d[depth] <= chsq.rank_) & (Math.random() * 100D < 98D) && !worried) AssignGoodMove2(); } } public void AddAnAttacker() { if((xatt==catt) & (yatt==datt)) return; if((catt>16) | (datt>16) | (catt<1) | (datt<1)) { return; } else { Attackers[datt][catt][satt]=Attackers[datt][catt][satt]+1; if (StrongestAttacker[datt][catt][satt]NowBoard.sq_[yatt][xatt].strength()) | (WeakestAttacker[datt][catt][satt]==0)) {WeakestAttacker[datt][catt][satt]=NowBoard.sq_[yatt][xatt].strength();} return; } } public boolean AmIUnderAttack(int i, int j, int k) { if(SupplementalAmIUnderAttackers(i, j, k)) return true; cc=j+1; dd=i; while(cc<17) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=20; } else { if(IsEnemyRook(dd, cc, k)) return true; if(MaybeBoard.sq_[dd][cc].piece_ !=0) cc=20; cc++; } cc=j-1; dd=i; while(cc>0) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=-200; } else { if(IsEnemyRook(dd, cc, k)) return true; if(MaybeBoard.sq_[dd][cc].piece_ !=0) cc=-200; cc--; } cc=j; for(dd=i+1; dd<17;) if(MaybeBoard.sq_[dd][cc].side_==k) { dd=20; } else { if(IsEnemyRook(dd, cc, k)) return true; if(MaybeBoard.sq_[dd][cc].piece_ !=0) dd=20; dd++; } cc=j; for(dd=i-1; dd>0;) if(MaybeBoard.sq_[dd][cc].side_==k) { dd=-1; } else { if(IsEnemyRook(dd, cc, k)) return true; if(MaybeBoard.sq_[dd][cc].piece_ !=0) dd=-1; dd--; } cc=j-1; dd=i-1; if(IsEnemySoldier(dd, cc, k)) return true; cc=j+1; dd=i-1; if(IsEnemySoldier(dd, cc, k)) return true; cc=j-1; dd=i+1; if(IsEnemySoldier(dd, cc, k)) return true; cc=j+1; dd=i+1; if(IsEnemySoldier(dd, cc, k)) return true; cc=j-1; dd=i-1; if(IsEnemyKing(dd, cc, k)) return true; cc=j-1; dd=i; if(IsEnemyKing(dd, cc, k)) return true; cc=j-1; dd=i+1; if(IsEnemyKing(dd, cc, k)) return true; cc=j; dd=i-1; if(IsEnemyKing(dd, cc, k)) return true; cc=j; dd=i+1; if(IsEnemyKing(dd, cc, k)) return true; cc=j+1; dd=i-1; if(IsEnemyKing(dd, cc, k)) return true; cc=j+1; dd=i; if(IsEnemyKing(dd, cc, k)) return true; cc=j+1; dd=i+1; if(IsEnemyKing(dd, cc, k)) return true; cc=j+1; for(dd=i+1; (cc<17) & (dd<17);) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=20; } else { if(IsEnemyBishop(dd, cc, k)) return true; if(MaybeBoard.sq_[dd][cc].piece_ !=0) cc=20; cc++; dd++; } cc=j+1; for(dd=i-1; (cc<17) & (dd>0);) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=20; } else { if(IsEnemyBishop(dd, cc, k)) return true; if(MaybeBoard.sq_[dd][cc].piece_ !=0) cc=20; cc++; dd--; } cc=j-1; for(dd=i+1; (cc>0) & (dd<17);) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=-200; } else { if(IsEnemyBishop(dd, cc, k)) return true; if(MaybeBoard.sq_[dd][cc].piece_ !=0) cc=-200; cc--; dd++; } cc=j-1; for(dd=i-1; (cc>0) & (dd>0);) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=-200; } else { if(IsEnemyBishop(dd, cc, k)) return true; if(MaybeBoard.sq_[dd][cc].piece_ !=0) cc=-200; cc--; dd--; } cc=j-2; dd=i-2; if(IsEnemyAlfilDabbaba(dd, cc, k)) return true; cc=j+2; dd=i-2; if(IsEnemyAlfilDabbaba(dd, cc, k)) return true; cc=j-2; dd=i+2; if(IsEnemyAlfilDabbaba(dd, cc, k)) return true; cc=j+2; dd=i+2; if(IsEnemyAlfilDabbaba(dd, cc, k)) return true; cc=j-2; dd=i ; if(IsEnemyAlfilDabbaba(dd, cc, k)) return true; cc=j+2; dd=i ; if(IsEnemyAlfilDabbaba(dd, cc, k)) return true; cc=j ; dd=i-2; if(IsEnemyAlfilDabbaba(dd, cc, k)) return true; cc=j ; dd=i+2; if(IsEnemyAlfilDabbaba(dd, cc, k)) return true; cc=j-2; dd=i-1; if(IsEnemyKnight(dd, cc, k)) return true; cc=j-2; dd=i+1; if(IsEnemyKnight(dd, cc, k)) return true; cc=j+2; dd=i-1; if(IsEnemyKnight(dd, cc, k)) return true; cc=j+2; dd=i+1; if(IsEnemyKnight(dd, cc, k)) return true; cc=j-1; dd=i-2; if(IsEnemyKnight(dd, cc, k)) return true; cc=j-1; dd=i+2; if(IsEnemyKnight(dd, cc, k)) return true; cc=j+1; dd=i-2; if(IsEnemyKnight(dd, cc, k)) return true; cc=j+1; dd=i+2; if(IsEnemyKnight(dd, cc, k)) return true; cc=j+1; dd=i+1; if(IsEnemySouthPawn(dd, cc, k)) return true; cc=j-1; dd=i+1; if(IsEnemySouthPawn(dd, cc, k)) return true; cc=j+1; dd=i-1; if(IsEnemyNorthPawn(dd, cc, k)) return true; cc=j-1; dd=i-1; if(IsEnemyNorthPawn(dd, cc, k)) return true; cc=j-1; dd=i+1; if(IsEnemyEastPawn(dd, cc, k)) return true; cc=j-1; dd=i-1; if(IsEnemyEastPawn(dd, cc, k)) return true; cc=j+1; dd=i+1; if(IsEnemyWestPawn(dd, cc, k)) return true; cc=j+1; dd=i-1; return IsEnemyWestPawn(dd, cc, k); } public boolean AmIUnderSparrowAttack(int i, int j, int k) { if(SupplementalAmIUnderSparrowAttackers(i, j, k)) return true; cc=j+1; dd=i; while(cc<17) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=20; } else { if(IsEnemyRook(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength()0) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=-200; } else { if(IsEnemyRook(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength()0;) if(MaybeBoard.sq_[dd][cc].side_==k) { dd=-1; } else { if(IsEnemyRook(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength()0);) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=20; } else { if(IsEnemyBishop(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength()0) & (dd<17);) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=-200; } else { if(IsEnemyBishop(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength()0) & (dd>0);) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=-200; } else { if(IsEnemyBishop(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength()1)) return false; if(i !=whoseMove) return false; for(xxx=1; xxx<17; xxx++) for(yyy=1; yyy<17; yyy++) if((MaybeBoard.sq_[yyy][xxx].side_==i) & (MaybeBoard.sq_[yyy][xxx].strength()>1) & (MaybeBoard.sq_[yyy][xxx].strength()>NowBoard.sq_[d[depth]][c[depth]].strength()) && AmIUnderSparrowAttack(yyy, xxx, i)) return true; return false; } public boolean AnotherWayToEndGame(Graphics g, int i) { return false; } public void Archives() { if (GameOver==true){return;} ArchiveCounter=0; ArchiveCounter=0; for(ff=1; ff<17; ff++) for(ee=1; ee<17; ee++) { ArchiveBoard[fifty_move_rule].sq_[ff][ee].piece_=NowBoard.sq_[ff][ee].piece_; ArchiveBoard[fifty_move_rule].sq_[ff][ee].side_=NowBoard.sq_[ff][ee].side_; } ArchiveBoard[fifty_move_rule].sq_[0][0].side_=whoseMove; for(xxx=0; xxx1) { if (konigsritter==false){ drawn_games++; ShowStatusQ("Draw By Repetition");} if (konigsritter==true){ drawn_games++; ShowStatusQ("Black wins by repetition!");} GameOver=true; return; } } } public void CountAllThePieces() { ZeroAllFiveCounts(); for(xxx=1; xxx<17; xxx++) for(yyy=1; yyy<17; yyy++) { if(NowBoard.sq_[yyy][xxx].piece_==101) PawnCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==102) PawnCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==103) PawnCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==104) PawnCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_>400) PawnCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==1) PawnCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==2) PawnCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==3) KnightCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==4) BishopCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==5) RookCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==6) RookCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==9) { if (konigsritter==true){KingCount[NowBoard.sq_[yyy][xxx].side_]++;} QueenCount[NowBoard.sq_[yyy][xxx].side_]++; } if(NowBoard.sq_[yyy][xxx].piece_==38) QueenCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==25) QueenCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_<0) KingCount[NowBoard.sq_[yyy][xxx].side_]++; } } public int DCAssailants(int i, int j, int k) { zzz=0; if(owner[k] !=owner[1]) zzz+=Attackers[i][j][1]; if(owner[k] !=owner[2]) zzz+=Attackers[i][j][2]; if(owner[k] !=owner[3]) zzz+=Attackers[i][j][3]; if(owner[k] !=owner[4]) zzz+=Attackers[i][j][4]; return zzz; } public void DesignateTheFineMoves(Chsq chsq) { good_move=1; if((skipDtGM) | (depth>1) | (worried)) return; if(IsMySideInCheck(1)) good_move+=5; if(IsMySideInCheck(2)) good_move+=5; if(IsMySideInCheck(3)) good_move+=5; if(IsMySideInCheck(4)) good_move+=5; if((chsq.piece_==1) | (chsq.piece_==2) | (chsq.piece_<0) | (chsq.piece_==51) | (chsq.piece_==61) | (chsq.piece_==71) | (chsq.piece_>100)) { if((NowBoard.sq_[d[depth]][c[depth]].piece_==3) | (NowBoard.sq_[d[depth]][c[depth]].piece_==4) | (NowBoard.sq_[d[depth]][c[depth]].piece_==25)) good_move+=15; if((NowBoard.sq_[d[depth]][c[depth]].piece_==28) |(NowBoard.sq_[d[depth]][c[depth]].piece_==5) | (NowBoard.sq_[d[depth]][c[depth]].piece_==6)) good_move+=25; if((NowBoard.sq_[d[depth]][c[depth]].piece_==9) | (NowBoard.sq_[d[depth]][c[depth]].piece_==21) | (NowBoard.sq_[d[depth]][c[depth]].piece_==28) | (NowBoard.sq_[d[depth]][c[depth]].piece_==29)) good_move+=50; } if((chsq.piece_==3) | (chsq.piece_==4) | (chsq.piece_==193) | (NowBoard.sq_[d[depth]][c[depth]].piece_==25)) { if((NowBoard.sq_[d[depth]][c[depth]].piece_==5) | (NowBoard.sq_[d[depth]][c[depth]].piece_==6)) good_move+=15; if(NowBoard.sq_[d[depth]][c[depth]].piece_==9) good_move+=25; } if((chsq.piece_==5) | (chsq.piece_==6) && NowBoard.sq_[d[depth]][c[depth]].piece_==9) good_move+=20; if((chsq.piece_==9) | (chsq.piece_==21) | (chsq.piece_==57) | (chsq.piece_==28) | (chsq.piece_==29) && (DCAssailants(chsq.rank_, chsq.file_, chsq.side_)>0) & (DCAssailants(d[depth], c[depth], chsq.side_)==0)) good_move+=20; if((NowBoard.sq_[d[depth]][c[depth]].piece_>0) & (Attackers[d[depth]][c[depth]][chsq.side_]>DCAssailants(d[depth], c[depth], chsq.side_))) good_move+=15; } public void DidICheckOrStalemate(Graphics g, int i) { } public void DisplayRules(Graphics g) { g.setFont(f1);g.setColor(Color.black); g.drawString("Mike Calkoviks and Jeff Knight, 1993.", 525, 40); g.drawString("Proprietary game from Scorpion Games.", 525, 57); g.drawString("The army vanishes when king is captured.", 525, 74); g.drawString("Last player surviving is the winner.", 525, 91); g.drawString("Pawns capturing into side extensions change", 525, 108); g.drawString("direction. You must escape check if you can.", 525, 125); g.drawString("For now I have all promotions to Queen.", 525, 142); g.drawString("I assumed liberal rules for castling.", 525, 159); } public boolean DoIHaveAMove(Graphics g, int i) { moveCounter=0; for(y_diham=1; y_diham<17; y_diham++) for(x_diham=1; x_diham<17; x_diham++) if(NowBoard.sq_[y_diham][x_diham].side_==i) { findPieceMoves(g, NowBoard.sq_[y_diham][x_diham], NowBoard, MaybeBoard); if(moveCounter>0) return true; } ShowStatusQ("No move!"); return false; } public void DoIHaveLastKing() { CountAllThePieces(); if(KingCount[2]+KingCount[3]+KingCount[4]==0) { wins[1]++; ShowStatusQ("Blue wins!"); GameOver=true; } if(KingCount[1]+KingCount[3]+KingCount[4]==0) { wins[2]++; ShowStatusQ("Gold wins!"); GameOver=true; } if(KingCount[2]+KingCount[1]+KingCount[4]==0) { wins[3]++; ShowStatusQ("Red wins!"); GameOver=true; } if(KingCount[2]+KingCount[3]+KingCount[1]==0) { wins[4]++; ShowStatusQ("White wins!"); GameOver=true; } } public boolean DoesArchiveMatchNowBoard() { if(whoseMove !=ArchiveBoard[xxx].sq_[0][0].side_) return false; for(ff=1; ff<17; ff++) for(ee=1; ee<17; ee++) { if(NowBoard.sq_[ff][ee].piece_ !=ArchiveBoard[xxx].sq_[ff][ee].piece_) return false; if(NowBoard.sq_[ff][ee].piece_ !=ArchiveBoard[xxx].sq_[ff][ee].piece_) return false; } return true; } public void DrawMaybeBoard(Graphics g) { for(ee=1; ee<17; ee++) for(ff=1; ff<17; ff++) MaybeBoard.sq_[ff][ee].drawchsq2(g, 3); } public void DrawNowBoard(Graphics g) { for(ee=1; ee<17; ee++) for(ff=1; ff<17; ff++) { NowBoard.sq_[ff][ee].DrawImperial3(g, 3, icanmove[ff][ee],playing_as_teams,am_i_checkmated[NowBoard.sq_[ff][ee].side_],konigsritter); if(NowBoard.sq_[ff][ee].piece_<0) { KingRank[NowBoard.sq_[ff][ee].side_]=ff; KingFile[NowBoard.sq_[ff][ee].side_]=ee; } } } public void DrawPromotionOptions(Graphics g) { g.setColor(niceblue); g.fillRect(510, 271, 300, 114); g.setColor(Color.black); g.setFont(f2); g.drawString("Choose: ", 5, 320); happySquare.side_=whoseMove; happySquare.rank_=-1; happySquare.file_=17; happySquare.piece_=9; happySquare.DrawImperial3(g, 11, false,playing_as_teams,false,konigsritter); happySquare.file_=18; happySquare.piece_=5; happySquare.DrawImperial3(g, 11, false,playing_as_teams,false,konigsritter); happySquare.file_=19; happySquare.piece_=4; happySquare.DrawImperial3(g, 11, false,playing_as_teams,false,konigsritter); happySquare.file_=20; happySquare.piece_=3; happySquare.DrawImperial3(g, 11, false,playing_as_teams,false,konigsritter); } public void ForGambler(Graphics g) { } public void GenerateAttackersArrays() { for(zatt=1; zatt<5; zatt++) for(yatt=1; yatt<17; yatt++) for(xatt=1; xatt<17; xatt++) { Attackers[yatt][xatt][zatt]=0; StrongestAttacker[yatt][xatt][zatt]=0; WeakestAttacker[yatt][xatt][zatt]=0; } for(yatt=1; yatt<17; yatt++) for(xatt=1; xatt<17; xatt++) { satt=NowBoard.sq_[yatt][xatt].side_; patt=NowBoard.sq_[yatt][xatt].piece_; if((patt==5) | (patt==6) | (patt==105) | (patt==109) | (patt==9) | (patt==-9) | (patt==57) | (patt==29) | (patt==28)) { catt=xatt; datt=yatt; for(; catt<17; catt++) { AddAnAttacker(); if((catt !=xatt) & (NowBoard.sq_[datt][catt].side_ !=0)) catt=20; } catt=xatt; datt=yatt; for(; catt>0; catt--) { AddAnAttacker(); if((catt !=xatt) & (NowBoard.sq_[datt][catt].side_ !=0)) catt=-20; } catt=xatt; for(datt=yatt; datt<17; datt++) { AddAnAttacker(); if((datt !=yatt) & (NowBoard.sq_[datt][catt].side_ !=0)) datt=20; } catt=xatt; for(datt=yatt; datt>0; datt--) { AddAnAttacker(); if((datt !=yatt) & (NowBoard.sq_[datt][catt].side_ !=0)) datt=-20; } } if((patt==3)|(patt==38)) { catt=xatt+1; datt=yatt+2; AddAnAttacker(); catt=xatt+1; datt=yatt-2; AddAnAttacker(); catt=xatt-1; datt=yatt+2; AddAnAttacker(); catt=xatt-1; datt=yatt-2; AddAnAttacker(); catt=xatt+2; datt=yatt+1; AddAnAttacker(); catt=xatt+2; datt=yatt-1; AddAnAttacker(); catt=xatt-2; datt=yatt+1; AddAnAttacker(); catt=xatt-2; datt=yatt-1; AddAnAttacker(); } if((patt<0) | (patt==25)) { catt=xatt+1; datt=yatt+1; AddAnAttacker(); catt=xatt+1; datt=yatt-1; AddAnAttacker(); catt=xatt-1; datt=yatt+1; AddAnAttacker(); catt=xatt-1; datt=yatt-1; AddAnAttacker(); catt=xatt; datt=yatt+1; AddAnAttacker(); catt=xatt; datt=yatt-1; AddAnAttacker(); catt=xatt+1; datt=yatt; AddAnAttacker(); catt=xatt-1; datt=yatt; AddAnAttacker(); } if((patt==4) | (patt==9)) { catt=xatt; for(datt=yatt; (catt<17) & (datt<17); datt++) { AddAnAttacker(); if((catt !=xatt) & (NowBoard.sq_[datt][catt].side_ !=0)) catt=20; catt++; } catt=xatt; for(datt=yatt; (catt>0) & (datt<17); datt++) { AddAnAttacker(); if((catt !=xatt) & (NowBoard.sq_[datt][catt].side_ !=0)) catt=-20; catt--; } catt=xatt; for(datt=yatt; (catt<17) & (datt>0); catt++) { AddAnAttacker(); if((datt !=yatt) & (NowBoard.sq_[datt][catt].side_ !=0)) catt=20; datt--; } catt=xatt; for(datt=yatt; (catt>0) & (datt>0); catt--) { AddAnAttacker(); if((datt !=yatt) & (NowBoard.sq_[datt][catt].side_ !=0)) catt=-20; datt--; } } if((patt==101) | (patt==201)) { datt=yatt+1; catt=xatt+1; AddAnAttacker(); datt=yatt-1; catt=xatt+1; AddAnAttacker(); } if((patt==102) | (patt==202)) { datt=yatt-1; catt=xatt+1; AddAnAttacker(); datt=yatt-1; catt=xatt-1; AddAnAttacker(); } if((patt==103) | (patt==203)) { datt=yatt+1; catt=xatt-1; AddAnAttacker(); datt=yatt-1; catt=xatt-1; AddAnAttacker(); } if((patt==104) | (patt==204)) { datt=yatt+1; catt=xatt+1; AddAnAttacker(); datt=yatt+1; catt=xatt-1; AddAnAttacker(); } SupplementalAddAnAttacker(); } } public boolean HumanMoveAPiece(Graphics g, int i, int j) { moveto_rank=i; moveto_file=j; if((mover_rank==moveto_rank) & (mover_file==moveto_file)) { markingAPiece=true; DrawNowBoard(g); return false; } if(!IsMyMoveListed()) { return false; } else { TotalBackBoard(); who_backed=whoseMove; NormalMove(g); TotalMaybeBoard(NowBoard,MaybeBoard);DidICheckOrStalemate(g, whoseMove); IsTheGameOver(); markingAPiece=true; DrawNowBoard(g); TotalMaybeBoard(NowBoard, MaybeBoard); TotalMaybeBoard(MaybeBoard, TwoBoard); TotalMaybeBoard(TwoBoard, ThreeBoard); TotalMaybeBoard(ThreeBoard, FourBoard); return true; } } public void IncrediblyGoodMove(Chsq chsq) { } public boolean IsEnemyBishop(int i, int j, int k) { if((j>16) | (j<1) | (i>16) | (i<1)) return false; if(owner[MaybeBoard.sq_[i][j].side_]==0) return false; if (am_i_checkmated[MaybeBoard.sq_[i][j].side_]==true){return false;} if(owner[MaybeBoard.sq_[i][j].side_]==owner[k]) return false; if(MaybeBoard.sq_[i][j].piece_==4) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==9) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyEastPawn(int i, int j, int k) { if((j>16) | (j<1) | (i>16) | (i<1)) return false; if(owner[MaybeBoard.sq_[i][j].side_]==0) return false; if (am_i_checkmated[MaybeBoard.sq_[i][j].side_]==true){return false;} if(owner[MaybeBoard.sq_[i][j].side_]==owner[k]) return false; if(MaybeBoard.sq_[i][j].piece_==402) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==406) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==101) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==201) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyKing(int i, int j, int k) { if((j>16) | (j<1) | (i>16) | (i<1)) return false; if(owner[MaybeBoard.sq_[i][j].side_]==0) return false; if (am_i_checkmated[MaybeBoard.sq_[i][j].side_]==true){return false;} if(owner[MaybeBoard.sq_[i][j].side_]==owner[k]) return false; if(MaybeBoard.sq_[i][j].piece_==-1) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==-2) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==-69) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemySoldier(int i, int j, int k) { if((j>16) | (j<1) | (i>16) | (i<1)) return false; if(owner[MaybeBoard.sq_[i][j].side_]==0) return false; if (am_i_checkmated[MaybeBoard.sq_[i][j].side_]==true){return false;} if(owner[MaybeBoard.sq_[i][j].side_]==owner[k]) return false; if(MaybeBoard.sq_[i][j].piece_==25) { assailant_rank=i; assailant_file=j; return true; } return false; } public boolean IsEnemyKnight(int i, int j, int k) { if((j>16) | (j<1) | (i>16) | (i<1)) return false; if(owner[MaybeBoard.sq_[i][j].side_]==0) return false; if (am_i_checkmated[MaybeBoard.sq_[i][j].side_]==true){return false;} if(owner[MaybeBoard.sq_[i][j].side_]==owner[k]) return false; if((MaybeBoard.sq_[i][j].piece_==3)|(MaybeBoard.sq_[i][j].piece_==38)) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyAlfilDabbaba(int i, int j, int k) { if((j>16) | (j<1) | (i>16) | (i<1)) return false; if(owner[MaybeBoard.sq_[i][j].side_]==0) return false; if (am_i_checkmated[MaybeBoard.sq_[i][j].side_]==true){return false;} if(owner[MaybeBoard.sq_[i][j].side_]==owner[k]) return false; if((MaybeBoard.sq_[i][j].piece_==38)) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyNorthPawn(int i, int j, int k) { if((j>16) | (j<1) | (i>16) | (i<1)) return false; if(owner[MaybeBoard.sq_[i][j].side_]==0) return false; if(owner[MaybeBoard.sq_[i][j].side_]==owner[k]) return false; if (am_i_checkmated[MaybeBoard.sq_[i][j].side_]==true){return false;} if(MaybeBoard.sq_[i][j].piece_==401) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==405) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==104) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==204) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyRook(int i, int j, int k) { if((j>16) | (j<1) | (i>16) | (i<1)) return false; if(owner[MaybeBoard.sq_[i][j].side_]==0) return false; if (am_i_checkmated[MaybeBoard.sq_[i][j].side_]==true){return false;} if(owner[MaybeBoard.sq_[i][j].side_]==owner[k]) return false; if(MaybeBoard.sq_[i][j].piece_==6) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==5) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==9) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemySouthPawn(int i, int j, int k) { if((j>16) | (j<1) | (i>16) | (i<1)) return false; if(owner[MaybeBoard.sq_[i][j].side_]==0) return false; if (am_i_checkmated[MaybeBoard.sq_[i][j].side_]==true){return false;} if(owner[MaybeBoard.sq_[i][j].side_]==owner[k]) return false; if(MaybeBoard.sq_[i][j].piece_==403) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==407) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==102) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==202) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyWestPawn(int i, int j, int k) { if((j>16) | (j<1) | (i>16) | (i<1)) return false; if(owner[MaybeBoard.sq_[i][j].side_]==0) return false; if (am_i_checkmated[MaybeBoard.sq_[i][j].side_]==true){return false;} if(owner[MaybeBoard.sq_[i][j].side_]==owner[k]) return false; if(MaybeBoard.sq_[i][j].piece_==404) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==408) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==103) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==203) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsMyMoveListed() { for(x=1; x<=moveCounter; x++) if((MaybeMoves[x].endingsquare_.rank_==moveto_rank) & (MaybeMoves[x].endingsquare_.file_==moveto_file)) return true; return false; } public boolean IsMySideInCheck(int i) { for(xxx=1; xxx<17; xxx++) for(yyy=1; yyy<17; yyy++) { if((i==MaybeBoard.sq_[yyy][xxx].side_) & (MaybeBoard.sq_[yyy][xxx].piece_<0) && AmIUnderAttack(yyy, xxx, i)) { return true;} if((i==MaybeBoard.sq_[yyy][xxx].side_) & (i<4) & (konigsritter==true)&(MaybeBoard.sq_[yyy][xxx].piece_==9) && AmIUnderAttack(yyy, xxx, i)) { return true;} } return false; } public boolean IsTheGameOver() { if (GameOver==true){return true;} CountAllThePieces(); if( (QueenCount[1]==0)&(QueenCount[2]==0)&(QueenCount[3]==0)&(QueenCount[4]==0)& (RookCount[1]==0) & (RookCount[2]==0) & (PawnCount[1]==0) & (PawnCount[2]==0) &(RookCount[3]==0) & (RookCount[4]==0) & (PawnCount[3]==0) & (PawnCount[4]==0) ) { if( (BishopCount[1]+KnightCount[1]<2) & (BishopCount[2]+KnightCount[2]<2) &(BishopCount[3]+KnightCount[3]<2) & (BishopCount[4]+KnightCount[4]<2) ) GameOver=true; if (konigsritter==false){drawn_games++;ShowStatusQ("Lack of force!");} if (konigsritter==true){wins[4]++;ShowStatusQ("Lack of force! Black wins!");} return true; } else { return false; } } public void KillKing(int i) { for(xzm=1; xzm<17; xzm++) for(yzm=1; yzm<17; yzm++) if((NowBoard.sq_[yzm][xzm].side_==i) & (NowBoard.sq_[yzm][xzm].piece_<0)) { NowBoard.sq_[yzm][xzm].piece_=0; NowBoard.sq_[yzm][xzm].side_=0; } TotalMaybeBoard(NowBoard, MaybeBoard); TotalMaybeBoard(MaybeBoard, TwoBoard); TotalMaybeBoard(TwoBoard, ThreeBoard); TotalMaybeBoard(ThreeBoard, FourBoard); } public void LowRectangle(Graphics g) { g.setColor(niceblue); g.fillRect(510, 271, 300, 314); g.fillRect(0, 0, 300, 29);g.setColor(Color.black);g.setFont(f1);NameThisChessVariant(g); g.setColor(Color.black); g.setFont(f1);NameThisChessVariant(g); g.setColor(Color.black); g.setFont(f1); } public boolean MachineMoves(Graphics g, int i) { if(GameOver) return true; NegateGMCounts();goodmove1=0; goodmove2=0; goodmove3=0; goodmove4=0; goodmove5=0; goodmove6=0; goodmove7=0; goodmove8=0; goodmove9=0; goodmove10=0; moveCounter=0; if(!opening_library()) { gametreecounter=0; if(how_deep_to_seek>3) depth=1; bestvcom1=-5000; for(x_run[1]=1; x_run[1]<17; x_run[1]++) for(y_run[1]=1; y_run[1]<17; y_run[1]++) if(NowBoard.sq_[y_run[1]][x_run[1]].side_==i) findPieceMoves(g, NowBoard.sq_[y_run[1]][x_run[1]], NowBoard, MaybeBoard); depth=0; ShowStatusNothing(); ShowStatusNothing(); if(moveCounter==0) { System.out.println("No Moves"); WhoIsHuman[1]=true;WhoIsHuman[2]=true;WhoIsHuman[3]=true;WhoIsHuman[4]=true;ShowStatusQ("No Moves"); return false; } x=1+(int)Math.floor(Math.random() * (double)moveCounter); if(DCAssailants(MaybeMoves[x].endingsquare_.rank_, MaybeMoves[x].endingsquare_.file_, i)>Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][i]) x=1+(int)Math.floor(Math.random() * (double)moveCounter); if(goodmove1>0) x=goodmove1; if(goodmove2>0) x=goodmove2; if(goodmove3>0) x=goodmove3; if(goodmove4>0) x=goodmove4; if(goodmove5>0) x=goodmove5; if(goodmove6>0) x=goodmove6; if(goodmove7>0) x=goodmove7; if(goodmove8>0) x=goodmove8; if(goodmove9>0) x=goodmove9; if(goodmove10>0) x=goodmove10; moveto_file=MaybeMoves[x].endingsquare_.file_; moveto_rank=MaybeMoves[x].endingsquare_.rank_; mover_file=MaybeMoves[x].startingsquare_.file_; mover_rank=MaybeMoves[x].startingsquare_.rank_; } NormalMove(g); NowBoard.sq_[mover_rank][mover_file].DrawImperial3(g, 3, false,playing_as_teams,am_i_checkmated[NowBoard.sq_[mover_rank][mover_file].side_],konigsritter); NowBoard.sq_[moveto_rank][moveto_file].DrawImperial3(g, 3, false,playing_as_teams,am_i_checkmated[NowBoard.sq_[mover_rank][mover_file].side_],konigsritter); MaybeBoard.sq_[mover_rank][mover_file].side_=NowBoard.sq_[mover_rank][mover_file].side_; MaybeBoard.sq_[moveto_rank][moveto_file].side_=NowBoard.sq_[moveto_rank][moveto_file].side_; MaybeBoard.sq_[mover_rank][mover_file].piece_=NowBoard.sq_[mover_rank][mover_file].piece_; MaybeBoard.sq_[moveto_rank][moveto_file].piece_=NowBoard.sq_[moveto_rank][moveto_file].piece_; TotalMaybeBoard(NowBoard,MaybeBoard);DidICheckOrStalemate(g, i); if(GameOver) return true; if((fifty_move_rule>100) & (GameOver==false)) { fifty_move_rule=0; if (konigsritter==false){ ShowStatusQ("Draw by Fifty Move Rule!"); drawn_games++;} if (konigsritter==true){ ShowStatusQ("Fifty Move Rule! Black wins!"); wins[4]++;} GameOver=true; return false; } else { return true; } } public boolean MaybeAdd(Graphics g, Chsq chsq, CB18_18 cb18_18, CB18_18 cb18_18_1) { assailant_rank=0; assailant2_rank=0; assailant_file=0; assailant2_file=0; CheckSquare[depth]=false; SquatterOnCheckSquare[depth]=false; if((c[depth]<1) | (c[depth]>16) | (d[depth]<1) | (d[depth]>16)) return false; if(NowBoard.sq_[d[depth]][c[depth]].side_==10) return false; if(NowBoard.sq_[d[depth]][c[depth]].piece_==74) return false; if(!PassedOtherRequirementsToKeep(chsq, cb18_18, cb18_18_1)) return false; if((chsq.piece_==101) | (chsq.piece_==102) | (chsq.piece_==103) | (chsq.piece_==104) | (chsq.piece_==201) | (chsq.piece_==202) | (chsq.piece_==203) | (chsq.piece_==204) |(chsq.piece_==401)|(chsq.piece_==402)|(chsq.piece_==403)|(chsq.piece_==404)) if((c[depth]==chsq.file_) | (d[depth]==chsq.rank_)) { if(NowBoard.sq_[d[depth]][c[depth]].piece_ !=0) return false; } else if((NowBoard.sq_[d[depth]][c[depth]].piece_==0) & (!enpassant(chsq))) return false; if((NowBoard.sq_[d[depth]][c[depth]].side_==chsq.side_) & ((chsq.piece_ !=-2) | (NowBoard.sq_[d[depth]][c[depth]].piece_ !=6) | (AmIUnderAttack(chsq.rank_, chsq.file_, chsq.side_)))) return false; alterMaybeBoard(g, chsq, cb18_18.sq_[d[depth]][c[depth]], cb18_18, cb18_18_1); worried=AmIWorried(chsq.side_); if( (IsMySideInCheck(chsq.side_)==true)&(i_am_checkmated==false)&(i_am_stalemated==false)) { unalterMaybeBoard(g, chsq, cb18_18.sq_[d[depth]][c[depth]], cb18_18, cb18_18_1); CheckSquare[depth]=true; if(NowBoard.sq_[d[depth]][c[depth]].piece_ !=0) SquatterOnCheckSquare[depth]=true; return false; } /* if ((how_deep_to_seek<4)&(seek_sacrificial_wins==false)&(WhoIsHuman[whoseMove]==false)&(moveCounter>0)&(chsq.side_==whoseMove)) { if ((Attackers[d[depth]][c[depth]][3-chsq.side_]>0)&(chsq.strength()>NowBoard.sq_[d[depth]][c[depth]].strength())& ( (WeakestAttacker[d[depth]][c[depth]][3-chsq.side_]Attackers[d[depth]][c[depth]][chsq.side_]-1) ) &(IsMySideInCheck(3-chsq.side_)==false) /// HEEEERE ) { // SquatterOnCheckSquare[depth]=true; SquatterOnCheckSquare[depth]=false; if(NowBoard.sq_[d[depth]][c[depth]].piece_ !=0) SquatterOnCheckSquare[depth]=true; if (NowBoard.sq_[d[depth]][c[depth]].piece_==0){CheckSquare[depth]=true;} unalterMaybeBoard(g, chsq, cb18_18.sq_[d[depth]][c[depth]], cb18_18, cb18_18_1); return false; } } */ good_move=1; good_counter=1; if(moveCounter>500) good_move=1; for(; good_counter<=good_move; good_counter++) { moveCounter++; if ((halt_if_king_taken==true)&(skipDtGM==false)&(depth<2)&(NowBoard.sq_[d[depth]][c[depth]].piece_<0)){goodmove10=moveCounter;System.out.print("King captured on"+d[depth]+""+c[depth]+"; chsq_rank="+chsq.rank_+" chsq_file="+chsq.file_);WhoIsHuman[1]=true;WhoIsHuman[2]=true;WhoIsHuman[3]=true;WhoIsHuman[4]=true;} if (killing_yeenoghu==true) { // System.out.print("["+chsq.side_+""+chsq.piece_+""+chsq.rank_+""+chsq.file_+"-"+d[depth]+""+c[depth]); } MaybeMoves[moveCounter].startingsquare_=chsq; MaybeMoves[moveCounter].endingsquare_=NowBoard.sq_[d[depth]][c[depth]]; } DesignateTheGoodMoves(chsq); if((worried) & (IsThisAGoodMove()==false) & (moveCounter>1) & (!WhoIsHuman[whoseMove])) moveCounter--; unalterMaybeBoard(g, chsq, cb18_18.sq_[d[depth]][c[depth]], cb18_18, cb18_18_1); return NowBoard.sq_[d[depth]][c[depth]].side_==0; } public void MoreGoodMoves(Chsq chsq) { } public void AssignVariantName(){ variant_name="Imperial Chess III"; } public void NameThisChessVariant(Graphics g) { AssignVariantName(); g.setColor(niceblue); g.fillRect(0, 0, 300, 29); g.setColor(Color.black); g.setFont(f1);g.drawString(variant_name, 5, 15); } public void NextOrdinaryPlayer(Graphics g) { if(PromotingAPawn) return; IsTheGameOver(); if (GameOver==true){return;} do {whoseMove++; if (whoseMove==5){whoseMove=1;turncounter++;}}while (KingCount[whoseMove]==0); TotalMaybeBoard(NowBoard, MaybeBoard); i_am_checkmated=false;i_am_stalemated=false; moveCounter=0; xx=1;while ((xx<17)&(moveCounter==0)){ yy=1;while ((yy<17)&(moveCounter==0)){ if (NowBoard.sq_[yy][xx].side_==whoseMove) {findPieceMoves(g,NowBoard.sq_[yy][xx],NowBoard,MaybeBoard);} yy++;}xx++;} if (moveCounter==0) { if (IsMySideInCheck(whoseMove)==true){i_am_checkmated=true;} else {i_am_stalemated=true;} } if ((KingCount[1]+KingCount[2]+KingCount[3]+KingCount[4]==2)&((i_am_checkmated==true)|(i_am_stalemated==true))) { if ((KingCount[1]>0)&(whoseMove!=1)){wins[1]++;ShowStatusQ("Blue wins!");GameOver=true;return;} if ((KingCount[2]>0)&(whoseMove!=2)){wins[2]++;ShowStatusQ("Gold wins!");GameOver=true;return;} if ((KingCount[3]>0)&(whoseMove!=3)){wins[3]++;ShowStatusQ("Red wins!");GameOver=true;return;} if ((KingCount[4]>0)&(whoseMove!=4)){wins[4]++;ShowStatusQ("White wins!");GameOver=true;return;} } TwoAndUntwo(g); TotalMaybeBoard(NowBoard, MaybeBoard); TotalMaybeBoard(MaybeBoard, TwoBoard); TotalMaybeBoard(TwoBoard, ThreeBoard); TotalMaybeBoard(ThreeBoard, FourBoard); TwoAndUntwo(g); whatpiecescanmove(g); DrawNowBoard(g); } public void NightMoves(Chsq chsq) { } public int NightScore(Chsq chsq) { return 0; } public void EverybodyTurnsHuman(){ System.out.print("Everybody turns human"); WhoIsHuman[1]=true; WhoIsHuman[2]=true; WhoIsHuman[3]=true; WhoIsHuman[4]=true; } public void NormalMove(Graphics g) { // if (NowBoard.sq_[moveto_rank][moveto_file].piece_<0) // { System.out.println("mover_rank="+mover_rank+"mover_file="+mover_file+"moveto_rank="+moveto_rank+"moveto_file="+moveto_file); // EverybodyTurnsHuman(); // } //**System.out.println(""+NowBoard.sq_[mover_rank][mover_file].piece_+" "+mover_rank+""+mover_file+" "+moveto_rank+""+moveto_file); CastleStuff(); if(NowBoard.sq_[mover_rank][mover_file].piece_<0) { KingRank[whoseMove]=moveto_rank; KingFile[whoseMove]=moveto_file; } if(NowBoard.sq_[moveto_rank][moveto_file].piece_<0) { z=NowBoard.sq_[moveto_rank][moveto_file].side_; x=1;while (x<17){ y=1;while (y<17){ if (NowBoard.sq_[y][x].side_==z) { NowBoard.sq_[y][x].side_=0; NowBoard.sq_[y][x].piece_=0; } y++;}x++;} } if((NowBoard.sq_[moveto_rank][moveto_file].piece_==6) & (NowBoard.sq_[mover_rank][mover_file].piece_==-2)) IJustCastled=true; if((NowBoard.sq_[moveto_rank][moveto_file].piece_>0) | (NowBoard.sq_[mover_rank][mover_file].piece_>100)) { fifty_move_rule=0; } else { fifty_move_rule++; if(fifty_move_rule>fifties_got_to) fifties_got_to=fifty_move_rule; } if((NowBoard.sq_[moveto_rank][moveto_file].piece_<0) & (NowBoard.sq_[moveto_rank][moveto_file].side_ !=0)) { xxx=NowBoard.sq_[moveto_rank][moveto_file].side_; player_is_alive[xxx]=false; for(y_nm=1; y_nm<17; y_nm++) for(x_nm=1; x_nm<17; x_nm++) if(NowBoard.sq_[y_nm][x_nm].side_==xxx) { NowBoard.sq_[y_nm][x_nm].side_=whoseMove; NowBoard.sq_[y_nm][x_nm].DrawImperial3(g, 3, false,playing_as_teams,am_i_checkmated[NowBoard.sq_[y_nm][x_nm].side_],konigsritter); } } NowBoard.sq_[moveto_rank][moveto_file].side_=NowBoard.sq_[mover_rank][mover_file].side_; NowBoard.sq_[moveto_rank][moveto_file].piece_=NowBoard.sq_[mover_rank][mover_file].piece_; SupplementForInsaneChess(); NowBoard.sq_[mover_rank][mover_file].side_=0; NowBoard.sq_[mover_rank][mover_file].piece_=0; PromoStuff(g); TotalMaybeBoard(NowBoard, MaybeBoard); TotalMaybeBoard(MaybeBoard, TwoBoard); TotalMaybeBoard(TwoBoard, ThreeBoard); TotalMaybeBoard(ThreeBoard, FourBoard); ShowStatusNothing(); Archives(); inquire_about_terms(); if (WhoIsHuman[whoseMove]==true){SayWhoIsHuman(g);} } public boolean PassedOtherRequirementsToKeep(Chsq chsq, CB18_18 cb18_18, CB18_18 cb18_18_1) { return true; } public void PromoStuff(Graphics g) { } public boolean PromotionClicks(int i, int j) { if(j<300) return false; if(j>330) return false; if(i<120) return false; if(i>210) return false; if(i<150) xxx=5; else if(i<180) xxx=4; else xxx=3; return true; } public void SayWhoIsHuman(Graphics g) { DisplayRules(g); if(PromotingAPawn) return; g.setColor(niceblue); g.fillRect(510, 271, 300, 314); g.setColor(Color.black); g.setFont(f1); if(!PromotingAPawn) { if (playing_as_teams==false){ g.drawString("Blue:", 10+510, 290); g.drawString("Gold:", 10+510, 310); g.drawString("Red:", 10+510, 330); g.drawString("White:", 10+510, 350);} if (playing_as_teams==true){ g.drawString("Blue 1:", 10+510, 290); g.drawString("Red 1:", 10+510, 310); g.drawString("Blue 2:", 10+510, 330); g.drawString("Red 2:", 10+510, 350);} g.drawString("Computer", 120+510, 290); g.drawString("Computer", 120+510, 310); g.drawString("Computer", 120+510, 330); g.drawString("Computer", 120+510, 350); g.drawString("Human", 60+510, 290); g.drawString("Human", 60+510, 310); g.drawString("Human", 60+510, 330); g.drawString("Human", 60+510, 350); g.setFont(f1);NameThisChessVariant(g); if (playing_as_teams==false){ g.drawString("Blue: "+wins[1]+" Gold: "+wins[2]+" Red: "+wins[3]+" White: "+wins[4]+" Drawn: "+drawn_games, 5+510, 450);} if (playing_as_teams==true){ g.drawString("Blue: "+wins[1]+" Red: "+wins[2]+" Draw "+drawn_games, 5+510, 450);} g.setFont(f3); g.drawString("--Ed Friedlander", 215+490, 500); g.setFont(f2); if(humanizing) g.drawString("OKAY", 210+510, 300); g.setColor(Color.blue); if (playing_as_teams==true){g.setColor(Color.blue);} if(WhoIsHuman[1]) { g.drawRect(56+510, 276, 48, 18); g.drawRect(57+510, 277, 46, 16); } if(!WhoIsHuman[1]) { g.drawRect(117+510, 276, 61, 18); g.drawRect(118+510, 277, 59, 16); } g.setColor(Color.yellow); if (playing_as_teams==true){g.setColor(Color.red);} if(WhoIsHuman[2]) { g.drawRect(56+510, 296, 48, 18); g.drawRect(57+510, 297, 46, 16); } if(!WhoIsHuman[2]) { g.drawRect(117+510, 296, 61, 18); g.drawRect(118+510, 297, 59, 16); } g.setColor(Color.red); if (playing_as_teams==true){g.setColor(Color.blue);} if(WhoIsHuman[3]) { g.drawRect(56+510, 316, 48, 18); g.drawRect(57+510, 317, 46, 16); } if(!WhoIsHuman[3]) { g.drawRect(117+510, 316, 61, 18); g.drawRect(118+510, 317, 59, 16); } g.setColor(Color.white); if (playing_as_teams==true){g.setColor(Color.red);} if(WhoIsHuman[4]) { g.drawRect(56+510, 336, 48, 18); g.drawRect(57+510, 337, 46, 16); } if(!WhoIsHuman[4]) { g.drawRect(117+510, 336, 61, 18); g.drawRect(118+510, 337, 59, 16); } } if(PromotingAPawn) DrawPromotionOptions(g); } public void ShowStatusNothing() { if (GameOver==false){ShowStatusQ("");} } public void SetUpTheBoard(){ for(a=1; a<17; a++) for(b=1; b<17; b++) { NowBoard.sq_[b][a].piece_=0; NowBoard.sq_[b][a].side_=0; } for(x=5; x<13; x++) { NowBoard.sq_[1][x].side_=1; NowBoard.sq_[2][x].side_=1; NowBoard.sq_[2][x].piece_=104; NowBoard.sq_[16][x].side_=3; NowBoard.sq_[15][x].side_=3; NowBoard.sq_[15][x].piece_=102; NowBoard.sq_[x][16].side_=4; NowBoard.sq_[x][15].side_=4; NowBoard.sq_[x][15].piece_=103; NowBoard.sq_[x][1].side_=2; NowBoard.sq_[x][2].side_=2; NowBoard.sq_[x][2].piece_=101; } x=1;while (x<5){ y=1;while (y<5){ NowBoard.sq_[y][x].piece_=74; NowBoard.sq_[y][x].side_=0; NowBoard.sq_[y+12][x].piece_=74; NowBoard.sq_[y+12][x].side_=0; NowBoard.sq_[y][x+12].piece_=74; NowBoard.sq_[y][x+12].side_=0; NowBoard.sq_[y+12][x+12].piece_=74; NowBoard.sq_[y+12][x+12].side_=0; y++;}x++;} NowBoard.sq_[1][5].piece_=6; NowBoard.sq_[1][6].piece_=3; NowBoard.sq_[1][7].piece_=4; NowBoard.sq_[1][8].piece_=9; NowBoard.sq_[1][9].piece_=-2; NowBoard.sq_[1][10].piece_=4; NowBoard.sq_[1][11].piece_=3; NowBoard.sq_[1][12].piece_=6; NowBoard.sq_[16][5].piece_=6; NowBoard.sq_[16][6].piece_=3; NowBoard.sq_[16][7].piece_=4; NowBoard.sq_[16][8].piece_=9; NowBoard.sq_[16][9].piece_=-2; NowBoard.sq_[16][10].piece_=4; NowBoard.sq_[16][11].piece_=3; NowBoard.sq_[16][12].piece_=6; NowBoard.sq_[5][1].piece_=6; NowBoard.sq_[6][1].piece_=3; NowBoard.sq_[7][1].piece_=4; NowBoard.sq_[8][1].piece_=9; NowBoard.sq_[9][1].piece_=-2; NowBoard.sq_[10][1].piece_=4; NowBoard.sq_[11][1].piece_=3; NowBoard.sq_[12][1].piece_=6; NowBoard.sq_[5][16].piece_=6; NowBoard.sq_[6][16].piece_=3; NowBoard.sq_[7][16].piece_=4; NowBoard.sq_[8][16].piece_=9; NowBoard.sq_[9][16].piece_=-2; NowBoard.sq_[10][16].piece_=4; NowBoard.sq_[11][16].piece_=3; NowBoard.sq_[12][16].piece_=6; } public void StartUp(Graphics g) { turncounter=1;saved_fifty_move_rule=0;saved_turncounter=1;ShowStatusNothing(); killing_yeenoghu=false; i_am_checked[0]=false; i_am_checked[1]=false; i_am_checked[2]=false; i_am_checked[3]=false; i_am_checked[4]=false; am_i_checkmated[0]=false; am_i_checkmated[1]=false; am_i_checkmated[2]=false; am_i_checkmated[3]=false; am_i_checkmated[4]=false; i_am_checkmated=false; i_am_stalemated=false; accepted_terms=false; who_is_winning=0; SupplementalStartup(); player_is_alive[0]=true; player_is_alive[1]=true; player_is_alive[2]=true; player_is_alive[3]=true; player_is_alive[4]=true; SetUpTheBoard(); TotalMaybeBoard(NowBoard,MaybeBoard); whoseMove=1; ForGambler(g); GameOver=false; fifty_move_rule=0; whatpiecescanmove(g); DrawNowBoard(g); TotalSaveBoard(); TotalBackBoard(); } public void SupplementForInsaneChess() { } public void SupplementalAddAnAttacker() { } public boolean SupplementalAmIUnderAttackers(int i, int j, int k) { return false; } public boolean SupplementalAmIUnderSparrowAttackers(int i, int j, int k) { return false; } public void SupplementalInit() { konigsritter=false; cincinnati=false; playing_as_teams=false; halt_if_king_taken=false; } public void SupplementalMovers(Graphics g, Chsq chsq, CB18_18 cb18_18, CB18_18 cb18_18_1) { } public void SupplementalStartup() { IJustCastled=false; owner[0]=0; owner[1]=1; owner[2]=2; owner[3]=3; owner[4]=4; owner[5]=0; owner[6]=0; owner[7]=0; owner[8]=0; owner[9]=0; owner[10]=0; } public void TotalMaybeBoard(CB18_18 cb18_18, CB18_18 cb18_18_1) { for(xxx=1; xxx<17; xxx++) for(yyy=1; yyy<17; yyy++) { cb18_18_1.sq_[yyy][xxx].side_=cb18_18.sq_[yyy][xxx].side_; cb18_18_1.sq_[yyy][xxx].piece_=cb18_18.sq_[yyy][xxx].piece_; } } public void TwoAndUntwo(Graphics g) { if(NowBoard.sq_[moveto_rank][moveto_file].piece_==6) NowBoard.sq_[moveto_rank][moveto_file].piece_=5; if(NowBoard.sq_[moveto_rank][moveto_file].piece_==-2) NowBoard.sq_[moveto_rank][moveto_file].piece_=-1; if (konigsritter==true){return;} if(NowBoard.sq_[moveto_rank][moveto_file].piece_>100) { if ((NowBoard.sq_[moveto_rank][moveto_file].piece_!=103)&(NowBoard.sq_[moveto_rank][moveto_file].piece_!=203)&(moveto_file>12)) {NowBoard.sq_[moveto_rank][moveto_file].piece_=101;} if ((NowBoard.sq_[moveto_rank][moveto_file].piece_!=101)&(NowBoard.sq_[moveto_rank][moveto_file].piece_!=201)&(moveto_file<5)) {NowBoard.sq_[moveto_rank][moveto_file].piece_=103;} if ((NowBoard.sq_[moveto_rank][moveto_file].piece_!=104)&(NowBoard.sq_[moveto_rank][moveto_file].piece_!=204)&(moveto_rank<5)) {NowBoard.sq_[moveto_rank][moveto_file].piece_=102;} if ((NowBoard.sq_[moveto_rank][moveto_file].piece_!=102)&(NowBoard.sq_[moveto_rank][moveto_file].piece_!=202)&(moveto_rank>12)) {NowBoard.sq_[moveto_rank][moveto_file].piece_=104;} if ((moveto_rank==1)|(moveto_file==1)|(moveto_rank==16)|(moveto_file==16)) {NowBoard.sq_[moveto_rank][moveto_file].piece_=9;} if(NowBoard.sq_[moveto_rank][moveto_file+1].piece_==201) { NowBoard.sq_[moveto_rank][moveto_file+1].piece_=0; NowBoard.sq_[moveto_rank][moveto_file+1].side_=0; } if(NowBoard.sq_[moveto_rank-1][moveto_file].piece_==202) { NowBoard.sq_[moveto_rank-1][moveto_file].piece_=0; NowBoard.sq_[moveto_rank-1][moveto_file].side_=0; } if(NowBoard.sq_[moveto_rank][moveto_file-1].piece_==203) { NowBoard.sq_[moveto_rank][moveto_file-1].piece_=0; NowBoard.sq_[moveto_rank][moveto_file-1].side_=0; } if(NowBoard.sq_[moveto_rank+1][moveto_file].piece_==204) { NowBoard.sq_[moveto_rank+1][moveto_file].piece_=0; NowBoard.sq_[moveto_rank+1][moveto_file].side_=0; } } if(IJustCastled) { NowBoard.sq_[mover_rank][mover_file].piece_=5; NowBoard.sq_[mover_rank][mover_file].side_=whoseMove; } IJustCastled=false; for(xzm=1; xzm<17; xzm++) for(yzm=1; yzm<17; yzm++) if(NowBoard.sq_[yzm][xzm].side_==whoseMove) { if(NowBoard.sq_[yzm][xzm].piece_>200) NowBoard.sq_[yzm][xzm].piece_=NowBoard.sq_[yzm][xzm].piece_-100; if(NowBoard.sq_[yzm][xzm].piece_==-69) NowBoard.sq_[yzm][xzm].piece_=-1; } if( (NowBoard.sq_[moveto_rank][moveto_file].piece_>100) & (NowBoard.sq_[moveto_rank][moveto_file].piece_<200) && (moveto_rank-mover_rank>1) | (moveto_rank-mover_rank<-1) | (moveto_file-mover_file>1) | (moveto_file-mover_file<-1)) NowBoard.sq_[moveto_rank][moveto_file].piece_=NowBoard.sq_[moveto_rank][moveto_file].piece_+100; if(NowBoard.sq_[moveto_rank][moveto_file].piece_==-1 && (moveto_rank==8) & (moveto_file==8) & (whoseMove==1) | (moveto_rank==1) & (moveto_file==8) & (whoseMove==2) | (moveto_rank==1) & (moveto_file==1) & (whoseMove==3) | (moveto_rank==8) & (moveto_file==1) & (whoseMove==4)) NowBoard.sq_[moveto_rank][moveto_file].piece_=-69; DrawNowBoard(g); } public void ZeroAllFiveCounts() { PawnCount[0]=0; QueenCount[0]=0; KingCount[0]=0; RookCount[0]=0; BishopCount[0]=0; KnightCount[0]=0; PawnCount[1]=0; QueenCount[1]=0; KingCount[1]=0; RookCount[1]=0; BishopCount[1]=0; KnightCount[1]=0; PawnCount[2]=0; KingCount[2]=0; QueenCount[2]=0; RookCount[2]=0; BishopCount[2]=0; KnightCount[2]=0; PawnCount[3]=0; QueenCount[3]=0; KingCount[3]=0; RookCount[3]=0; BishopCount[3]=0; KnightCount[3]=0; PawnCount[4]=0; QueenCount[4]=0; KingCount[4]=0; RookCount[4]=0; BishopCount[4]=0; KnightCount[4]=0; } public void alterMaybeBoard(Graphics g, Chsq chsq, Chsq chsq1, CB18_18 cb18_18, CB18_18 cb18_18_1) { cb18_18_1.sq_[chsq.rank_][chsq.file_].piece_=0; cb18_18_1.sq_[chsq.rank_][chsq.file_].side_=0; cb18_18_1.sq_[chsq1.rank_][chsq1.file_].piece_=cb18_18.sq_[chsq.rank_][chsq.file_].piece_; cb18_18_1.sq_[chsq1.rank_][chsq1.file_].side_=cb18_18.sq_[chsq.rank_][chsq.file_].side_; if((cb18_18.sq_[chsq.rank_][chsq.file_].piece_>100) & (chsq.rank_ !=chsq1.rank_) & (chsq.file_ !=chsq1.file_)) { if(cb18_18.sq_[chsq1.rank_][chsq1.file_+1].piece_==201) { cb18_18_1.sq_[chsq1.rank_][chsq1.file_+1].piece_=0; cb18_18_1.sq_[chsq1.rank_][chsq1.file_+1].side_=0; } if(cb18_18.sq_[chsq1.rank_-1][chsq1.file_].piece_==202) { cb18_18_1.sq_[chsq1.rank_-1][chsq1.file_].piece_=0; cb18_18_1.sq_[chsq1.rank_-1][chsq1.file_].side_=0; } if(cb18_18.sq_[chsq1.rank_][chsq1.file_-1].piece_==203) { cb18_18_1.sq_[chsq1.rank_][chsq1.file_-1].piece_=0; cb18_18_1.sq_[chsq1.rank_][chsq1.file_-1].side_=0; } if(cb18_18.sq_[chsq1.rank_+1][chsq1.file_].piece_==204) { cb18_18_1.sq_[chsq1.rank_+1][chsq1.file_].piece_=0; cb18_18_1.sq_[chsq1.rank_+1][chsq1.file_].side_=0; } } if(cb18_18.sq_[chsq.rank_][chsq.file_].piece_==-2) { if (c[depth]==11) { cb18_18_1.sq_[chsq.rank_][12].piece_=0; cb18_18_1.sq_[chsq.rank_][12].side_=0; cb18_18_1.sq_[chsq.rank_][10].piece_=5; cb18_18_1.sq_[chsq.rank_][10].side_=chsq.side_; } if (c[depth]==7) { cb18_18_1.sq_[chsq.rank_][5].piece_=0; cb18_18_1.sq_[chsq.rank_][5].side_=0; cb18_18_1.sq_[chsq.rank_][8].piece_=5; cb18_18_1.sq_[chsq.rank_][8].side_=chsq.side_; } if (d[depth]==11) { cb18_18_1.sq_[12][chsq.file_].piece_=0; cb18_18_1.sq_[12][chsq.file_].side_=0; cb18_18_1.sq_[10][chsq.file_].piece_=5; cb18_18_1.sq_[10][chsq.file_].side_=chsq.side_; } if (d[depth]==7) { cb18_18_1.sq_[5][chsq.file_].piece_=0; cb18_18_1.sq_[5][chsq.file_].side_=0; cb18_18_1.sq_[8][chsq.file_].piece_=5; cb18_18_1.sq_[8][chsq.file_].side_=chsq.side_; } } } public boolean dcishuman() { if((!WhoIsHuman[1]) & (!WhoIsHuman[1]) & (!WhoIsHuman[1]) & (!WhoIsHuman[1])) return true; return WhoIsHuman[NowBoard.sq_[d[depth]][c[depth]].side_]; } public boolean enpassant(Chsq chsq) { if(chsq.piece_<100) return false; if(chsq.rank_==d[depth]) return false; if(chsq.file_==c[depth]) return false; if(NowBoard.sq_[d[depth]][c[depth]+1].piece_==201 && chsq.side_ !=2) return true; if(NowBoard.sq_[d[depth]-1][c[depth]].piece_==202 && chsq.side_ !=3) return true; if(NowBoard.sq_[d[depth]][c[depth]-1].piece_==203 && chsq.side_ !=4) return true; return NowBoard.sq_[d[depth]+1][c[depth]].piece_==204 && chsq.side_ !=1; } public boolean findPieceMoves(Graphics g, Chsq chsq, CB18_18 cb18_18, CB18_18 cb18_18_1) { CheckSquare[depth]=false; SquatterOnCheckSquare[depth]=false; SupplementalMovers(g, chsq, cb18_18, cb18_18_1); if((chsq.piece_==9) | (chsq.piece_==5) | (chsq.piece_==57) | (chsq.piece_==29) | (chsq.piece_==109) | (chsq.piece_==105) | (chsq.piece_==28) | (chsq.piece_==6)) { c[depth]=chsq.file_-1; for(d[depth]=chsq.rank_; (MaybeAdd(g, chsq, cb18_18, cb18_18_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (!SquatterOnCheckSquare[depth]); c[depth]=c[depth]-1); } if((chsq.piece_==9) | (chsq.piece_==5) | (chsq.piece_==57) | (chsq.piece_==29) | (chsq.piece_==109) | (chsq.piece_==105) | (chsq.piece_==28) | (chsq.piece_==6)) { c[depth]=chsq.file_+1; for(d[depth]=chsq.rank_; (MaybeAdd(g, chsq, cb18_18, cb18_18_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (!SquatterOnCheckSquare[depth]); c[depth]++); } if((chsq.piece_==9) | (chsq.piece_==5) | (chsq.piece_==57) | (chsq.piece_==29) | (chsq.piece_==109) | (chsq.piece_==105) | (chsq.piece_==28) | (chsq.piece_==6)) { c[depth]=chsq.file_; for(d[depth]=chsq.rank_-1; (MaybeAdd(g, chsq, cb18_18, cb18_18_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth]-1); } if((chsq.piece_==9) | (chsq.piece_==5) | (chsq.piece_==57) | (chsq.piece_==29) | (chsq.piece_==109) | (chsq.piece_==105) | (chsq.piece_==28) | (chsq.piece_==6)) { c[depth]=chsq.file_; for(d[depth]=chsq.rank_+1; (MaybeAdd(g, chsq, cb18_18, cb18_18_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (!SquatterOnCheckSquare[depth]); d[depth]++); } if (chsq.piece_==-2) { if (chsq.side_==1) { if ((NowBoard.sq_[1][10].piece_==0)&(NowBoard.sq_[1][11].piece_==0)&(NowBoard.sq_[1][12].piece_==6)) {c[depth]=11;d[depth]=1;MaybeAdd(g, chsq, cb18_18, cb18_18_1);} if ((NowBoard.sq_[1][8].piece_==0)&(NowBoard.sq_[1][7].piece_==0)&(NowBoard.sq_[1][6].piece_==0)&(NowBoard.sq_[1][5].piece_==6)) {c[depth]=7;d[depth]=1;MaybeAdd(g, chsq, cb18_18, cb18_18_1);} } if (chsq.side_==2) { if ((NowBoard.sq_[10][1].piece_==0)&(NowBoard.sq_[11][1].piece_==0)&(NowBoard.sq_[12][1].piece_==6)) {c[depth]=1;d[depth]=11;MaybeAdd(g, chsq, cb18_18, cb18_18_1);} if ((NowBoard.sq_[8][1].piece_==0)&(NowBoard.sq_[7][1].piece_==0)&(NowBoard.sq_[6][1].piece_==0)&(NowBoard.sq_[5][1].piece_==6)) {c[depth]=1;d[depth]=7;MaybeAdd(g, chsq, cb18_18, cb18_18_1);} } if (chsq.side_==3) { if ((NowBoard.sq_[16][10].piece_==0)&(NowBoard.sq_[16][11].piece_==0)&(NowBoard.sq_[16][12].piece_==6)) {c[depth]=11;d[depth]=16;MaybeAdd(g, chsq, cb18_18, cb18_18_1);} if ((NowBoard.sq_[16][8].piece_==0)&(NowBoard.sq_[16][7].piece_==0)&(NowBoard.sq_[16][6].piece_==0)&(NowBoard.sq_[16][5].piece_==6)) {c[depth]=7;d[depth]=16;MaybeAdd(g, chsq, cb18_18, cb18_18_1);} } if ((chsq.side_==4)&(konigsritter==false)) { if ((NowBoard.sq_[10][16].piece_==0)&(NowBoard.sq_[11][16].piece_==0)&(NowBoard.sq_[12][16].piece_==6)) {c[depth]=16;d[depth]=11;MaybeAdd(g, chsq, cb18_18, cb18_18_1);} if ((NowBoard.sq_[8][16].piece_==0)&(NowBoard.sq_[7][16].piece_==0)&(NowBoard.sq_[6][16].piece_==0)&(NowBoard.sq_[5][16].piece_==6)) {c[depth]=16;d[depth]=7;MaybeAdd(g, chsq, cb18_18, cb18_18_1);} } if ((chsq.side_==4)&(konigsritter==true)) { if ((NowBoard.sq_[11][16].piece_==0)&(NowBoard.sq_[12][16].piece_==0)&(NowBoard.sq_[13][16].piece_==0)&(NowBoard.sq_[14][16].piece_==6)) {c[depth]=16;d[depth]=12;MaybeAdd(g, chsq, cb18_18, cb18_18_1);} if ((NowBoard.sq_[9][16].piece_==0)&(NowBoard.sq_[8][16].piece_==0)&(NowBoard.sq_[7][16].piece_==6)) {c[depth]=16;d[depth]=8;MaybeAdd(g, chsq, cb18_18, cb18_18_1);} } } if((chsq.piece_==-1) | (chsq.piece_==-2) | (chsq.piece_==-69)| (chsq.piece_==25)) { c[depth]=chsq.file_+1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_; d[depth]=chsq.rank_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_-1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_; d[depth]=chsq.rank_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_+1; d[depth]=chsq.rank_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_+1; d[depth]=chsq.rank_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_-1; d[depth]=chsq.rank_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_-1; d[depth]=chsq.rank_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } if((chsq.piece_==9) | (chsq.piece_==4)) { c[depth]=chsq.file_-1; for(d[depth]=chsq.rank_-1; (MaybeAdd(g, chsq, cb18_18, cb18_18_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth]-1) c[depth]=c[depth]-1; } if((chsq.piece_==9) | (chsq.piece_==4)) { c[depth]=chsq.file_-1; for(d[depth]=chsq.rank_+1; (MaybeAdd(g, chsq, cb18_18, cb18_18_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth]+1) c[depth]=c[depth]-1; } if((chsq.piece_==9) | (chsq.piece_==4)) { c[depth]=chsq.file_+1; for(d[depth]=chsq.rank_-1; (MaybeAdd(g, chsq, cb18_18, cb18_18_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth]-1) c[depth]=c[depth]+1; } if((chsq.piece_==9) | (chsq.piece_==4)) { c[depth]=chsq.file_+1; for(d[depth]=chsq.rank_+1; (MaybeAdd(g, chsq, cb18_18, cb18_18_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth]+1) c[depth]=c[depth]+1; } if((chsq.piece_==3) | (chsq.piece_==38) | (chsq.piece_==-4) | (chsq.piece_==-5) | (chsq.piece_==57) | (chsq.piece_==29)) { c[depth]=chsq.file_-2; d[depth]=chsq.rank_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_-2; d[depth]=chsq.rank_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_+2; d[depth]=chsq.rank_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_+2; d[depth]=chsq.rank_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_-1; d[depth]=chsq.rank_-2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_-1; d[depth]=chsq.rank_+2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_+1; d[depth]=chsq.rank_-2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_+1; d[depth]=chsq.rank_+2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } if (chsq.piece_==38) { c[depth]=chsq.file_-2; d[depth]=chsq.rank_-2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_-2; d[depth]=chsq.rank_+2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_+2; d[depth]=chsq.rank_-2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_+2; d[depth]=chsq.rank_+2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_+2; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_-2; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_; d[depth]=chsq.rank_-2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_+2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } if((chsq.piece_==101) | (chsq.piece_==201)) { c[depth]=chsq.file_+1; d[depth]=chsq.rank_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_+1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); if((chsq.file_==2) & (NowBoard.sq_[d[depth]][c[depth]].piece_==0)) { c[depth]=chsq.file_+2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } c[depth]=chsq.file_+1; d[depth]=chsq.rank_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } if((chsq.piece_==102) | (chsq.piece_==202)) { d[depth]=chsq.rank_-1; c[depth]=chsq.file_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_-1; c[depth]=chsq.file_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); if((chsq.rank_==15) & (NowBoard.sq_[d[depth]][c[depth]].piece_==0)) { d[depth]=chsq.rank_-2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } d[depth]=chsq.rank_-1; c[depth]=chsq.file_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } if((chsq.piece_==103) | (chsq.piece_==203)) { c[depth]=chsq.file_-1; d[depth]=chsq.rank_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); c[depth]=chsq.file_-1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); if((chsq.file_==15) & (NowBoard.sq_[d[depth]][c[depth]].piece_==0)) { c[depth]=chsq.file_-2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } c[depth]=chsq.file_-1; d[depth]=chsq.rank_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } if((chsq.piece_==104) | (chsq.piece_==204)) { d[depth]=chsq.rank_+1; c[depth]=chsq.file_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_+1; c[depth]=chsq.file_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); if((chsq.rank_==2) & (NowBoard.sq_[d[depth]][c[depth]].piece_==0)) { d[depth]=chsq.rank_+2; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } d[depth]=chsq.rank_+1; c[depth]=chsq.file_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } if (chsq.piece_==401) { d[depth]=chsq.rank_+1;c[depth]=chsq.file_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); if (chsq.rank_==7) { if (NowBoard.sq_[d[depth]][c[depth]].piece_==0) { d[depth]++;MaybeAdd(g, chsq, cb18_18, cb18_18_1); } } else { d[depth]=chsq.rank_;c[depth]=chsq.file_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_;c[depth]=chsq.file_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } d[depth]=chsq.rank_+1;c[depth]=chsq.file_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_+1;c[depth]=chsq.file_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } if (chsq.piece_==403) { d[depth]=chsq.rank_-1;c[depth]=chsq.file_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); if (chsq.rank_==14) { if (NowBoard.sq_[d[depth]][c[depth]].piece_==0) { d[depth]--;MaybeAdd(g, chsq, cb18_18, cb18_18_1); } } else { d[depth]=chsq.rank_;c[depth]=chsq.file_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_;c[depth]=chsq.file_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } d[depth]=chsq.rank_-1;c[depth]=chsq.file_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_-1;c[depth]=chsq.file_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } if (chsq.piece_==402) { d[depth]=chsq.rank_;c[depth]=chsq.file_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); if (chsq.file_==3) { if (NowBoard.sq_[d[depth]][c[depth]].piece_==0) { c[depth]++;MaybeAdd(g, chsq, cb18_18, cb18_18_1); } } else { d[depth]=chsq.rank_+1;c[depth]=chsq.file_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_-1;c[depth]=chsq.file_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } d[depth]=chsq.rank_+1;c[depth]=chsq.file_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_-1;c[depth]=chsq.file_+1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } if (chsq.piece_==404) { d[depth]=chsq.rank_;c[depth]=chsq.file_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); if (chsq.file_==15) { if (NowBoard.sq_[d[depth]][c[depth]].piece_==0) { c[depth]--;MaybeAdd(g, chsq, cb18_18, cb18_18_1); } } else { d[depth]=chsq.rank_+1;c[depth]=chsq.file_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_-1;c[depth]=chsq.file_; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } d[depth]=chsq.rank_+1;c[depth]=chsq.file_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); d[depth]=chsq.rank_-1;c[depth]=chsq.file_-1; MaybeAdd(g, chsq, cb18_18, cb18_18_1); } return true; } public void init() { seek_sacrificial_wins=false; halt_if_king_taken=true; term_counts=new int[5]; best_four_count=new int[7]; c4_1=new Color(255, 0, 0); c4_2=new Color(0, 128, 0); niceblue=new Color(0, 192, 255); c4_3=new Color(255, 255, 0); c4_4=new Color(0, 0, 255); KingFile=new int[6]; KingRank=new int[6]; c4_5=new Color(128, 255, 255); PawnCount=new int[5]; owner=new int[11]; KnightCount=new int[5]; BishopCount=new int[5]; RookCount=new int[5]; QueenCount=new int[5]; KingCount=new int[5]; darkgreen=new Color(128, 128, 0); Attackers=new int[18][18][5]; StrongestAttacker=new int[18][18][5]; WeakestAttacker=new int[18][18][5]; NowBoard=new CB18_18(316); SaveBoard=new CB18_18(316); BackBoard=new CB18_18(316); MaybeBoard=new CB18_18(316); OneBoard=new CB18_18(316); TwoBoard=new CB18_18(316); ThreeBoard=new CB18_18(316); FourBoard=new CB18_18(316); ArchiveBoard=new CB18_18[102]; icanmove=new boolean[18][18]; am_i_checkmated=new boolean[5]; i_am_checked=new boolean[5]; happySquare=new Chsq(1, 1, 5, 1); MaybeMoves=new Chmo[1001]; c=new int[7]; d=new int[7]; x_run=new int[7]; y_run=new int[7]; z_run=new int[7]; CheckSquare=new boolean[7]; SquatterOnCheckSquare=new boolean[7]; f1=new Font("Arial", 0, 12); f2=new Font("Arial", 0, 18); f3=new Font("Arial", 0, 8); WhoIsHuman=new boolean[5]; player_is_alive=new boolean[5]; wins=new int[5]; depth=0; WhoIsHuman[1]=true; WhoIsHuman[2]=false; WhoIsHuman[3]=true; WhoIsHuman[4]=false; SupplementalInit(); GameOver=false; drawn_games=0; Graphics g=getGraphics(); setBackground(niceblue); markingAPiece=true; for(a=1; a<=1000; a++) MaybeMoves[a]=new Chmo(); WhoIsHuman[0]=true; WhoIsHuman[1]=true; WhoIsHuman[2]=false; WhoIsHuman[3]=false; WhoIsHuman[4]=false; wins[0]=0; wins[1]=0; wins[2]=0; millipede1=System.currentTimeMillis();for (xxx=0;xxx<102;xxx++){ArchiveBoard[xxx]=new CB18_18(316);} wins[3]=0; wins[4]=0; millipede2=System.currentTimeMillis(); how_deep_to_seek=1; StartUp(g); } public void inquire_about_terms() { } public boolean markAPiece(Graphics g, int i, int j) { if(NowBoard.sq_[i][j].side_ !=whoseMove) return false; moveCounter=0; c[depth]=j; d[depth]=i; mover_rank=i; mover_file=j; moveCounter=0; findPieceMoves(g, NowBoard.sq_[mover_rank][mover_file], NowBoard, MaybeBoard); if(moveCounter==0) { stringy=NowBoard.sq_[mover_rank][mover_file].moniker();ShowStatusQ("That "+stringy+" cannot move."); NowBoard.sq_[i][j].DrawImperial3(g, 3, false,playing_as_teams,am_i_checkmated[NowBoard.sq_[i][j].side_],konigsritter); return false; } NowBoard.sq_[i][j].DrawImperial3(g, 2, icanmove[i][j],playing_as_teams,am_i_checkmated[NowBoard.sq_[i][j].side_],konigsritter); for(x=1; x<=moveCounter; x++) MaybeMoves[x].endingsquare_.markexchsq(g,16); markingAPiece=false; return true; } public boolean mouseDown(Event event, int i, int j) { if(NowBoard==null) return true; Graphics g=getGraphics(); ShowStatusNothing(); if(!PromotingAPawn) SayWhoIsHuman(g); if(PromotingAPawn) DrawPromotionOptions(g); if(GameOver) { GameOver=false; StartUp(g); repaint(); return true; } if(!PromotingAPawn) { if((i-510>=56) & (j>=276) & (i-510<=104) & (j<=294)) { humanizing=true; WhoIsHuman[1]=true; SayWhoIsHuman(g); } else if((i-510>=117) & (j>=276) & (i-510<=178) & (j<=294)) { humanizing=true; WhoIsHuman[1]=false; SayWhoIsHuman(g); } else if((i-510>=56) & (j>=296) & (i-510<=104) & (j<=314)) { humanizing=true; WhoIsHuman[2]=true; SayWhoIsHuman(g); } else if((i-510>=117) & (j>=296) & (i-510<=178) & (j<=314)) { humanizing=true; WhoIsHuman[2]=false; SayWhoIsHuman(g); } else if((i-510>=26) & (j>356) & (i-510<=93) & (j<=374)) { if(who_is_winning==0) return true; humanizing=true; accepted_terms=true; SayWhoIsHuman(g); } else if((i-510>=147) & (j>=356) & (i-510<242) & (j<374)) { if(who_is_winning==0) return true; humanizing=true; accepted_terms=false; SayWhoIsHuman(g); } else if((i-510>=56) & (j>=316) & (i-510<=104) & (j<=334)) { humanizing=true; WhoIsHuman[3]=true; SayWhoIsHuman(g); } else if((i-510>=117) & (j>=316) & (i-510<=178) & (j<=334)) { humanizing=true; WhoIsHuman[3]=false; SayWhoIsHuman(g); } else if((i-510>=56) & (j>=336) & (i-510<=104) & (j<=354)) { humanizing=true; WhoIsHuman[4]=true; SayWhoIsHuman(g); } else if((i-510>=117) & (j>=336) & (i-510<=178) & (j<=354)) { humanizing=true; WhoIsHuman[4]=false; SayWhoIsHuman(g); } else if((i-510>=210) & (j>=285) & (i-510<270) & (j<320)) { humanizing=false; SayWhoIsHuman(g); if(accepted_terms) { if(who_is_winning !=0) GameOver=true; if(who_is_winning==1) wins[1]++; if(who_is_winning==2) wins[2]++; if(who_is_winning==3) drawn_games++; if(who_is_winning !=0) { StartUp(g); repaint(); markingAPiece=true; return true; } } } if(humanizing) return true; } if(PromotingAPawn) { if(!PromotionClicks(i, j)) return true; NowBoard.sq_[queening_rank][queening_file].piece_=xxx; MaybeBoard.sq_[queening_rank][queening_file].piece_=xxx; NowBoard.sq_[queening_rank][queening_file].DrawImperial3(g, 1, false,playing_as_teams,am_i_checkmated[NowBoard.sq_[queening_rank][queening_file].side_],konigsritter); TotalMaybeBoard(NowBoard,MaybeBoard);DidICheckOrStalemate(g, whoseMove); PromotingAPawn=false; if (WhoIsHuman[whoseMove]==true){SayWhoIsHuman(g);} NextOrdinaryPlayer(g); if(WhoIsHuman[whoseMove]) { markingAPiece=true; return true; } } a=i / 30; b=17-j / 30; if((a<1) | (a>16) | (b<1) | (b>16) && WhoIsHuman[whoseMove]) return true; if(WhoIsHuman[owner[whoseMove]]) if(markingAPiece) markAPiece(g, b, a); else if(HumanMoveAPiece(g, b, a)) { if(GameOver) return true; NextOrdinaryPlayer(g); } while((!WhoIsHuman[owner[whoseMove]]) & (!GameOver)) { MachineMoves(g, whoseMove); if(GameOver) return true; NextOrdinaryPlayer(g); if(WhoIsHuman[owner[whoseMove]]) markingAPiece=true; } return true; } public boolean opening_library() { return false; } public void paint(Graphics g) { setBackground(niceblue); if(NowBoard==null) { g.setColor(Color.black); g.setFont(f1); AssignVariantName();g.drawString("Thank you for playing "+variant_name+"!", 5, 20); // g.drawString("Final totals: White "+wins[1]+" Red "+wins[2]+" Drawn "+drawn_games, 5, 50); g.drawString("Final totals: Blue: "+wins[1]+" Gold: "+wins[2]+" Red: "+wins[3]+" White: "+wins[4]+" Draw "+drawn_games, 5+510, 450); return; } DrawNowBoard(g); g.setColor(niceblue); g.fillRect(510, 271, 300, 29);g.setColor(Color.black);g.setFont(f1);NameThisChessVariant(g); g.setColor(Color.black); g.setFont(f1); g.setColor(Color.black); SayWhoIsHuman(g); if((!markingAPiece) & (WhoIsHuman[owner[whoseMove]])) { NowBoard.sq_[mover_rank][mover_file].DrawImperial3(g, 2,icanmove[mover_rank][mover_file],playing_as_teams,am_i_checkmated[NowBoard.sq_[mover_rank][mover_file].side_],konigsritter); for(x=1; x<=moveCounter; x++) MaybeMoves[x].endingsquare_.markexchsq(g,16); } } public boolean paralyzed(Graphics g, int i) { if(i==0) return true; if(owner[i]==0) return true; moveCounter=0; for(xzm=1; xzm<17; xzm++) for(yzm=1; yzm<17; yzm++) { if(NowBoard.sq_[yzm][xzm].side_==i) findPieceMoves(g, NowBoard.sq_[yzm][xzm], NowBoard, MaybeBoard); if(moveCounter>0) return false; } return true; } public void stalemate(int i) { if(owner[i]==0) return; moveCounter=0; for(xzm=1; xzm<17; xzm++) for(yzm=1; yzm<17; yzm++) if(NowBoard.sq_[yzm][xzm].side_==i) { if(NowBoard.sq_[yzm][xzm].piece_>0) { NowBoard.sq_[yzm][xzm].piece_=0; NowBoard.sq_[yzm][xzm].side_=0; } if(NowBoard.sq_[yzm][xzm].piece_<0) NowBoard.sq_[yzm][xzm].side_=0; } } public void stop() { NowBoard=null; MaybeBoard=null; OneBoard=null; TwoBoard=null; ThreeBoard=null; FourBoard=null; ArchiveBoard=null; MaybeMoves=null; Attackers=null; destroy(); } public void unalterMaybeBoard(Graphics g, Chsq chsq, Chsq chsq1, CB18_18 cb18_18, CB18_18 cb18_18_1) { TotalMaybeBoard(cb18_18, cb18_18_1); } public void whatpiecescanmove(Graphics g) { for(ee=1; ee<17; ee++) for(ff=1; ff<17; ff++) { icanmove[ff][ee]=false; moveCounter=0; if(NowBoard.sq_[ff][ee].piece_<0) { KingRank[NowBoard.sq_[ff][ee].side_]=ff; KingFile[NowBoard.sq_[ff][ee].side_]=ee; } if(whoseMove==NowBoard.sq_[ff][ee].side_) { skipDtGM=true; findPieceMoves(g, NowBoard.sq_[ff][ee], NowBoard, MaybeBoard); skipDtGM=false; if(moveCounter>0) { icanmove[ff][ee]=true; } } } DrawNowBoard(g); } static String variant_name; int term_counts[]; static boolean accepted_terms; static int who_is_winning; static int how_deep_to_seek; public static long millipede1; public static long millipede2; static int gametreecounter; int best_four_count[]; static int vcom1; static int vcom2; static int vcom3; static int vcom4; static int bestvcom1; static int bestvcom2; static int bestvcom3; static int bestvcom4; static int cee; static int dee; static int eee; static int xee; static int yee; static int assailant_rank; static int assailant_file; static int assailant2_rank; static int assailant2_file; static boolean skipDtGM; static boolean worried; Color c4_1; static int strategos; Color c4_2; Color niceblue; Color c4_3; Color c4_4; int KingFile[]; int KingRank[]; Color c4_5; static int xzm; static int yzm; static int zzz; int PawnCount[]; int owner[]; int KnightCount[]; int BishopCount[]; int RookCount[]; int QueenCount[]; int KingCount[]; Color darkgreen; int Attackers[][][]; int StrongestAttacker[][][]; int WeakestAttacker[][][]; CB18_18 NowBoard; CB18_18 BackBoard; CB18_18 SaveBoard; CB18_18 MaybeBoard; CB18_18 OneBoard; CB18_18 TwoBoard; CB18_18 ThreeBoard; CB18_18 FourBoard; CB18_18 ArchiveBoard[]; boolean icanmove[][]; Chsq happySquare; Chmo MaybeMoves[]; static int ArchiveCounter; static int fifties_got_to; static int goodmove1; static int goodmove2; static int goodmove3; static int goodmove4; static int goodmove5; static int goodmove6; static int goodmove7; static int goodmove8; static int goodmove9; static int goodmove10; static int GM1count; static int GM2count; static int GM3count; static int GM4count; static int GM5count; static int GM6count; static int GM7count; static int GM8count; static int GM9count; static int GM10count; int c[]; int d[]; int x_run[]; int y_run[]; int z_run[]; static int x; static int y; static int z; static int a; static int b; static int depth; static int e; static int f; static int h; static int moveCounter; static int xx; static int yy; static int cc; static int dd; static int ee; static int ff; static int xxx; static int yyy; static int x_diham; static int y_diham; static int x_nm; static int y_nm; static int satt; static int patt; static int zatt; static int yatt; static int xatt; static int datt; static int catt; static int xq; static int yq; static int good_move; static int good_counter; boolean CheckSquare[]; boolean SquatterOnCheckSquare[]; boolean am_i_checkmated[]; boolean i_am_checked[]; static boolean markingAPiece; static boolean GameOver; static boolean humanizing; static boolean IJustCastled; static boolean PromotingAPawn; static int mover_rank; static int mover_file; static int moveto_rank; static int moveto_file; static int queening_rank; static int queening_file; Font f1; Font f2; Font f3; static int drawn_games; static int fifty_move_rule; static int whoseMove; boolean WhoIsHuman[]; boolean player_is_alive[]; int wins[]; static String stringy; static boolean i_am_checkmated; static boolean i_am_stalemated; static boolean halt_if_king_taken; static boolean playing_as_teams; static boolean cincinnati; static boolean seek_sacrificial_wins; static boolean konigsritter; static boolean killing_yeenoghu; static int turncounter;static int saved_turncounter;static int back_turncounter;static int saved_fifty_move_rule;static int back_fifty_move_rule; static char oopsKey; static char loadKey; static char saveKey; static int who_backed; static int who_saved;static int when_saved; }