// 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: OblongCh.java import java.applet.Applet; import java.awt.*; public class OblongCh extends Applet { public OblongCh() { } 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) { 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) { 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 < 5; 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 < 5; 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 < 5; 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 < 5; 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 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 draw_bone(Graphics g){ g.setColor(Color.orange); if (whoseMove==1){g.setColor(Color.white);} if (whoseMove==2){g.setColor(Color.red);} g.fillRect(450,185,43,43); g.setColor(Color.black); g.drawRect(450, 185, 43, 43); g.drawRect(451, 186, 41, 41); if((dice_roll == 2) | (dice_roll == 3) | (dice_roll == 4) | (dice_roll == 5) | (dice_roll == 6)) g.fillOval(454, 189, 7, 7); if((dice_roll == 1) | (dice_roll == 3) | (dice_roll == 5)) g.fillOval(469, 205, 7, 7); if((dice_roll == 2) | (dice_roll == 3) | (dice_roll == 4) | (dice_roll == 5) | (dice_roll == 6)) g.fillOval(484, 219, 7, 7); if((dice_roll == 4) | (dice_roll == 5) | (dice_roll == 6)) g.fillOval(454, 219, 7, 7); if((dice_roll == 4) | (dice_roll == 5) | (dice_roll == 6)) g.fillOval(484, 189, 7, 7); if(dice_roll == 6) g.fillOval(484, 205, 7, 7); if(dice_roll == 6) g.fillOval(454, 205, 7, 7); } 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 void AddAnAttacker() { if((xatt == catt) & (yatt == datt)) return; if((catt > 16) | (datt > 4) | (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; for(dd=i + 1; (cc < 17) & (dd < 5);) if(MaybeBoard.sq_[dd][cc].side_ == k) { cc=20; } else { if(IsEnemyBishop(dd, cc)) 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)) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) cc=20; cc++; dd--; } cc=j - 1; for(dd=i + 1; (cc > 0) & (dd < 5);) if(MaybeBoard.sq_[dd][cc].side_ == k) { cc=-1; } else { if(IsEnemyBishop(dd, cc)) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) cc=-1; cc--; dd++; } cc=j - 1; for(dd=i - 1; (cc > 0) & (dd > 0);) if(MaybeBoard.sq_[dd][cc].side_ == k) { cc=-1; } else { if(IsEnemyBishop(dd, cc)) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) cc=-1; cc--; dd--; } cc=j + 1; dd=i; while(cc < 17) if(MaybeBoard.sq_[dd][cc].side_ == k) { cc=20; } else { if(IsEnemyRook(dd, cc)) 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=-1; } else { if(IsEnemyRook(dd, cc)) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) cc=-1; cc--; } cc=j; for(dd=i + 1; dd < 5;) if(MaybeBoard.sq_[dd][cc].side_ == k) { dd=10; } else { if(IsEnemyRook(dd, cc)) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) dd=10; dd++; } cc=j; for(dd=i - 1; dd > 0;) if(MaybeBoard.sq_[dd][cc].side_ == k) { dd=-1; } else { if(IsEnemyRook(dd, cc)) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) dd=-1; dd--; } 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 - 2; dd=i - 2; if(IsEnemyElephant(dd, cc, k)) return true; cc=j - 2; dd=i + 2; if(IsEnemyElephant(dd, cc, k)) return true; cc=j + 2; dd=i - 2; if(IsEnemyElephant(dd, cc, k)) return true; cc=j + 2; dd=i + 2; if(IsEnemyElephant(dd, cc, k)) return true; cc=j - 1; dd=i - 1; if(IsEnemyFerz(dd, cc, k)) return true; cc=j - 1; dd=i + 1; if(IsEnemyFerz(dd, cc, k)) return true; cc=j + 1; dd=i - 1; if(IsEnemyFerz(dd, cc, k)) return true; cc=j + 1; dd=i + 1; if(IsEnemyFerz(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; if(k != 1) { cc=j - 1; dd=i + 1; if(IsEnemyPawn(dd, cc, k)) return true; cc=j - 1; dd=i - 1; if(IsEnemyPawn(dd, cc, k)) return true; } if(k != 2) { cc=j + 1; dd=i + 1; if(IsEnemyPawn(dd, cc, k)) return true; cc=j + 1; dd=i - 1; if(IsEnemyPawn(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; for(dd=i + 1; (cc < 17) & (dd < 5);) if(MaybeBoard.sq_[dd][cc].side_ == k) { cc=20; } else { if(IsEnemyBishop(dd, cc) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) 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) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) cc=20; cc++; dd--; } cc=j - 1; for(dd=i + 1; (cc > 0) & (dd < 5);) if(MaybeBoard.sq_[dd][cc].side_ == k) { cc=-1; } else { if(IsEnemyBishop(dd, cc) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) cc=-1; cc--; dd++; } cc=j - 1; for(dd=i - 1; (cc > 0) & (dd > 0);) if(MaybeBoard.sq_[dd][cc].side_ == k) { cc=-1; } else { if(IsEnemyBishop(dd, cc) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) cc=-1; cc--; dd--; } cc=j + 1; dd=i; while(cc < 17) if(MaybeBoard.sq_[dd][cc].side_ == k) { cc=20; } else { if(IsEnemyRook(dd, cc) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) 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=-1; } else { if(IsEnemyRook(dd, cc) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) cc=-1; cc--; } cc=j; for(dd=i + 1; dd < 5;) if(MaybeBoard.sq_[dd][cc].side_ == k) { dd=10; } else { if(IsEnemyRook(dd, cc) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) dd=10; dd++; } cc=j; for(dd=i - 1; dd > 0;) if(MaybeBoard.sq_[dd][cc].side_ == k) { dd=-1; } else { if(IsEnemyRook(dd, cc) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; if(MaybeBoard.sq_[dd][cc].piece_ != 0) dd=-1; dd--; } cc=j - 1; dd=i - 1; if(IsEnemyKing(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 1; dd=i; if(IsEnemyKing(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 1; dd=i + 1; if(IsEnemyKing(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j; dd=i - 1; if(IsEnemyKing(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j; dd=i + 1; if(IsEnemyKing(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 1; dd=i - 1; if(IsEnemyKing(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 1; dd=i; if(IsEnemyKing(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 1; dd=i + 1; if(IsEnemyKing(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 2; dd=i - 2; if(IsEnemyElephant(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 2; dd=i + 2; if(IsEnemyElephant(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 2; dd=i - 2; if(IsEnemyElephant(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 2; dd=i + 2; if(IsEnemyElephant(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 1; dd=i - 1; if(IsEnemyFerz(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 1; dd=i + 1; if(IsEnemyFerz(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 1; dd=i - 1; if(IsEnemyFerz(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 1; dd=i + 1; if(IsEnemyFerz(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 2; dd=i - 1; if(IsEnemyKnight(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 2; dd=i + 1; if(IsEnemyKnight(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 2; dd=i - 1; if(IsEnemyKnight(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 2; dd=i + 1; if(IsEnemyKnight(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 1; dd=i - 2; if(IsEnemyKnight(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 1; dd=i + 2; if(IsEnemyKnight(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 1; dd=i - 2; if(IsEnemyKnight(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 1; dd=i + 2; if(IsEnemyKnight(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; if(k != 1) { cc=j - 1; dd=i + 1; if(IsEnemyPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 1; dd=i - 1; if(IsEnemyPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; } if(k != 2) { cc=j + 1; dd=i + 1; if(IsEnemyPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 1; dd=i - 1; if(IsEnemyPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; } cc=j - 1; dd=i + 1; if(IsEnemyEastPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 1; dd=i - 1; if(IsEnemyEastPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 1; dd=i + 1; if(IsEnemyWestPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j + 1; dd=i - 1; return IsEnemyWestPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength(); } public boolean AmIWorried(int i) { if((skipDtGM) | (depth > 1)) return false; if(i != whoseMove) return false; for(xxx=1; xxx < 17; xxx++) for(yyy=1; yyy < 5; 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() { ArchiveCounter=0; for(ff=1; ff < 6; ff++) for(ee=1; ee < 18; 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; xxx < fifty_move_rule; xxx++) { if(DoesArchiveMatchNowBoard()) ArchiveCounter++; if(ArchiveCounter > 1) { drawn_games++; ShowStatusQ("Draw By Repetition"); GameOver=true; return; } } } public void BareKing() { int ai[]=new int[3]; int ai1[]=new int[3]; int ai2[]=new int[3]; int ai3[]=new int[3]; int ai4[]=new int[3]; ai[1]=0; ai[2]=0; ai1[1]=0; ai1[2]=0; ai2[1]=0; ai2[2]=0; ai3[1]=0; ai3[2]=0; ai4[1]=0; ai4[2]=0; for(int i=1; i < 17; i++) { for(int j=1; j < 5; j++) { if(NowBoard.sq_[j][i].piece_ < 0) { ai[NowBoard.sq_[j][i].side_]=j; ai1[NowBoard.sq_[j][i].side_]=i; } if(NowBoard.sq_[j][i].piece_ > 0) { ai4[NowBoard.sq_[j][i].side_]++; ai2[NowBoard.sq_[j][i].side_]=j; ai3[NowBoard.sq_[j][i].side_]=i; } } } if((ai4[1] == 0) & (ai4[2] == 0)) { GameOver=true; drawn_games++; ShowStatusQ("Draw!"); return; } if(ai4[1] == 0) { GameOver=true; if((ai4[2] > 1) | (ai2[2] - ai[1] < -1) | (ai2[2] - ai[1] > 1) | (ai3[2] - ai1[1] < -1) | (ai3[2] - ai1[1] > 1)) { ShowStatusQ("Bare king loses!"); wins[2]++; } else { ShowStatusQ("Bare king draws!"); drawn_games++; } return; } if(ai4[2] == 0) { GameOver=true; if((ai4[1] > 1) | (ai2[1] - ai[2] < -1) | (ai2[1] - ai[2] > 1) | (ai3[1] - ai1[2] < -1) | (ai3[1] - ai1[2] > 1)) { ShowStatusQ("Bare king loses!"); wins[1]++; } else { ShowStatusQ("Bare king draws!"); drawn_games++; } return; } else { return; } } public void CountAllThePieces() { ZeroAllFiveCounts(); for(xxx=1; xxx < 17; xxx++) for(yyy=1; yyy < 5; yyy++) switch(NowBoard.sq_[yyy][xxx].piece_) { case 1: // '\001' PawnCount[NowBoard.sq_[yyy][xxx].side_]++; break; case 2: // '\002' PawnCount[NowBoard.sq_[yyy][xxx].side_]++; break; case 3: // '\003' KnightCount[NowBoard.sq_[yyy][xxx].side_]++; break; case 4: // '\004' BishopCount[NowBoard.sq_[yyy][xxx].side_]++; break; case 5: // '\005' RookCount[NowBoard.sq_[yyy][xxx].side_]++; break; case 6: // '\006' RookCount[NowBoard.sq_[yyy][xxx].side_]++; break; case 22: // '\026' QueenCount[NowBoard.sq_[yyy][xxx].side_]++; break; case 23: // '\027' QueenCount[NowBoard.sq_[yyy][xxx].side_]++; break; case -1: KingCount[NowBoard.sq_[yyy][xxx].side_]++; break; case -2: KingCount[NowBoard.sq_[yyy][xxx].side_]++; break; } } public void DesignateTheFineMoves(Chsq chsq) { good_move=1; if((skipDtGM) | (depth > 1) | (worried)) return; if(IsMySideInCheck(3 - chsq.side_)) good_move += 5; if(chsq.strength() < NowBoard.sq_[d[depth]][c[depth]].strength()) good_move=(good_move + 3 * NowBoard.sq_[d[depth]][c[depth]].strength()) - chsq.strength(); if((Attackers[chsq.rank_][chsq.file_][3 - chsq.side_] > 0) & (AmIUnderAttack(d[depth],c[depth],whoseMove)==false)) good_move += 5 * chsq.strength(); if((NowBoard.sq_[d[depth]][c[depth]].piece_ > 0) & (Attackers[d[depth]][c[depth]][chsq.side_] > Attackers[d[depth]][c[depth]][3 - chsq.side_])) good_move += 3 * NowBoard.sq_[d[depth]][c[depth]].strength(); } public void DesignateTheGoodMoves(Chsq chsq) { if((whoseMove != chsq.side_) | ((skipDtGM) | (depth > 1))) return; IncrediblyGoodMove(chsq); if ((Attackers[chsq.rank_][chsq.file_][3-chsq.side_]>Attackers[chsq.rank_][chsq.file_][chsq.side_])) { if (AmIUnderAttack(d[depth],c[depth],3-chsq.side_)==true) AssignGoodMove1(); } /*winner tries to exchange*/ if ((term_counts[chsq.side_]>term_counts[3-chsq.side_])&(chsq.strength()<=NowBoard.sq_[d[depth]][c[depth]].strength())) { switch(chsq.strength()){ case 5:{AssignGoodMove9();break;} case 4:{AssignGoodMove8();break;} case 3:{AssignGoodMove6();break;} case 2:{AssignGoodMove4();break;} case 1:{AssignGoodMove1();break;} } } if((AmIUnderAttack(d[depth],c[depth],whoseMove)==false) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) && Math.random() * 100D < 99D) AssignGoodMove9(); if(NowBoard.sq_[d[depth]][c[depth]].strength() > 1 + chsq.strength() && Math.random() * 100D < 98D && !worried) AssignGoodMove9(); if(NowBoard.sq_[d[depth]][c[depth]].strength() > 2 + chsq.strength() && !worried) AssignGoodMove9(); if((chsq.strength() > 3) & (Attackers[chsq.rank_][chsq.file_][3 - chsq.side_] > 0) & (AmIUnderAttack(d[depth],c[depth],whoseMove)==false) && (Math.random() * 100D <98D && !worried)) {AssignGoodMove8();if (NowBoard.sq_[d[depth]][c[depth]].piece_!=0){AssignGoodMove9();}} if((AmIUnderAttack(d[depth],c[depth],whoseMove)==false) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) && (Math.random() * 100D <98D && !worried)) AssignGoodMove7(); if((chsq.strength() < 3) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) && (Math.random() * 100D <98D && !worried)) AssignGoodMove6(); if((chsq.strength() > 2) & (Attackers[chsq.rank_][chsq.file_][3 - chsq.side_] > 0) & (AmIUnderAttack(d[depth],c[depth],whoseMove)==false) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove5(); if((AmIUnderAttack(d[depth],c[depth],whoseMove)==false) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 1) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove4(); if(chsq.strength() < NowBoard.sq_[d[depth]][c[depth]].strength() && Math.random() * 100D < 98D && !worried) AssignGoodMove3(); if((AmIUnderAttack(d[depth],c[depth],whoseMove)==false) & (IsMySideInCheck(3 - chsq.side_)) && (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) & (AmIUnderAttack(d[depth],c[depth],whoseMove)==false)) AssignGoodMove1(); if((WeakestAttacker[d[depth]][c[depth]][3-chsq.side_]>=chsq.strength())&(Attackers[d[depth]][c[depth]][3 - chsq.side_] < Attackers[d[depth]][c[depth]][chsq.side_]) & (NowBoard.sq_[d[depth]][c[depth]].piece_ != 0) && (Math.random() * 100D <98D && !worried)) AssignGoodMove1(); MoreGoodMoves(chsq); NightMoves(chsq); } public void DidICheckOrStalemate(Graphics g, int i) { IsTheGameOver(); if(GameOver) return; if(use_dice) return; CountAllThePieces();if(AnotherWayToEndGame(g, i)) { GameOver=true; return; } moveCounter=0; for(xx=1; (xx < 17) & (moveCounter == 0); xx++) for(yy=1; (yy < 5) & (moveCounter == 0); yy++) if(NowBoard.sq_[yy][xx].side_ == 3 - i) findPieceMoves(g, NowBoard.sq_[yy][xx], NowBoard, MaybeBoard); if(IsMySideInCheck(3 - i)) { if((moveCounter == 0) & (!use_dice)) { ShowStatusQ("Checkmate!"); GameOver=true; wins[i]=wins[i] + 1; return; } ShowStatusQ("Check!"); } else if((moveCounter == 0) & (!use_dice)) { ShowStatusQ("Stalemate!"); GameOver=true; drawn_games++; return; } } public void DisplayRules(Graphics g) { LowRectangle(g); g.drawString("This is a very old variant of Shatranj", 5, 175); g.drawString("with a variety of possible setups.", 5, 291); } public void DoTheCounts() { PawnCount[0]=0; FerzCount[0]=0; RookCount[0]=0; ElephantCount[0]=0; KnightCount[0]=0; PawnCount[1]=0; FerzCount[1]=0; RookCount[1]=0; ElephantCount[1]=0; KnightCount[1]=0; PawnCount[2]=0; FerzCount[2]=0; RookCount[2]=0; ElephantCount[2]=0; KnightCount[2]=0; for(xxx=1; xxx < 17; xxx++) for(yyy=1; yyy < 5; yyy++) { 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_ == 22) ElephantCount[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_ == 23) FerzCount[NowBoard.sq_[yyy][xxx].side_]++; } } public boolean DoesArchiveMatchNowBoard() { if(whoseMove != ArchiveBoard[xxx].sq_[0][0].side_) return false; for(ff=1; ff < 6; ff++) for(ee=1; ee < 18; 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 < 5; ff++) MaybeBoard.sq_[ff][ee].drawchsq2(g, 3); } public void DrawNowBoard(Graphics g) { for(ee=1; ee < 17; ee++) for(ff=1; ff < 5; ff++) NowBoard.sq_[ff][ee].DrawChessSquare(g, 304, 3, icanmove[ff][ee]); } public void GenerateAttackersArrays() { for(zatt=1; zatt < 3; zatt++) for(yatt=1; yatt < 5; 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 < 5; 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 == 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 < 5; 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 == 4) | (patt == 9) | (patt == 21) | (patt == 28)) { catt=xatt; for(datt=yatt; (catt < 17) & (datt < 5); datt++) { AddAnAttacker(); if((catt != xatt) & (NowBoard.sq_[datt][catt].side_ != 0)) catt=20; catt++; } catt=xatt; for(datt=yatt; (catt > 0) & (datt < 5); 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 == 3) | (patt == -4) | (patt == -5) | (patt == 21) | (patt == 28) | (patt == 29) | (patt == 57)) { 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 == 22) { catt=xatt + 2; datt=yatt + 2; AddAnAttacker(); catt=xatt + 2; datt=yatt - 2; AddAnAttacker(); catt=xatt - 2; datt=yatt + 2; AddAnAttacker(); catt=xatt - 2; datt=yatt - 2; AddAnAttacker(); } if(patt == 23) { 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(); } if(patt == 101) { datt=yatt + 1; catt=xatt + 1; AddAnAttacker(); datt=yatt - 1; catt=xatt + 1; AddAnAttacker(); } if(patt == 102) { datt=yatt + 1; catt=xatt - 1; AddAnAttacker(); datt=yatt - 1; catt=xatt - 1; AddAnAttacker(); } if((patt == 1) | (patt == 2) | (patt == 51) | (patt == 52) | (patt == 83) | (patt == 84) | (patt == 85)) { if(satt == 1) { datt=yatt + 1; catt=xatt + 1; AddAnAttacker(); datt=yatt - 1; catt=xatt + 1; AddAnAttacker(); } if(satt == 2) { 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) { if((j > 16) | (j < 1) | (i > 4) | (i < 1)) 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; } if(MaybeBoard.sq_[i][j].piece_ == 8104) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_ == 8109) { 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_ == 109) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_ == 21) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_ == 28) { 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 > 4) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_ == k) return false; if(MaybeBoard.sq_[i][j].piece_ == 101) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyElephant(int i, int j, int k) { if((j > 16) | (j < 1) | (i > 4) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_ == k) return false; if(MaybeBoard.sq_[i][j].piece_ == 22) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyFerz(int i, int j, int k) { if((j > 16) | (j < 1) | (i > 4) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_ == k) return false; if(MaybeBoard.sq_[i][j].piece_ == 23) { 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 > 4) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_ == 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_ == 25) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyKnight(int i, int j, int k) { if((j > 16) | (j < 1) | (i > 4) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_ == k) return false; if(MaybeBoard.sq_[i][j].piece_ == 3) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyPawn(int i, int j, int k) { if((j > 16) | (j < 1) | (i > 4) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_ == k) return false; if(MaybeBoard.sq_[i][j].piece_ == 1) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyRook(int i, int j) { if((j > 16) | (j < 1) | (i > 4) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].piece_ == 5) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_ == 6) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_ == 9) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_ == 28) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_ == 29) { assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_ == 57) { 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 > 4) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_ == k) return false; if(MaybeBoard.sq_[i][j].piece_ == 102) { 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 < 5; yyy++) if((i == MaybeBoard.sq_[yyy][xxx].side_) & (MaybeBoard.sq_[yyy][xxx].piece_ < 0) && AmIUnderAttack(yyy, xxx, i)) return true; return false; } public boolean IsTheGameOver() { DoTheCounts(); if((RookCount[1] == 0) & (RookCount[2] == 0) & (PawnCount[1] == 0) & (PawnCount[2] == 0)) { if((ElephantCount[1] == 0) & (ElephantCount[2] == 0) & (KnightCount[1] < 3) & (KnightCount[2] < 3)) { GameOver=true; drawn_games++; ShowStatusQ("Lack of force!"); return true; } if((ElephantCount[1] < 2) & (ElephantCount[2] < 2) & (KnightCount[1] == 0) & (KnightCount[2] == 0)) { GameOver=true; drawn_games++; ShowStatusQ("Lack of force!"); return true; } } return false; } public void LowRectangle(Graphics g) { g.setColor(niceblue); g.fillRect(0, 152, 580, 104); 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) { NegateGMCounts();goodmove1=0; goodmove2=0; goodmove3=0; goodmove4=0; goodmove5=0; goodmove6=0; goodmove7=0; goodmove8=0; goodmove9=0; goodmove10=0; UnTwoThePawns(i); 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] < 5; 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) { if (use_dice==false){System.out.println("No Moves");WhoIsHuman[1]=true;WhoIsHuman[2]=true;ShowStatusQ("No Moves");} NextOrdinaryMove(g); return true; } x=1 + (int)Math.floor(Math.random() * (double)moveCounter); if(Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][3 - i] > Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][i]) x=1 + (int)Math.floor(Math.random() * (double)moveCounter); if(Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][3 - 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].DrawChessSquare(g, 304, 3, false); NowBoard.sq_[moveto_rank][moveto_file].DrawChessSquare(g, 304, 3, false); 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) { fifty_move_rule=0; DrawNowBoard(g);ShowStatusQ("Fifty move rule!"); drawn_games++; GameOver=true; return false; } else { return true; } } public boolean MaybeAdd(Graphics g, Chsq chsq, CB6_18 cb6_18, CB6_18 cb6_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] > 4)) return false; if(use_dice) { if((dice_roll == 6) & (chsq.piece_ > 0)) { if(WhoIsHuman[whoseMove]) ShowStatusQ("Move your king or PASS"); return false; } if((dice_roll == 5) & (chsq.piece_ != 23)) { if(WhoIsHuman[whoseMove]) ShowStatusQ("Move your general or PASS"); return false; } if((dice_roll == 4) & (chsq.piece_ != 22)) { if(WhoIsHuman[whoseMove]) ShowStatusQ("Move an elephant or PASS"); return false; } if((dice_roll == 3) & (chsq.piece_ != 3)) { if(WhoIsHuman[whoseMove]) ShowStatusQ("Move a knight or PASS"); return false; } if((dice_roll == 2) & (chsq.piece_ != 5)) { if(WhoIsHuman[whoseMove]) ShowStatusQ("Move a rook or PASS"); return false; } if((dice_roll == 1) & (chsq.piece_ != 1)) { if(WhoIsHuman[whoseMove]) ShowStatusQ("Move a pawn or PASS"); return false; } } if(NowBoard.sq_[d[depth]][c[depth]].piece_ == 85) return false; if(NowBoard.sq_[d[depth]][c[depth]].piece_ == 123) return false; if(NowBoard.sq_[d[depth]][c[depth]].side_ == chsq.side_) return false; alterMaybeBoard(g, chsq, cb6_18.sq_[d[depth]][c[depth]], cb6_18, cb6_18_1); worried=AmIWorried(chsq.side_); if((IsMySideInCheck(chsq.side_)) & ((!use_dice) | (!WhoIsHuman[whoseMove]))) { unalterMaybeBoard(g, chsq, cb6_18.sq_[d[depth]][c[depth]], cb6_18, cb6_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, cb6_18.sq_[d[depth]][c[depth]], cb6_18, cb6_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; if (skipDtGM==false){System.out.print("King captured");wins[chsq.side_]++;GameOver=true;WhoIsHuman[1]=true;WhoIsHuman[2]=true;} } MaybeMoves[moveCounter].startingsquare_=chsq; MaybeMoves[moveCounter].endingsquare_=cb6_18.sq_[d[depth]][c[depth]]; } DesignateTheGoodMoves(chsq); if((worried) & (IsThisAGoodMove()==false) & (moveCounter > 1) & (!WhoIsHuman[whoseMove])) moveCounter--; unalterMaybeBoard(g, chsq, cb6_18.sq_[d[depth]][c[depth]], cb6_18, cb6_18_1); return NowBoard.sq_[d[depth]][c[depth]].side_ == 0; } public void MoreGoodMoves(Chsq chsq) { } public void AssignVariantName(){ variant_name="Oblong Chess I"; } 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); g.drawString("About:", 480, 15); } public void NextOrdinaryMove(Graphics g) { BareKing(); NextOrdinaryPlayer(g); Game_Has_Started=true; if(!use_dice) dice_roll=0; if(use_dice) { roll_it();draw_bone(g);} if (WhoIsHuman[whoseMove]==true){SayWhoIsHuman(g);} whatpiecescanmove(g); } public void NextOrdinaryPlayer(Graphics g) { IsTheGameOver(); if(GameOver) return; if (WhoIsHuman[whoseMove]==true){SayWhoIsHuman(g);} whoseMove=3 - whoseMove; UnTwoThePawns(whoseMove); if(whoseMove == 1) turncounter++; TotalMaybeBoard(NowBoard, MaybeBoard); TotalMaybeBoard(MaybeBoard, TwoBoard); TotalMaybeBoard(TwoBoard, ThreeBoard); TotalMaybeBoard(ThreeBoard, FourBoard); GenerateAttackersArrays(); DoTheCounts(); DrawNowBoard(g); } public void NightMoves(Chsq chsq) { if ((goodmove1>0)|(goodmove2>0)|(goodmove3>0)|(goodmove4>0)|(goodmove5>0)|(goodmove6>0)|(goodmove7>0)|(goodmove8>0)|(goodmove9>0)|(goodmove10>0)){return;} if(worried) return; if(chsq.side_ != whoseMove) return; if(chsq.piece_ == 9 && (KingRank[3 - chsq.side_] == 1) | (KingRank[3 - chsq.side_] == 4) && (KingFile[3 - chsq.side_] == 1) | (KingFile[3 - chsq.side_] == 16) && (KingRank[3 - chsq.side_] - d[depth]) * (KingRank[3 - chsq.side_] - d[depth]) + (KingFile[3 - chsq.side_] - c[depth]) * (KingFile[3 - chsq.side_] - c[depth]) == 5) return; if((chsq.piece_ == 3) & (AmIUnderAttack(d[depth],c[depth],whoseMove)==false)) { knightforks(chsq); if(forked_royalty > 1 && Math.random() * 100D <98D && !worried) AssignGoodMove8(); if(forked_rookage > 1 && Math.random() * 100D <98D && !worried) AssignGoodMove5(); } if((chsq.piece_ == 1) | (chsq.piece_ == 2) | (chsq.piece_ == 83) | (chsq.piece_ == 84) | (chsq.piece_ == 51) | (chsq.piece_ == 52)) { pawnforks(chsq); if(forked_royalty > 1 && Math.random() * 100D <98D && !worried) AssignGoodMove8(); if(forked_rookage > 1 && Math.random() * 100D <98D) AssignGoodMove9(); if(forked_pieceage > 1 && Math.random() * 100D <98D && !worried) AssignGoodMove4(); } if((chsq.piece_ == 1) & (FerzCount[3 - chsq.side_] + RookCount[3 - chsq.side_] + KnightCount[3 - chsq.side_] + ElephantCount[3 - chsq.side_] <= 2)) { if(chsq.side_ == 1 && Attackers[d[depth]][c[depth]][2] <= Attackers[d[depth]][c[depth]][1] && Math.random() * 100D <98D) { AssignGoodMove7(); return; } if(chsq.side_ == 2 && Attackers[d[depth]][c[depth]][1] <= Attackers[d[depth]][c[depth]][2] && Math.random() * 100D <98D) { AssignGoodMove7(); return; } } if((d[depth] == undef_enemy_pawn_most_advanced_rank[chsq.side_]) & (c[depth] == undef_enemy_pawn_most_advanced_file[chsq.side_]) && Math.random() * 100D <98D) { AssignGoodMove7(); return; } if((d[depth] == undef_enemy_pawn_nearest_king_rank[chsq.side_]) & (c[depth] == undef_enemy_pawn_nearest_king_file[chsq.side_]) && Math.random() * 100D <98D) { AssignGoodMove7(); return; } if((Attackers[d[depth]][c[depth]][3 - chsq.side_] < Attackers[d[depth]][c[depth]][chsq.side_]) & ((chsq.piece_ == 5) | (chsq.piece_ == 6) | (chsq.piece_ == 9) | (chsq.piece_ == 28) | (chsq.piece_ == 29) | (chsq.piece_ == 163) | (chsq.piece_ == 165))) { if(c[depth] == undef_enemy_pawn_most_advanced_file[chsq.side_]) { if(NowBoard.sq_[d[depth]][c[depth]].piece_ != 0 && Math.random() * 100D <98D) { AssignGoodMove7(); return; } if(chsq.side_ == 1 && (d[depth] < undef_enemy_pawn_most_advanced_rank[1]) & (NowBoard.sq_[undef_enemy_pawn_most_advanced_rank[1] - 1][undef_enemy_pawn_most_advanced_file[1]].side_ == 0) && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } if(chsq.side_ == 2 && (d[depth] > undef_enemy_pawn_most_advanced_rank[2]) & (NowBoard.sq_[undef_enemy_pawn_most_advanced_rank[2] + 1][undef_enemy_pawn_most_advanced_file[2]].side_ == 0) && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } if(chsq.side_ == 1 && d[depth] > undef_enemy_pawn_most_advanced_rank[1] && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } if(chsq.side_ == 2 && d[depth] < undef_enemy_pawn_most_advanced_rank[2] && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } } if(d[depth] == undef_enemy_pawn_most_advanced_rank[chsq.side_]) { if(NowBoard.sq_[d[depth]][c[depth]].piece_ != 0 && Math.random() * 100D <98D) { AssignGoodMove7(); return; } if(chsq.side_ == 1 && NowBoard.sq_[undef_enemy_pawn_most_advanced_rank[1] - 1][undef_enemy_pawn_most_advanced_file[1]].side_ != 0 && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } if(chsq.side_ == 2 && NowBoard.sq_[undef_enemy_pawn_most_advanced_rank[2] + 1][undef_enemy_pawn_most_advanced_file[2]].side_ != 0 && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } } if(c[depth] == undef_enemy_pawn_nearest_king_file[chsq.side_]) { if(NowBoard.sq_[d[depth]][c[depth]].piece_ != 0 && Math.random() * 100D <98D) { AssignGoodMove7(); return; } if(chsq.side_ == 1 && (d[depth] < undef_enemy_pawn_nearest_king_rank[1]) & (NowBoard.sq_[undef_enemy_pawn_nearest_king_rank[1] - 1][undef_enemy_pawn_nearest_king_file[1]].side_ == 0) && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } if(chsq.side_ == 2 && (d[depth] > undef_enemy_pawn_nearest_king_rank[2]) & (NowBoard.sq_[undef_enemy_pawn_nearest_king_rank[2] + 1][undef_enemy_pawn_nearest_king_file[2]].side_ == 0) && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } if(chsq.side_ == 1 && d[depth] > undef_enemy_pawn_nearest_king_rank[1] && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } if(chsq.side_ == 2 && d[depth] < undef_enemy_pawn_nearest_king_rank[2] && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } } if(d[depth] == undef_enemy_pawn_nearest_king_rank[chsq.side_]) { if(NowBoard.sq_[d[depth]][c[depth]].piece_ != 0 && Math.random() * 100D < 80D) { AssignGoodMove7(); return; } if(chsq.side_ == 1 && NowBoard.sq_[undef_enemy_pawn_nearest_king_rank[1] - 1][undef_enemy_pawn_nearest_king_file[1]].side_ != 0 && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } if(chsq.side_ == 2 && NowBoard.sq_[undef_enemy_pawn_nearest_king_rank[2] + 1][undef_enemy_pawn_nearest_king_file[2]].side_ != 0 && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } } } if((chsq.piece_ < 0) & (FerzCount[chsq.side_] + RookCount[chsq.side_] == 0)) { if(NowBoard.sq_[d[depth]][c[depth]].piece_ != 0 && Math.random() * 100D < 80D) { AssignGoodMove7(); return; } if((((chsq.rank_ - d[depth]) * (undef_enemy_pawn_nearest_king_rank[chsq.side_] - d[depth]) < 0) | (d[depth] == undef_enemy_pawn_nearest_king_rank[chsq.side_])) & (((chsq.file_ - c[depth]) * (undef_enemy_pawn_nearest_king_file[chsq.side_] - c[depth]) < 0) | (c[depth] == undef_enemy_pawn_nearest_king_file[chsq.side_])) && Math.random() * 100D < 80D) { AssignGoodMove7(); return; } if(((chsq.rank_ - d[depth]) * (undef_enemy_pawn_nearest_king_rank[chsq.side_] - d[depth]) <= 0) & ((chsq.file_ - c[depth]) * (undef_enemy_pawn_nearest_king_file[chsq.side_] - c[depth]) <= 0) && Math.random() * 100D < 80D) { AssignGoodMove6(); return; } if((chsq.rank_ - d[depth]) * (undef_enemy_pawn_nearest_king_rank[chsq.side_] - d[depth]) <= 0 && Math.random() * 100D < 80D) { goodmove5=0; return; } if((chsq.file_ - c[depth]) * (undef_enemy_pawn_nearest_king_file[chsq.side_] - c[depth]) <= 0 && Math.random() * 100D < 80D) { goodmove5=0; return; } } if((ArchiveCounter > 0) & (chsq.piece_ == 1) & (Math.random() * 100D <98D) && !worried) AssignGoodMove1(); if(RookCount[3 - chsq.side_] + ElephantCount[3 - chsq.side_] + FerzCount[3 - chsq.side_] + KnightCount[3 - chsq.side_] > 2) return; if((chsq.piece_ == 1) & (Attackers[d[depth]][c[depth]][3 - chsq.side_] < Attackers[d[depth]][c[depth]][chsq.side_]) && (Math.random() * 100D < 70D && !worried)) AssignGoodMove1(); if(ElephantCount[3 - chsq.side_] > 0) return; if(KnightCount[3 - chsq.side_] > 0) return; goodmove2=0; if((Attackers[d[depth]][c[depth]][3 - chsq.side_] < Attackers[d[depth]][c[depth]][chsq.side_]) & ((chsq.piece_ == 5) | (chsq.piece_ == 6) | (chsq.piece_ == 9) | (chsq.piece_ == 28) | (chsq.piece_ == 29) | (chsq.piece_ == 163) | (chsq.piece_ == 165) | (chsq.piece_ < 0)) && (AmIUnderAttack(d[depth],c[depth],whoseMove)==false) & ((d[depth] - KingRank[3 - chsq.side_]) * (d[depth] - KingRank[3 - chsq.side_]) + (c[depth] - KingFile[3 - chsq.side_]) * (c[depth] - KingFile[3 - chsq.side_]) > 2)) { AssignGoodMove1(); if((chsq.piece_ == 9) | (chsq.piece_ == 5) | (chsq.piece_ == 6) | (chsq.piece_ == 28) | (chsq.piece_ == 29) | (chsq.piece_ == 66) | (chsq.piece_ == 65)) { if((strategos == 6) & (d[depth] < chsq.rank_) & (d[depth] > KingRank[3 - chsq.side_]) & (d[depth] < KingRank[chsq.side_]) && !worried) AssignGoodMove8(); if((strategos == 12) & (d[depth] > chsq.rank_) & (d[depth] < KingRank[3 - chsq.side_]) & (d[depth] > KingRank[chsq.side_]) && !worried) AssignGoodMove8(); if((strategos == 9) & (c[depth] < chsq.file_) & (c[depth] > KingFile[3 - chsq.side_]) & (c[depth] < KingFile[chsq.side_]) && !worried) AssignGoodMove8(); if((strategos == 3) & (c[depth] > chsq.file_) & (c[depth] < KingFile[3 - chsq.side_]) & (c[depth] > KingFile[chsq.side_]) && !worried) AssignGoodMove8(); } if(chsq.piece_ < 0) { if((strategos == 6) & (d[depth] < chsq.rank_) & (d[depth] >= KingRank[3 - chsq.side_] + 2) & ((c[depth] - chsq.file_) * (c[depth] - KingFile[3 - chsq.side_]) <= 0) && !worried) AssignGoodMove8(); if((strategos == 12) & (d[depth] > chsq.rank_) & (d[depth] <= KingRank[3 - chsq.side_] + 2) & ((c[depth] - chsq.file_) * (c[depth] - KingFile[3 - chsq.side_]) <= 0) && !worried) AssignGoodMove8(); if((strategos == 3) & (c[depth] < chsq.file_) & (c[depth] >= KingFile[3 - chsq.side_] + 2) & ((d[depth] - chsq.rank_) * (d[depth] - KingRank[3 - chsq.side_]) <= 0) && !worried) AssignGoodMove8(); if((strategos == 9) & (c[depth] > chsq.file_) & (c[depth] <= KingFile[3 - chsq.side_] + 2) & ((d[depth] - chsq.rank_) * (d[depth] - KingRank[3 - chsq.side_]) <= 0) && !worried) AssignGoodMove8(); } if(chsq.piece_ > 0) { if((d[depth] < chsq.rank_) & (KingRank[3 - chsq.side_] < d[depth]) & (KingRank[chsq.side_] > d[depth]) & ((strategos == 6) | (strategos == 0)) | (d[depth] > chsq.rank_) & (KingRank[3 - chsq.side_] > d[depth]) & (KingRank[chsq.side_] < d[depth]) & ((strategos == 12) | (strategos == 0)) | (c[depth] < chsq.file_) & (KingFile[3 - chsq.side_] < c[depth]) & (KingFile[chsq.side_] > c[depth]) & ((strategos == 9) | (strategos == 0)) | (c[depth] > chsq.file_) & (KingFile[3 - chsq.side_] > c[depth]) & (KingFile[chsq.side_] < c[depth]) & ((strategos == 3) | (strategos == 0)) && !worried) AssignGoodMove9(); if((d[depth] == chsq.rank_) & (KingRank[3 - chsq.side_] < d[depth]) & (KingRank[chsq.side_] > d[depth]) & ((strategos == 6) | (strategos == 0)) | (d[depth] == chsq.rank_) & (KingRank[3 - chsq.side_] > d[depth]) & (KingRank[chsq.side_] < d[depth]) & ((strategos == 12) | (strategos == 0)) | (c[depth] == chsq.file_) & (KingFile[3 - chsq.side_] < c[depth]) & (KingFile[chsq.side_] > c[depth]) & ((strategos == 9) | (strategos == 0)) | (c[depth] == chsq.file_) & (KingFile[3 - chsq.side_] > c[depth]) & (KingFile[chsq.side_] < c[depth]) & ((strategos == 3) | (strategos == 0))) { AssignGoodMove6(); if(((KingRank[3 - chsq.side_] - chsq.rank_) * (KingRank[3 - chsq.side_] - chsq.rank_) + (KingFile[3 - chsq.side_] - chsq.file_) * (KingFile[3 - chsq.side_] - chsq.file_) <= 2) & ((KingRank[3 - chsq.side_] - d[depth]) * (KingRank[3 - chsq.side_] - d[depth]) + (KingFile[3 - chsq.side_] - c[depth]) * (KingFile[3 - chsq.side_] - c[depth]) > 2) & ((KingRank[chsq.side_] - chsq.rank_) * (KingRank[chsq.side_] - chsq.rank_) + (KingFile[chsq.side_] - chsq.file_) * (KingFile[chsq.side_] - chsq.file_) > 2)) { if((c[depth] == chsq.file_) & ((strategos == 9) | (strategos == 3) | (strategos == 0)) && !worried) AssignGoodMove9(); if((d[depth] == chsq.rank_) & ((strategos == 12) | (strategos == 6) | (strategos == 0)) && !worried) AssignGoodMove9(); } } if((d[depth] < chsq.rank_) & (KingRank[3 - chsq.side_] < d[depth]) & (KingRank[chsq.side_] > d[depth]) & (strategos == 0)) strategos=6; if((d[depth] > chsq.rank_) & (KingRank[3 - chsq.side_] > d[depth]) & (KingRank[chsq.side_] < d[depth]) & (strategos == 0)) strategos=12; if((c[depth] < chsq.file_) & (KingFile[3 - chsq.side_] < c[depth]) & (KingFile[chsq.side_] > c[depth]) & (strategos == 0)) strategos=9; if((c[depth] > chsq.file_) & (KingFile[3 - chsq.side_] > c[depth]) & (KingFile[chsq.side_] < c[depth]) & (strategos == 0)) strategos=3; if(((KingRank[3 - chsq.side_] >= chsq.rank_) | (KingRank[chsq.side_] <= chsq.rank_)) & (strategos == 6)) strategos=0; if(((KingRank[3 - chsq.side_] <= chsq.rank_) | (KingRank[chsq.side_] >= chsq.rank_)) & (strategos == 12)) strategos=0; if(((KingFile[3 - chsq.side_] >= chsq.file_) | (KingFile[chsq.side_] <= chsq.file_)) & (strategos == 9)) strategos=0; if(((KingFile[3 - chsq.side_] <= chsq.file_) | (KingFile[chsq.side_] >= chsq.file_)) & (strategos == 3)) strategos=0; } } } public void NormalMove(Graphics g) { //**System.out.println(""+NowBoard.sq_[mover_rank][mover_file].piece_+" "+mover_rank+""+mover_file+" "+moveto_rank+""+moveto_file); 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) | (NowBoard.sq_[mover_rank][mover_file].piece_ == 1) | (NowBoard.sq_[mover_rank][mover_file].piece_ == 51) | (NowBoard.sq_[mover_rank][mover_file].piece_ == 83) | (NowBoard.sq_[mover_rank][mover_file].piece_ == 85)) { fifty_move_rule=0; } else { fifty_move_rule++; if(fifty_move_rule > fifties_got_to) fifties_got_to=fifty_move_rule; } oldpiece=NowBoard.sq_[moveto_rank][moveto_file].piece_; if (oldpiece<0) { ShowStatusQ("You win!"); GameOver=true; wins[whoseMove]++; return; } 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(); 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(NowBoard.sq_[moveto_rank][moveto_file].piece_ == 1 && (moveto_file == 1) | (moveto_file == 16)) NowBoard.sq_[moveto_rank][moveto_file].piece_=23; NowBoard.sq_[mover_rank][mover_file].side_=0; NowBoard.sq_[mover_rank][mover_file].piece_=0; TotalMaybeBoard(NowBoard, MaybeBoard); TotalMaybeBoard(MaybeBoard, TwoBoard); TotalMaybeBoard(TwoBoard, ThreeBoard); TotalMaybeBoard(ThreeBoard, FourBoard); Archives(); ShowStatusNothing(); if(oldpiece < 0) { wins[whoseMove]++; if(whoseMove == 2) ShowStatusQ("Red wins!"); if(whoseMove == 1) ShowStatusQ("White wins!"); } inquire_about_terms(); if (WhoIsHuman[whoseMove]==true){SayWhoIsHuman(g);} } public void SayWhoIsHuman(Graphics g) { g.setColor(niceblue); g.fillRect(0, 152, 540, 114); g.setColor(Color.black); g.setFont(f1); g.drawString("White:", 10, 170); g.drawString("Red:", 10, 190); g.drawString("Computer", 120, 170); g.drawString("Computer", 120, 190); g.drawString("Human", 60, 170); g.drawString("Human", 60, 190); g.drawString("Dice", 270, 170); g.drawString("No Dice", 270, 190); g.setFont(f1);NameThisChessVariant(g); g.drawString("White " + wins[1] + " Red " + wins[2] + " Drawn " + drawn_games, 5, 240); switch(who_is_winning) { case 1: // '\001' g.drawString("White wins", 30, 210); break; case 2: // '\002' g.drawString("Red wins", 30, 210); break; case 3: // '\003' g.drawString("Draw", 30, 210); break; } if(who_is_winning > 0) g.drawString("Continue Game", 150, 210); if(who_is_winning > 0) { if(accepted_terms) { g.drawRect(26, 196, 67, 18); g.drawRect(27, 197, 65, 16); } if(!accepted_terms) { g.drawRect(147, 196, 95, 18); g.drawRect(148, 197, 93, 16); } } g.setFont(f3); g.drawString("--Ed Friedlander", 450, 240); g.setFont(f2); if(humanizing) g.drawString("OKAY", 210, 180); if(use_dice) { g.drawString("PASS", 450, 180); draw_bone(g); } if(use_dice) { g.drawRect(265, 156, 55, 18); g.drawRect(266, 157, 53, 16); } if(!use_dice) { g.drawRect(265, 176, 55, 18); g.drawRect(266, 177, 53, 16); } g.setColor(Color.white); if(WhoIsHuman[1]) { g.drawRect(56, 156, 48, 18); g.drawRect(57, 157, 46, 16); } if(!WhoIsHuman[1]) { g.drawRect(117, 156, 61, 18); g.drawRect(118, 157, 59, 16); } g.setColor(Color.red); if(WhoIsHuman[2]) { g.drawRect(56, 176, 48, 18); g.drawRect(57, 177, 46, 16); } if(!WhoIsHuman[2]) { g.drawRect(117, 176, 61, 18); g.drawRect(118, 177, 59, 16); } } public void ShowStatusNothing() { if(!GameOver) ShowStatusQ(""); } public void StartUp(Graphics g) { accepted_terms=false; who_is_winning=0; turncounter=1;saved_fifty_move_rule=0;saved_turncounter=1;ShowStatusNothing(); Game_Has_Started=false; for(a=1; a <= 16; a++) for(b=1; b <= 4; b++) { NowBoard.sq_[b][a].piece_=0; NowBoard.sq_[b][a].side_=0; } SupplementalStartup(); IsTheGameOver(); for(x=1; x < 17; x++) for(y=1; y < 5; y++) { MaybeBoard.sq_[y][x].side_=NowBoard.sq_[y][x].side_; MaybeBoard.sq_[y][x].piece_=NowBoard.sq_[y][x].piece_; } whoseMove=1; whatpiecescanmove(g); GameOver=false; SayWhoIsHuman(g); fifty_move_rule=0; 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() { } public void SupplementalMovers(Graphics g, Chsq chsq, CB6_18 cb6_18, CB6_18 cb6_18_1) { } public void SupplementalStartup() { NowBoard.sq_[2][1].piece_=-1; NowBoard.sq_[2][1].side_=1; NowBoard.sq_[2][16].piece_=-1; NowBoard.sq_[2][16].side_=2; NowBoard.sq_[3][1].piece_=23; NowBoard.sq_[3][1].side_=1; NowBoard.sq_[3][16].piece_=23; NowBoard.sq_[3][16].side_=2; NowBoard.sq_[1][1].piece_=22; NowBoard.sq_[1][1].side_=1; NowBoard.sq_[1][16].piece_=22; NowBoard.sq_[1][16].side_=2; NowBoard.sq_[4][1].piece_=22; NowBoard.sq_[4][1].side_=1; NowBoard.sq_[4][16].piece_=22; NowBoard.sq_[4][16].side_=2; NowBoard.sq_[2][2].piece_=3; NowBoard.sq_[2][2].side_=1; NowBoard.sq_[2][15].piece_=3; NowBoard.sq_[2][15].side_=2; NowBoard.sq_[3][2].piece_=3; NowBoard.sq_[3][2].side_=1; NowBoard.sq_[3][15].piece_=3; NowBoard.sq_[3][15].side_=2; NowBoard.sq_[1][3].piece_=5; NowBoard.sq_[1][3].side_=1; NowBoard.sq_[1][14].piece_=5; NowBoard.sq_[1][14].side_=2; NowBoard.sq_[4][3].piece_=5; NowBoard.sq_[4][3].side_=1; NowBoard.sq_[4][14].piece_=5; NowBoard.sq_[4][14].side_=2; for(x=1; x < 5; x++) { NowBoard.sq_[x][5].piece_=1; NowBoard.sq_[x][5].side_=1; NowBoard.sq_[x][7].piece_=1; NowBoard.sq_[x][7].side_=1; NowBoard.sq_[x][10].piece_=1; NowBoard.sq_[x][10].side_=2; NowBoard.sq_[x][12].piece_=1; NowBoard.sq_[x][12].side_=2; } IsTheGameOver(); } public void TotalMaybeBoard(CB6_18 cb6_18, CB6_18 cb6_18_1) { for(xxx=1; xxx < 17; xxx++) for(yyy=1; yyy < 5; yyy++) { cb6_18_1.sq_[yyy][xxx].side_=cb6_18.sq_[yyy][xxx].side_; cb6_18_1.sq_[yyy][xxx].piece_=cb6_18.sq_[yyy][xxx].piece_; } } public void UnTwoThePawns(int i) { for(xq=1; xq < 17; xq++) for(yq=1; yq < 5; yq++) { if((NowBoard.sq_[yq][xq].side_ == i) & (NowBoard.sq_[yq][xq].piece_ == 2)) NowBoard.sq_[yq][xq].piece_=1; if((NowBoard.sq_[yq][xq].side_ == i) & (NowBoard.sq_[yq][xq].piece_ == 52)) NowBoard.sq_[yq][xq].piece_=51; if((NowBoard.sq_[yq][xq].side_ == i) & (NowBoard.sq_[yq][xq].piece_ == 84)) NowBoard.sq_[yq][xq].piece_=83; } } 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; } public void alterMaybeBoard(Graphics g, Chsq chsq, Chsq chsq1, CB6_18 cb6_18, CB6_18 cb6_18_1) { cb6_18_1.sq_[chsq.rank_][chsq.file_].piece_=0; cb6_18_1.sq_[chsq.rank_][chsq.file_].side_=0; cb6_18_1.sq_[chsq1.rank_][chsq1.file_].piece_=cb6_18.sq_[chsq.rank_][chsq.file_].piece_; cb6_18_1.sq_[chsq1.rank_][chsq1.file_].side_=cb6_18.sq_[chsq.rank_][chsq.file_].side_; if((cb6_18.sq_[chsq.rank_][chsq.file_].piece_ == 1) & (cb6_18.sq_[chsq1.rank_][chsq1.file_].side_ == 0) & (chsq.file_ != chsq1.file_)) { cb6_18_1.sq_[chsq.rank_][chsq1.file_].piece_=0; cb6_18_1.sq_[chsq.rank_][chsq1.file_].side_=0; } } public void alterforked(Chsq chsq) { if((fork_c > 0) & (fork_c <= 16) & (fork_d > 0) & (fork_d <= 4)) { if(NowBoard.sq_[fork_d][fork_c].side_ == chsq.side_) return; if((NowBoard.sq_[fork_d][fork_c].strength() > 3) | (NowBoard.sq_[fork_d][fork_c].piece_ < 0)) forked_royalty++; if((NowBoard.sq_[fork_d][fork_c].strength() > 2) | (NowBoard.sq_[fork_d][fork_c].piece_ < 0)) forked_rookage++; if((NowBoard.sq_[fork_d][fork_c].strength() > 1) | (NowBoard.sq_[fork_d][fork_c].piece_ < 0)) forked_pieceage++; } } public boolean findPieceMoves(Graphics g, Chsq chsq, CB6_18 cb6_18, CB6_18 cb6_18_1) { CheckSquare[depth]=false; SquatterOnCheckSquare[depth]=false; SupplementalMovers(g, chsq, cb6_18, cb6_18_1); if((chsq.piece_ == 9) | (chsq.piece_ == 5) | (chsq.piece_ == 57) | (chsq.piece_ == 29) | (chsq.piece_ == 28) | (chsq.piece_ == 6)) { c[depth]=chsq.file_ - 1; for(d[depth]=chsq.rank_; (MaybeAdd(g, chsq, cb6_18, cb6_18_1)) | (CheckSquare[depth]) & (!SquatterOnCheckSquare[depth]); c[depth]=c[depth] - 1); } if((chsq.piece_ == 9) | (chsq.piece_ == 5) | (chsq.piece_ == 57) | (chsq.piece_ == 29) | (chsq.piece_ == 28) | (chsq.piece_ == 6)) { c[depth]=chsq.file_ + 1; for(d[depth]=chsq.rank_; (MaybeAdd(g, chsq, cb6_18, cb6_18_1)) | (CheckSquare[depth]) & (!SquatterOnCheckSquare[depth]); c[depth]++); } if((chsq.piece_ == 9) | (chsq.piece_ == 5) | (chsq.piece_ == 57) | (chsq.piece_ == 29) | (chsq.piece_ == 28) | (chsq.piece_ == 6)) { c[depth]=chsq.file_; for(d[depth]=chsq.rank_ - 1; (MaybeAdd(g, chsq, cb6_18, cb6_18_1)) | (CheckSquare[depth]) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] - 1); } if((chsq.piece_ == 9) | (chsq.piece_ == 5) | (chsq.piece_ == 57) | (chsq.piece_ == 29) | (chsq.piece_ == 28) | (chsq.piece_ == 6)) { c[depth]=chsq.file_; for(d[depth]=chsq.rank_ + 1; (MaybeAdd(g, chsq, cb6_18, cb6_18_1)) | (CheckSquare[depth]) & (!SquatterOnCheckSquare[depth]); d[depth]++); } if((chsq.piece_ == 9) | (chsq.piece_ == 4) | (chsq.piece_ == 21) | (chsq.piece_ == 28)) { c[depth]=chsq.file_ - 1; for(d[depth]=chsq.rank_ - 1; (MaybeAdd(g, chsq, cb6_18, cb6_18_1)) | (CheckSquare[depth]) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] - 1) c[depth]=c[depth] - 1; } if((chsq.piece_ == 9) | (chsq.piece_ == 4) | (chsq.piece_ == 21) | (chsq.piece_ == 28)) { c[depth]=chsq.file_ - 1; for(d[depth]=chsq.rank_ + 1; (MaybeAdd(g, chsq, cb6_18, cb6_18_1)) | (CheckSquare[depth]) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] + 1) c[depth]=c[depth] - 1; } if((chsq.piece_ == 9) | (chsq.piece_ == 4) | (chsq.piece_ == 21) | (chsq.piece_ == 28)) { c[depth]=chsq.file_ + 1; for(d[depth]=chsq.rank_ - 1; (MaybeAdd(g, chsq, cb6_18, cb6_18_1)) | (CheckSquare[depth]) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] - 1) c[depth]=c[depth] + 1; } if((chsq.piece_ == 9) | (chsq.piece_ == 4) | (chsq.piece_ == 21) | (chsq.piece_ == 28)) { c[depth]=chsq.file_ + 1; for(d[depth]=chsq.rank_ + 1; (MaybeAdd(g, chsq, cb6_18, cb6_18_1)) | (CheckSquare[depth]) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] + 1) c[depth]=c[depth] + 1; } if((chsq.piece_ == -1) | (chsq.piece_ == -2) | (chsq.piece_ == 25)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } if(chsq.piece_ == 22) { c[depth]=chsq.file_ + 2; d[depth]=chsq.rank_ + 2; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ + 2; d[depth]=chsq.rank_ - 2; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ - 2; d[depth]=chsq.rank_ + 2; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ - 2; d[depth]=chsq.rank_ - 2; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } if((chsq.piece_ == 23) | (chsq.piece_ == 123)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } if((chsq.piece_ == 3) | (chsq.piece_ == -4) | (chsq.piece_ == -5) | (chsq.piece_ == 21) | (chsq.piece_ == 28) | (chsq.piece_ == 57) | (chsq.piece_ == 29)) { c[depth]=chsq.file_ - 2; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ - 2; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ + 2; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ + 2; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 2; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 2; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 2; MaybeAdd(g, chsq, cb6_18, cb6_18_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 2; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } if((chsq.piece_ == 1) | (chsq.piece_ == 101) | (chsq.piece_ == 102)) { if((chsq.side_ == 1) & (chsq.piece_ == 1) | (chsq.piece_ == 101)) { if(NowBoard.sq_[chsq.rank_][transf(chsq.file_ + 1)].piece_ == 0) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } if(chsq.rank_ > 1) { if((NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_ + 1)].side_ != 0) & (NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_ + 1)].side_ != chsq.side_) & (NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_ + 1)].piece_ != 0)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } if((NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_ + 1)].side_ == 0) & (NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_)].side_ != chsq.side_) & ((NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_)].piece_ == 2) | (NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_)].piece_ == 52) | (NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_)].piece_ == 84))) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } } if(chsq.rank_ < 4) { if((NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_ + 1)].side_ != 0) & (NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_ + 1)].side_ != chsq.side_) & (NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_ + 1)].piece_ != 0)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } if((NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_ + 1)].side_ == 0) & (NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_)].side_ != chsq.side_) & ((NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_)].piece_ == 2) | (NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_)].piece_ == 52) | (NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_)].piece_ == 84))) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } } } if((chsq.side_ == 2) & (chsq.piece_ == 1) | (chsq.piece_ == 102)) { if(NowBoard.sq_[chsq.rank_][transf(chsq.file_ - 1)].piece_ == 0) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } if(chsq.rank_ > 1) { if((NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_ - 1)].side_ != 0) & (NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_ - 1)].side_ != chsq.side_) & (NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_ - 1)].piece_ != 0)) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } if((NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_ - 1)].side_ == 0) & (NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_)].side_ != chsq.side_) & ((NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_)].piece_ == 2) | (NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_)].piece_ == 52) | (NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_)].piece_ == 84))) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } } if(chsq.rank_ < 4) { if((NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_ - 1)].side_ != 0) & (NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_ - 1)].side_ != chsq.side_) & (NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_ - 1)].piece_ != 0)) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_18_1); } if((NowBoard.sq_[chsq.rank_ - 1][transf(chsq.file_ + 1)].side_ == 0) & (NowBoard.sq_[chsq.rank_][transf(chsq.file_ + 1)].side_ != chsq.side_) & ((NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_)].piece_ == 2) | (NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_)].piece_ == 52) | (NowBoard.sq_[chsq.rank_ + 1][transf(chsq.file_)].piece_ == 84))) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb6_18, cb6_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]; KnightCount=new int[4]; BishopCount=new int[4]; RookCount=new int[4]; QueenCount=new int[4]; KingCount=new int[4]; undef_enemy_pawn_most_advanced_file=new int[3]; undef_enemy_pawn_most_advanced_rank=new int[3]; undef_enemy_pawn_nearest_king_file=new int[3]; undef_enemy_pawn_nearest_king_rank=new int[3]; distance_to_edible_pawn=new int[3]; PawnCount=new int[3]; niceblue=new Color(0, 192, 255); KingFile=new int[4]; KingRank=new int[4]; ElephantCount=new int[3]; FerzCount=new int[3]; Attackers=new int[6][18][3]; StrongestAttacker=new int[6][18][3]; WeakestAttacker=new int[6][18][3]; NowBoard=new CB6_18(306); SaveBoard=new CB6_18(306); BackBoard=new CB6_18(306); icanmove=new boolean[6][18]; MaybeBoard=new CB6_18(306); OneBoard=new CB6_18(306); TwoBoard=new CB6_18(306); ThreeBoard=new CB6_18(306); FourBoard=new CB6_18(306); ArchiveBoard=new CB6_18[102]; happySquare=new Chsq(1, 1, 5, 1); MaybeMoves=new Chmo[2001]; 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]; wins=new int[3]; depth=0; WhoIsHuman[1]=true; WhoIsHuman[2]=false; SupplementalInit(); Game_Has_Started=false; use_dice=false; GameOver=false; drawn_games=0; Graphics g=getGraphics(); setBackground(niceblue); markingAPiece=true; for(a=1; a <= 2000; a++) MaybeMoves[a]=new Chmo(); WhoIsHuman[0]=true; WhoIsHuman[1]=true; WhoIsHuman[2]=false; wins[0]=0; wins[1]=0; wins[2]=0; millipede1=System.currentTimeMillis();for (xxx=0;xxx<102;xxx++){ArchiveBoard[xxx]=new CB6_18(306);} millipede2=System.currentTimeMillis(); how_deep_to_seek=1; StartUp(g); } public void inquire_about_terms() { who_is_winning=0; if((!WhoIsHuman[1]) & (!WhoIsHuman[2])) return; if(IsMySideInCheck(1)) return; if(IsMySideInCheck(2)) return; CountAllThePieces(); term_counts[1]=20 * QueenCount[1] + 50 * RookCount[1] + 30 * BishopCount[1] + 30 * KnightCount[1] + 10 * PawnCount[1]; term_counts[2]=20 * QueenCount[2] + 50 * RookCount[2] + 30 * BishopCount[2] + 30 * KnightCount[2] + 10 * PawnCount[2]; if((fifty_move_rule > 2) & (PawnCount[1] == 0) & (PawnCount[2] == 0) & (term_counts[1] == term_counts[2]) & (bestvcom1 == 0)) who_is_winning=3; if(!WhoIsHuman[whoseMove]) { if(((bestvcom1 >= 0) | (bestvcom1 == -5000) | (how_deep_to_seek < 4)) & (term_counts[whoseMove] >= 30 + term_counts[3 - whoseMove])) who_is_winning=whoseMove; if(((bestvcom1 <= 0) | (how_deep_to_seek < 4)) & (term_counts[3 - whoseMove] >= 30 + term_counts[whoseMove])) who_is_winning=3 - whoseMove; } if(WhoIsHuman[whoseMove]) { if((Attackers[moveto_rank][moveto_file][3 - whoseMove] == 0) & (term_counts[whoseMove] >= 30 + term_counts[3 - whoseMove])) who_is_winning=whoseMove; if(term_counts[3 - whoseMove] >= 30 + term_counts[whoseMove]) who_is_winning=3 - whoseMove; } } public void knightforks(Chsq chsq) { forked_royalty=0; forked_rookage=0; forked_pieceage=0; fork_c=c[depth] + 2; fork_d=d[depth] + 1; alterforked(chsq); fork_c=c[depth] + 2; fork_d=d[depth] - 1; alterforked(chsq); fork_c=c[depth] - 2; fork_d=d[depth] + 1; alterforked(chsq); fork_c=c[depth] - 2; fork_d=d[depth] - 1; alterforked(chsq); fork_c=c[depth] + 1; fork_d=d[depth] + 2; alterforked(chsq); fork_c=c[depth] + 1; fork_d=d[depth] - 2; alterforked(chsq); fork_c=c[depth] - 1; fork_d=d[depth] + 2; alterforked(chsq); fork_c=c[depth] - 1; fork_d=d[depth] - 2; alterforked(chsq); } 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].DrawChessSquare(g, 304, 3, false); return false; } NowBoard.sq_[i][j].DrawChessSquare(g, 304, 2, false); NowBoard.sq_[i][j].BlackPerimeter(g,304); for(x=1; x <= moveCounter; x++) MaybeMoves[x].endingsquare_.markexchsquncheckered(g, 4); markingAPiece=false; return true; } public boolean mouseDown(Event event, int i, int j) { if(NowBoard == null) return true; Graphics g=getGraphics(); ShowStatusNothing(); if(j < 30) if(humanizing) { return true; } else { DisplayRules(g); return true; } SayWhoIsHuman(g); if(GameOver) { GameOver=false; StartUp(g); repaint(); return true; } a=i / 30; b=5 - j / 30; if((i >= 268) & (j >= 156) & (i <= 320) & (j <= 174)) { humanizing=true; use_dice=true; if(!Game_Has_Started) roll_it(); if(dice_roll == 0) roll_it(); whatpiecescanmove(g); SayWhoIsHuman(g); } else if((i >= 268) & (j >= 176) & (i <= 320) & (j <= 194)) { humanizing=true; use_dice=false;whatpiecescanmove(g); SayWhoIsHuman(g); } else if((i >= 56) & (j >= 156) & (i <= 104) & (j <= 174)) { humanizing=true; WhoIsHuman[1]=true; SayWhoIsHuman(g); } else if((i >= 117) & (j >= 156) & (i <= 178) & (j <= 174)) { humanizing=true; WhoIsHuman[1]=false; SayWhoIsHuman(g); } else if((i >= 56) & (j >= 176) & (i <= 104) & (j <= 194)) { humanizing=true; WhoIsHuman[2]=true; SayWhoIsHuman(g); } else if((i >= 117) & (j >= 176) & (i <= 178) & (j <= 194)) { humanizing=true; WhoIsHuman[2]=false; SayWhoIsHuman(g); } else if((i >= 26) & (j > 196) & (i <= 93) & (j <= 214)) { if(who_is_winning == 0) return true; humanizing=true; accepted_terms=true; SayWhoIsHuman(g); } else if((i >= 147) & (j >= 196) & (i < 242) & (j < 214)) { if(who_is_winning == 0) return true; humanizing=true; accepted_terms=false; SayWhoIsHuman(g); } else if((i >= 210) & (j >= 165) & (i < 270) & (j < 185)) { humanizing=false; SayWhoIsHuman(g); Game_Has_Started=true; 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; UnTwoThePawns(whoseMove); if((b < 1) & (a > 14)) { ShowStatusQ("Pass"); if(!use_dice) return true; NextOrdinaryMove(g); if(WhoIsHuman[whoseMove]) return true; } else if((a < 1) | (a > 16) | (b < 1) | (b > 4)) return true; if(WhoIsHuman[whoseMove]) if(markingAPiece) markAPiece(g, b, a); else if(HumanMoveAPiece(g, b, a)) { if(GameOver) return true; NextOrdinaryMove(g); } while((!WhoIsHuman[whoseMove]) & (!GameOver)) { MachineMoves(g, whoseMove); if(GameOver) return true; NextOrdinaryMove(g); UnTwoThePawns(whoseMove); if(WhoIsHuman[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); return; } DrawNowBoard(g); g.setColor(niceblue); g.fillRect(0, 151, 300, 59);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[whoseMove])) { NowBoard.sq_[mover_rank][mover_file].DrawChessSquare(g, 304, 2, false); for(x=1; x <= moveCounter; x++) MaybeMoves[x].endingsquare_.markexchsquncheckered(g, 4); } } public void pawnforks(Chsq chsq) { forked_royalty=0; forked_rookage=0; forked_pieceage=0; if(chsq.side_ == 1) { fork_d=d[depth] + 1; fork_c=c[depth] + 1; alterforked(chsq); fork_d=d[depth] - 1; fork_c=c[depth] + 1; alterforked(chsq); } if(chsq.side_ == 2) { fork_d=d[depth] + 1; fork_c=c[depth] - 1; alterforked(chsq); fork_d=d[depth] - 1; fork_c=c[depth] - 1; alterforked(chsq); } } public void roll_it() { dice_roll=(int)Math.floor(Math.random() * 6D + 1.0D); } public int sixteener(int i) { if(i == 0) return 16; if(i == 17) return 1; if(i == -1) return 15; if(i == 18) return 2; else return i; } public void stop() { NowBoard=null; MaybeBoard=null; OneBoard=null; TwoBoard=null; ThreeBoard=null; FourBoard=null; ArchiveBoard=null; MaybeMoves=null; Attackers=null; destroy(); } public int transf(int i) { return i; } public void unalterMaybeBoard(Graphics g, Chsq chsq, Chsq chsq1, CB6_18 cb6_18, CB6_18 cb6_18_1) { cb6_18_1.sq_[chsq.rank_][chsq.file_].piece_=cb6_18.sq_[chsq.rank_][chsq.file_].piece_; cb6_18_1.sq_[chsq.rank_][chsq.file_].side_=cb6_18.sq_[chsq.rank_][chsq.file_].side_; cb6_18_1.sq_[chsq1.rank_][chsq1.file_].piece_=cb6_18.sq_[chsq1.rank_][chsq1.file_].piece_; cb6_18_1.sq_[chsq1.rank_][chsq1.file_].side_=cb6_18.sq_[chsq1.rank_][chsq1.file_].side_; cb6_18_1.sq_[chsq.rank_][chsq1.file_].piece_=cb6_18.sq_[chsq.rank_][chsq1.file_].piece_; cb6_18_1.sq_[chsq.rank_][chsq1.file_].side_=cb6_18.sq_[chsq.rank_][chsq1.file_].side_; } public void whatpiecescanmove(Graphics g) { for(ee=1; ee < 17; ee++) for(ff=1; ff < 5; 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; static int turncounter;static int saved_turncounter;static int back_turncounter;static int saved_fifty_move_rule;static int back_fifty_move_rule; int KnightCount[]; int BishopCount[]; int RookCount[]; int QueenCount[]; int KingCount[]; static int forked_royalty; static int forked_rookage; static int forked_pieceage; static int fork_c; static int fork_d; int undef_enemy_pawn_most_advanced_file[]; int undef_enemy_pawn_most_advanced_rank[]; int undef_enemy_pawn_nearest_king_file[]; int undef_enemy_pawn_nearest_king_rank[]; int distance_to_edible_pawn[]; static int pawnowner; static int strategos; int PawnCount[]; Color niceblue; int KingFile[]; int KingRank[]; int ElephantCount[]; int FerzCount[]; int Attackers[][][]; int StrongestAttacker[][][]; int WeakestAttacker[][][]; CB6_18 NowBoard; CB6_18 SaveBoard; CB6_18 BackBoard; boolean icanmove[][]; CB6_18 MaybeBoard; CB6_18 OneBoard; CB6_18 TwoBoard; CB6_18 ThreeBoard; CB6_18 FourBoard; CB6_18 ArchiveBoard[]; 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 dice_roll; static int oldpiece; 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[]; static boolean markingAPiece; static boolean GameOver; static boolean humanizing; static boolean Game_Has_Started; static boolean use_dice; 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[]; int wins[]; static String stringy; static boolean halt_if_king_taken; static boolean seek_sacrificial_wins; static char oopsKey; static char loadKey; static char saveKey; static int who_backed; static int who_saved;static int when_saved; }