// 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: ForChess.java import java.applet.Applet; import java.awt.*; public class ForChess extends Applet { public ForChess() { } public void SomethingElseForTotalBackBoard() { back_i_began_as[yyy][xxx]=i_began_as[yyy][xxx]; if (xxx<5) { back_KingFile[xxx]=KingFile[xxx]; back_KingRank[xxx]=KingRank[xxx]; back_checks_in_a_row[xxx]=checks_in_a_row[xxx]; back_pawns_taken[xxx]=pawns_taken[xxx]; back_who_took_this_king[xxx]=who_took_this_king[xxx]; back_units_taken[xxx]=units_taken[xxx]; back_royal_rank[xxx]=royal_rank[xxx]; back_royal_file[xxx]=royal_file[xxx]; back_kings_taken[xxx]=kings_taken[xxx]; back_CapturedAKing[xxx]=CapturedAKing[xxx]; back_CapturedAQueen[xxx]=CapturedAQueen[xxx]; back_CapturedABishop[xxx]=CapturedABishop[xxx]; back_CapturedARook[xxx]=CapturedARook[xxx]; back_CapturedAKnight[xxx]=CapturedAKnight[xxx]; back_CapturedAPawn[xxx]=CapturedAPawn[xxx]; back_term_counts[xxx]=term_counts[xxx]; back_best_four_count[xxx]=best_four_count[xxx]; } } public void SomethingElseForTotalSaveBoard() { save_i_began_as[yyy][xxx]=i_began_as[yyy][xxx]; if (xxx<5) { save_KingFile[xxx]=KingFile[xxx]; save_KingRank[xxx]=KingRank[xxx]; save_checks_in_a_row[xxx]=checks_in_a_row[xxx]; save_pawns_taken[xxx]=pawns_taken[xxx]; save_who_took_this_king[xxx]=who_took_this_king[xxx]; save_units_taken[xxx]=units_taken[xxx]; save_royal_rank[xxx]=royal_rank[xxx]; save_royal_file[xxx]=royal_file[xxx]; save_kings_taken[xxx]=kings_taken[xxx]; save_CapturedAKing[xxx]=CapturedAKing[xxx]; save_CapturedAQueen[xxx]=CapturedAQueen[xxx]; save_CapturedABishop[xxx]=CapturedABishop[xxx]; save_CapturedARook[xxx]=CapturedARook[xxx]; save_CapturedAKnight[xxx]=CapturedAKnight[xxx]; save_CapturedAPawn[xxx]=CapturedAPawn[xxx]; save_term_counts[xxx]=term_counts[xxx]; save_best_four_count[xxx]=best_four_count[xxx]; } } public void SomethingElseForUnBackBoard() { i_began_as[yyy][xxx]=back_i_began_as[yyy][xxx]; if (xxx<5) { KingFile[xxx]=back_KingFile[xxx]; KingRank[xxx]=back_KingRank[xxx]; checks_in_a_row[xxx]=back_checks_in_a_row[xxx]; pawns_taken[xxx]=back_pawns_taken[xxx]; who_took_this_king[xxx]=back_who_took_this_king[xxx]; units_taken[xxx]=back_units_taken[xxx]; royal_rank[xxx]=back_royal_rank[xxx]; royal_file[xxx]=back_royal_file[xxx]; kings_taken[xxx]=back_kings_taken[xxx]; CapturedAKing[xxx]=back_CapturedAKing[xxx]; CapturedAQueen[xxx]=back_CapturedAQueen[xxx]; CapturedABishop[xxx]=back_CapturedABishop[xxx]; CapturedARook[xxx]=back_CapturedARook[xxx]; CapturedAKnight[xxx]=back_CapturedAKnight[xxx]; CapturedAPawn[xxx]=back_CapturedAPawn[xxx]; term_counts[xxx]=back_term_counts[xxx]; best_four_count[xxx]=back_best_four_count[xxx]; } } public void SomethingElseForLoadSavedBoard() { i_began_as[yyy][xxx]=save_i_began_as[yyy][xxx]; if (xxx<5) { KingFile[xxx]=save_KingFile[xxx]; KingRank[xxx]=save_KingRank[xxx]; checks_in_a_row[xxx]=save_checks_in_a_row[xxx]; pawns_taken[xxx]=save_pawns_taken[xxx]; who_took_this_king[xxx]=save_who_took_this_king[xxx]; units_taken[xxx]=save_units_taken[xxx]; royal_rank[xxx]=save_royal_rank[xxx]; royal_file[xxx]=save_royal_file[xxx]; kings_taken[xxx]=save_kings_taken[xxx]; CapturedAKing[xxx]=save_CapturedAKing[xxx]; CapturedAQueen[xxx]=save_CapturedAQueen[xxx]; CapturedABishop[xxx]=save_CapturedABishop[xxx]; CapturedARook[xxx]=save_CapturedARook[xxx]; CapturedAKnight[xxx]=save_CapturedAKnight[xxx]; CapturedAPawn[xxx]=save_CapturedAPawn[xxx]; term_counts[xxx]=save_term_counts[xxx]; best_four_count[xxx]=save_best_four_count[xxx]; } } 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; PromotingAPawn=false; UnBackBoard();TotalMaybeBoard(NowBoard, MaybeBoard); markingAPiece=true; whoseMove=who_backed; SayWhoIsHuman(g); whatpiecescanmove(g); TotalMaybeBoard(NowBoard, MaybeBoard); GenerateAttackersArrays(); CountAllThePieces(); DrawNowBoard(g); ShowStatusNothing(); return true; } if (k==saveKey) { TotalSaveBoard();TotalMaybeBoard(NowBoard, MaybeBoard); who_saved=whoseMove; ShowStatusNothing(); return true; } 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); ShowStatusNothing(); return true; } System.out.println("kurwa"); return false; } public void TotalBackBoard(){back_turncounter=turncounter;back_fifty_move_rule=fifty_move_rule; for(xxx=1; xxx < 14; xxx++) for(yyy=1; yyy < 9; 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=1; xxx < 14; xxx++) for(yyy=1; yyy < 9; 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=1; xxx < 14; xxx++) for(yyy=1; yyy < 9; 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=1; xxx < 14; xxx++) for(yyy=1; yyy < 9; 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 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();showStatus("Applet Re-Started");} } public void plague(){ NowBoard.sq_[moveto_rank][moveto_file].side_=NowBoard.sq_[mover_rank][mover_file].side_; } public void AddAnAttacker() { if((xatt==catt) & (yatt==datt)) return; if((catt > 8) | (datt > 8) | (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 void AlsoMark(Graphics g) { } public boolean AmIUnderAttack(int i, int j, int k) { if(SupplementalAmIUnderAttackers(i, j, k)) return true; cc=j + 1; dd=i; while(cc < 9) 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 < 9;) if(MaybeBoard.sq_[dd][cc].side_==k) { dd=20; } else { if(IsEnemyRook(dd, cc)) 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)) return true; if(MaybeBoard.sq_[dd][cc].piece_ !=0) dd=-1; dd--; } cc=j + 1; for(dd=i + 1; (cc < 9) & (dd < 9);) 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 < 9) & (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 < 9);) 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 - 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 - 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 (IsEnemyPawn(i,j,k)==true){return true;} return false; } public boolean IsEnemyPawn(int i,int j,int k){ cc=j + 1; dd=i; if(IsEnemyThirdPlayerPawn(dd, cc, k)) return true; if(IsEnemyFourthPlayerPawn(dd, cc, k)) return true; cc=j - 1; dd=i; if(IsEnemyFirstPlayerPawn(dd, cc, k)) return true; if(IsEnemySecondPlayerPawn(dd, cc, k)) return true; cc=j; dd=i + 1; if(IsEnemyThirdPlayerPawn(dd, cc, k)) return true; if(IsEnemySecondPlayerPawn(dd, cc, k)) return true; cc=j; dd=i - 1; if(IsEnemyFirstPlayerPawn(dd, cc, k)) return true; if (IsEnemyFourthPlayerPawn(dd, cc, k)){return true;} return false; } public boolean AmIUnderSparrowAttack(int i, int j, int k) { if(SupplementalAmIUnderSparrowAttackers(i, j, k)) return true; cc=j + 1; dd=i; while(cc < 9) 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 < 9;) if(MaybeBoard.sq_[dd][cc].side_==k) { dd=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) 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) && 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; for(dd=i + 1; (cc < 9) & (dd < 9);) 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 < 9) & (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 < 9);) 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 - 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 - 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; cc=j + 1; dd=i; if(IsEnemyThirdPlayerPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; if(IsEnemyFourthPlayerPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j - 1; dd=i; if(IsEnemyFirstPlayerPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; if(IsEnemySecondPlayerPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j; dd=i + 1; if(IsEnemyThirdPlayerPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; if(IsEnemySecondPlayerPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; cc=j; dd=i - 1; if(IsEnemyFirstPlayerPawn(dd, cc, k) && MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength()) return true; return IsEnemyFourthPlayerPawn(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 < 9; xxx++) for(yyy=1; yyy < 9; 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 AnotherWayToCheck(int i) { return false; } public boolean AnotherWayToEndGame(Graphics g, int i) { x=1;while (x<13){ y=1;while (y<9){ if ((NowBoard.sq_[y][x].piece_<0)&(NowBoard.sq_[y][x].side_==whoseMove)){return false;} if ((NowBoard.sq_[y][x].piece_<0)&(NowBoard.sq_[y][x].side_==friend(whoseMove))){return false;} y++;}x++;} GameOver=true; if ((whoseMove==1)|(whoseMove==3)) {wins[2]++;ShowStatusQ("Blue wins!");} if ((whoseMove==2)|(whoseMove==4)) {wins[1]++;ShowStatusQ(" Red wins!");} return true; } public void Archives() { ArchiveCounter=0; for(ff=1; ff < 9; ff++) for(ee=1; ee < 9; 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) { ShowStatusQ("Ends By Repetition");DeclareADraw(); GameOver=true;repaint(); return; } } } public void CountAllThePieces() { ZeroAllFiveCounts(); for(xxx=1; xxx < 13; xxx++) for(yyy=1; yyy < 9; 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_==260) BishopCount[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) { QueenCount[NowBoard.sq_[yyy][xxx].side_]++; if (royal_queen[NowBoard.sq_[yyy][xxx].side_]==true){KingCount[NowBoard.sq_[yyy][xxx].side_]++;} } if(NowBoard.sq_[yyy][xxx].piece_==28) AmazonCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==223) QueenCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_==224) QueenCount[NowBoard.sq_[yyy][xxx].side_]++; if(NowBoard.sq_[yyy][xxx].piece_ < 0) KingCount[NowBoard.sq_[yyy][xxx].side_]++; } if ((bare_king_wins[1]==true)&(KingCount[1]==1)&(PawnCount[1]==0)&(KnightCount[1]==0)&(BishopCount[1]==0)&(RookCount[1]==0)&(AmazonCount[1]==0)&(QueenCount[1]==0)) { GameOver=true; wins[1]++; ShowStatusQ("C king bared!"); } if ((bare_king_wins[2]==true)&(KingCount[2]==1)&(PawnCount[2]==0)&(KnightCount[2]==0)&(BishopCount[2]==0)&(RookCount[2]==0)&(AmazonCount[2]==0)&(QueenCount[2]==0)) { GameOver=true; wins[2]++; ShowStatusQ("Gold king bared!"); } if ((bare_king_wins[3]==true)&(KingCount[3]==1)&(PawnCount[3]==0)&(KnightCount[3]==0)&(BishopCount[3]==0)&(RookCount[3]==0)&(AmazonCount[3]==0)&(QueenCount[3]==0)) { GameOver=true; wins[3]++; ShowStatusQ("Shadow king bared!"); } if ((bare_king_wins[4]==true)&(KingCount[4]==1)&(PawnCount[4]==0)&(KnightCount[4]==0)&(BishopCount[4]==0)&(RookCount[4]==0)&(AmazonCount[4]==0)&(QueenCount[4]==0)) { GameOver=true; wins[4]++; ShowStatusQ("Temple king bared!"); } } 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.strength() < NowBoard.sq_[d[depth]][c[depth]].strength()) good_move=(good_move + 3 * NowBoard.sq_[d[depth]][c[depth]].strength()) - chsq.strength(); } public void DesignateTheGoodMoves(Chsq chsq) { if((whoseMove !=chsq.side_) | (skipDtGM) | (depth > 1)|(friend(chsq.side_)==NowBoard.sq_[d[depth]][c[depth]].side_)) return; if ((royal_rank[whoseMove]==chsq.rank_)&(royal_file[whoseMove]==chsq.file_) &(AmIUnderAttack(d[depth],c[depth],whoseMove)==true)){return;} if (AmIUnderAttack(royal_rank[whoseMove],royal_file[whoseMove],whoseMove)==true){return;} IncrediblyGoodMove(chsq); if ((HowManyEnemiesBearingDown(chsq)>HowManyDefendersThere(chsq))) { if (AmIUnderAttack(d[depth],c[depth],chsq.side_)==true) AssignGoodMove1(); } if((HowManyDefendersThere(chsq)==0) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) & (NowBoard.sq_[d[depth]][c[depth]].side_ !=friend(chsq.side_)) && Math.random() * 100D < 99D) AssignGoodMove9(); if(NowBoard.sq_[d[depth]][c[depth]].piece_ < 0 && Math.random() * 100D < 99D) goodmove10=moveCounter; if((NowBoard.sq_[d[depth]][c[depth]].strength() > 1 + chsq.strength()) & (NowBoard.sq_[d[depth]][c[depth]].side_ !=friend(chsq.side_)) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove9(); if(NowBoard.sq_[d[depth]][c[depth]].strength() > 2 + chsq.strength() && !worried) AssignGoodMove9(); if((chsq.strength() > 3) & (HowManyEnemiesBearingDown(chsq) > 0) & (HowManyDefendersThere(chsq)==0) && (Math.random() * 100D <98D && !worried)) {AssignGoodMove8();if (NowBoard.sq_[d[depth]][c[depth]].piece_!=0){AssignGoodMove9();}} if((HowManyDefendersThere(chsq)==0) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) & (NowBoard.sq_[d[depth]][c[depth]].side_ !=friend(chsq.side_)) && (Math.random() * 100D <98D && !worried)) AssignGoodMove7(); if((chsq.strength() < 3) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) & (NowBoard.sq_[d[depth]][c[depth]].side_ !=friend(chsq.side_)) && (Math.random() * 100D <98D && !worried)) AssignGoodMove6(); if((chsq.strength() > 2) & (HowManyEnemiesBearingDown(chsq) > 0) & (HowManyDefendersThere(chsq)==0) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove5(); if((HowManyDefendersThere(chsq)==0) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 1) & (NowBoard.sq_[d[depth]][c[depth]].side_ !=friend(chsq.side_)) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove4(); if((chsq.strength() < NowBoard.sq_[d[depth]][c[depth]].strength()) & (NowBoard.sq_[d[depth]][c[depth]].side_ !=friend(chsq.side_)) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove3(); if((HowManyDefendersThere(chsq)==0) & ((IsMySideInCheck(1)) | (IsMySideInCheck(2)) | (IsMySideInCheck(3)) | (IsMySideInCheck(4))) && (Math.random() * 100D <98D && !worried)) AssignGoodMove2(); if((fifty_move_rule > 4) & (chsq.pawn()) & (Math.random() * 100D < (double)(100 - 10 * PawnCount[chsq.side_])) & (!worried) & (HowManyEnemiesBearingDown(chsq)==0)) AssignGoodMove1(); MoreGoodMoves(chsq); NightMoves(chsq); } public void DidICheckOrStalemate(Graphics g, int i) { if(GameOver) return; spite_move=false; evict_pawn=false; evict_knight=false; evict_bishop=false; evict_rook=false; evict_queen=false; evict_king=false; CountAllThePieces();if(AnotherWayToEndGame(g, i)) { GameOver=true;repaint(); return; } else { return; } } public void DisplayRules(Graphics g) { LowRectangle(g); g.drawString("No partners. Capture the enemy king and control", 5, 285); g.drawString("the remaining enemy army. By Mark Rogers.", 5, 301); } public boolean DoesArchiveMatchNowBoard() { if(whoseMove !=ArchiveBoard[xxx].sq_[0][0].side_) return false; for(ff=1; ff < 9; ff++) for(ee=1; ee < 9; 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 < 9; ee++) for(ff=1; ff < 9; ff++) MaybeBoard.sq_[ff][ee].drawForchesschsq2(g, 1); } public void DrawNowBoard(Graphics g) { for(ee=1; ee < 13; ee++) for(ff=1; ff < 9; ff++) { { NowBoard.sq_[ff][ee].drawForchesschsq(g, 1, icanmove[ff][ee], teams,i_began_as[ff][ee]); 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(0, 271, 300, 114); g.setColor(Color.black); g.setFont(f2); g.drawString("Choose: ", 5, 320); happySquare.side_=whoseMove; happySquare.rank_=-1; happySquare.file_=3; happySquare.piece_=9; happySquare.drawForchesschsq(g, 11, false, teams,0); happySquare.file_=4; happySquare.piece_=5; happySquare.drawForchesschsq(g, 11, false, teams,0); happySquare.file_=5; happySquare.piece_=4; happySquare.drawForchesschsq(g, 11, false, teams,0); happySquare.file_=6; happySquare.piece_=3; happySquare.drawForchesschsq(g, 11, false, teams,0); } public void FindWhoCanMove(Graphics g) { spite_move=false; evict_pawn=false; evict_knight=false; evict_bishop=false; evict_queen=false; evict_king=false; evict_rook=false; infindhoo=true; for(z_forchess=1; z_forchess < 5; z_forchess++) { CanMove[z_forchess]=false; moveCounter=0; for(x_forchess=1; (x_forchess < 9) & (moveCounter==0); x_forchess++) for(y_forchess=1; (y_forchess < 9) & (moveCounter==0); y_forchess++) if(NowBoard.sq_[y_forchess][x_forchess].side_==z_forchess) findPieceMoves(g, NowBoard.sq_[y_forchess][x_forchess], NowBoard, MaybeBoard); if(moveCounter > 0) { CanMove[z_forchess]=true; ShowStatusQ("Remove a unit"); } } if ((spite_game==true)&(CanMove[whoseMove]==false)) { if (IsMySideInCheck(whoseMove)==false){ x=1;while (x<9){ y=1;while (y<9){ if (NowBoard.sq_[y][x].side_==whoseMove) { TotalMaybeBoard(NowBoard,MaybeBoard); MaybeBoard.sq_[y][x].piece_=0; MaybeBoard.sq_[y][x].side_=0; if ((IsMySideInCheck(whoseMove)==false) & (IsMySideInCheck(friend(whoseMove))==false)) { switch(NowBoard.sq_[y][x].piece_){ case -2:{evict_king=true;break;} case -1:{evict_king=true;break;} case 1:{evict_pawn=true;break;} case 2:{evict_pawn=true;break;} case 3:{evict_knight=true;break;} case 4:{evict_bishop=true;break;} case 5:{evict_rook=true;break;} case 6:{evict_rook=true;break;} case 9:{evict_queen=true;break;} } } TotalMaybeBoard(NowBoard,MaybeBoard); } y++;}x++;} } else { spite_move=true; moveCounter=0; x=1;while (x<13){ y=1;while (y<9){ if (NowBoard.sq_[y][x].side_==whoseMove){findPieceMoves(g,NowBoard.sq_[y][x],NowBoard,MaybeBoard);} y++;}x++;} if (moveCounter==0){spite_move=false;} else {ShowStatusQ("Spite move!");} } if ((spite_move==true)| (evict_pawn==true)| (evict_knight==true)| (evict_bishop==true)| (evict_rook==true)| (evict_queen==true)| (evict_king==true)) { CanMove[whoseMove]=true; } } if(teams==4) { if((!CanMove[2]) & (!CanMove[3]) & (!CanMove[4])) { ShowStatusQ("Red wins!"); wins[1]++; GameOver=true;repaint(); } if((!CanMove[1]) & (!CanMove[3]) & (!CanMove[4])) { ShowStatusQ("White wins!"); wins[2]++; GameOver=true;repaint(); } if((!CanMove[1]) & (!CanMove[2]) & (!CanMove[4])) { ShowStatusQ("Blue wins!"); wins[3]++; GameOver=true;repaint(); } if((!CanMove[1]) & (!CanMove[2]) & (!CanMove[3])) { ShowStatusQ("Gold wins!"); wins[4]++; GameOver=true;repaint(); } } if(teams==2) { if((!CanMove[2]) & (!CanMove[4])) { ShowStatusQ("Red wins!"); wins[1]++; GameOver=true;repaint(); } if((!CanMove[1]) & (!CanMove[3])) { ShowStatusQ("Blue wins!"); wins[2]++; GameOver=true;repaint(); } } infindhoo=false; } public void ForGambler(Graphics g) { } public void GenerateAttackersArrays() { for(zatt=1; zatt < 5; zatt++) for(yatt=1; yatt < 9; yatt++) for(xatt=1; xatt < 9; xatt++) { Attackers[yatt][xatt][zatt]=0; StrongestAttacker[yatt][xatt][zatt]=0; WeakestAttacker[yatt][xatt][zatt]=0; } for(yatt=1; yatt < 9; yatt++) for(xatt=1; xatt < 9; xatt++) { satt=NowBoard.sq_[yatt][xatt].side_; patt=NowBoard.sq_[yatt][xatt].piece_; SupplementalAddAnAttacker(); if((patt==5) | (patt==6)) { catt=xatt; datt=yatt; for(; catt < 9; 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 < 9; 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)) { catt=xatt; for(datt=yatt; (catt < 9) & (datt < 9); datt++) { AddAnAttacker(); if((catt !=xatt) & (NowBoard.sq_[datt][catt].side_ !=0)) catt=20; catt++; } catt=xatt; for(datt=yatt; (catt > 0) & (datt < 9); datt++) { AddAnAttacker(); if((catt !=xatt) & (NowBoard.sq_[datt][catt].side_ !=0)) catt=-20; catt--; } catt=xatt; for(datt=yatt; (catt < 9) & (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==60) | (patt==260) | (patt==224)) { 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==3) { 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==1) | (patt==2)) { if(satt==1) { datt=yatt + 1; catt=xatt; AddAnAttacker(); datt=yatt; catt=xatt + 1; AddAnAttacker(); } if(satt==2) { datt=yatt - 1; catt=xatt; AddAnAttacker(); datt=yatt; catt=xatt + 1; AddAnAttacker(); } if(satt==3) { datt=yatt - 1; catt=xatt; AddAnAttacker(); datt=yatt; catt=xatt - 1; AddAnAttacker(); } if(satt==4) { datt=yatt + 1; catt=xatt; AddAnAttacker(); datt=yatt; catt=xatt - 1; AddAnAttacker(); } } } } public int HowManyDefendersThere(Chsq chsq) { if(teams==4) return (Attackers[d[depth]][c[depth]][1] + Attackers[d[depth]][c[depth]][2] + Attackers[d[depth]][c[depth]][3] + Attackers[d[depth]][c[depth]][4]) - Attackers[d[depth]][c[depth]][chsq.side_]; if(teams==2) return (Attackers[d[depth]][c[depth]][1] + Attackers[d[depth]][c[depth]][2] + Attackers[d[depth]][c[depth]][3] + Attackers[d[depth]][c[depth]][4]) - Attackers[d[depth]][c[depth]][chsq.side_] - Attackers[d[depth]][c[depth]][friend(chsq.side_)]; else return 0; } public int HowManyEnemiesBearingDown(Chsq chsq) { return (Attackers[chsq.rank_][chsq.file_][1] + Attackers[chsq.rank_][chsq.file_][2] + Attackers[chsq.rank_][chsq.file_][3] + Attackers[chsq.rank_][chsq.file_][4]) - Attackers[chsq.rank_][chsq.file_][chsq.side_]; } 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 > 8) | (j < 1) | (i > 8) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_==whoisconcerned) return false; if(MaybeBoard.sq_[i][j].side_==friend(whoisconcerned)) return false; if(MaybeBoard.sq_[i][j].piece_==4) { 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_==9) { assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyThirdPlayerPawn(int i, int j, int k) { if((j > 8) | (j < 1) | (i > 8) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_==k) return false; if(MaybeBoard.sq_[i][j].side_==friend(k)) return false; if(pawnkind(i,j) !=3) 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; } else { return false; } } public boolean IsEnemyKing(int i, int j, int k) { if((j > 8) | (j < 1) | (i > 8) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_==k) return false; if(MaybeBoard.sq_[i][j].side_==friend(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; } else { return false; } } public boolean IsEnemyKnight(int i, int j, int k) { if((j > 8) | (j < 1) | (i > 8) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_==k) return false; if(MaybeBoard.sq_[i][j].side_==friend(k)) return false; if(MaybeBoard.sq_[i][j].piece_==3) { 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 int pawnkind(int i, int j){ if ((DynamicBastardo==true)&(turncounter<9)){return MaybeBoard.sq_[i][j].side_;} return i_began_as[i][j]; } public boolean IsEnemyFirstPlayerPawn(int i, int j, int k) { if((j > 8) | (j < 1) | (i > 8) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_==k) return false; if(MaybeBoard.sq_[i][j].side_==friend(k)) return false; if(pawnkind(i,j) !=1) 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; } else { return false; } } public boolean IsEnemyRook(int i, int j) { if((j > 8) | (j < 1) | (i > 8) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_==whoisconcerned) return false; if(MaybeBoard.sq_[i][j].side_==friend(whoisconcerned)) return false; if(MaybeBoard.sq_[i][j].piece_==5) { 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_==6) { 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 IsEnemySecondPlayerPawn(int i, int j, int k) { if((j > 8) | (j < 1) | (i > 8) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_==k) return false; if(MaybeBoard.sq_[i][j].side_==friend(k)) return false; if (pawnkind(i,j)!=2) 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; } else { return false; } } public boolean IsEnemyFourthPlayerPawn(int i, int j, int k) { if((j > 8) | (j < 1) | (i > 8) | (i < 1)) return false; if(MaybeBoard.sq_[i][j].side_==k) return false; if(MaybeBoard.sq_[i][j].side_==friend(k)) return false; if(pawnkind(i,j) !=4) 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; } 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) { if ((spite_move==true)&(i==whoseMove)){return false;} if(AnotherWayToCheck(i)) return true; whoisconcerned=i; for(xxx=1; xxx < 9; xxx++) for(yyy=1; yyy < 9; 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() { if (GameOver==true){return true;} if ((DynamicBastardo==true)&(turncounter<10)){return false;} CountAllThePieces(); if( (QueenCount[1]==0) & (QueenCount[2]==0) & (RookCount[1]==0) & (RookCount[2]==0) & (PawnCount[1]==0) & (PawnCount[2]==0) & (QueenCount[3]==0) & (QueenCount[4]==0) & (RookCount[3]==0) & (RookCount[2]==0) & (PawnCount[1]==0) & (PawnCount[4]==0) &(AmazonCount[1]==0)&(AmazonCount[2]==0)&(AmazonCount[3]==0)&(AmazonCount[4]==0) ) { if((BishopCount[1]==0) & (BishopCount[2]==0) & (KnightCount[1] < 3) & (KnightCount[2] < 3) & (BishopCount[3]==0) & (BishopCount[4]==0) & (KnightCount[3] < 3) & (KnightCount[4] < 3)) { GameOver=true; ShowStatusQ("Lack of force!");DeclareADraw();repaint(); return true; } if((BishopCount[1] < 2) & (BishopCount[2] < 2) & (KnightCount[1]==0) & (KnightCount[2]==0) & (BishopCount[3] < 2) & (BishopCount[4] < 2) & (KnightCount[3]==0) & (KnightCount[4]==0)) { GameOver=true; ShowStatusQ("Lack of force!"); DeclareADraw();repaint(); return true; } } return false; } public void LowRectangle(Graphics g) { g.setColor(niceblue); g.fillRect(0, 271, 300, 114); 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] < 9; x_run[1]++) for(y_run[1]=1; y_run[1] < 9; 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(); if(moveCounter==0) { System.out.println("No Moves");WhoIsHuman[1]=true;WhoIsHuman[2]=true;ShowStatusQ("No Moves"); return false; } x=1 + (int)Math.floor(Math.random() * (double)moveCounter); if((Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][1] + Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][2] + Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][3] + Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][4]) - Attackers[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((Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][1] + Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][2] + Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][3] + Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][4]) - Attackers[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].drawForchesschsq(g, 1, false, teams,i_began_as[mover_rank][mover_file]); NowBoard.sq_[moveto_rank][moveto_file].drawForchesschsq(g, 1, false, teams,i_began_as[moveto_rank][moveto_file]); // i_began_as[moveto_rank][moveto_file]=i_began_as[mover_rank][mover_file]; // i_began_as[mover_rank][mover_file]=0; 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 > 45) { fifty_move_rule=0; DrawNowBoard(g);ShowStatusQ("Fifty move rule!"); DeclareADraw(); GameOver=true;repaint(); return false; } else { return true; } } public boolean MaybeAdd(Graphics g, Chsq chsq, CB10_14 cb10_14, CB10_14 cb10_14_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] > 8) | (d[depth] < 1) | (d[depth] > 8)) { if ((c[depth]!=10)|(d[depth]!=4)){return false;} if ((evict_pawn==false)&(evict_knight==false)&(evict_bishop==false)&(evict_rook==false)&(evict_queen==false)&(evict_king==false)) {return false;} } if(!PassedOtherRequirementsToKeep(g, chsq, cb10_14, cb10_14_1)) return false; if(NowBoard.sq_[d[depth]][c[depth]].side_==chsq.side_) return false; alterMaybeBoard(g, chsq, cb10_14.sq_[d[depth]][c[depth]], cb10_14, cb10_14_1); worried=AmIWorried(chsq.side_); if(!IsMySideInCheck(chsq.side_)) ICanEscapeCheck[chsq.side_]=true; if((IsMySideInCheck(chsq.side_)) & (ICanEscapeCheck[chsq.side_])) { unalterMaybeBoard(g, chsq, cb10_14.sq_[d[depth]][c[depth]], cb10_14, cb10_14_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, cb10_14.sq_[d[depth]][c[depth]], cb10_14, cb10_14_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");WhoIsHuman[1]=true;WhoIsHuman[2]=true;} MaybeMoves[moveCounter].startingsquare_=chsq; MaybeMoves[moveCounter].endingsquare_=cb10_14.sq_[d[depth]][c[depth]]; } DesignateTheGoodMoves(chsq); if((worried) & (IsThisAGoodMove()==false) & (moveCounter > 1) & (!WhoIsHuman[whoseMove])) moveCounter--; unalterMaybeBoard(g, chsq, cb10_14.sq_[d[depth]][c[depth]], cb10_14, cb10_14_1); return NowBoard.sq_[d[depth]][c[depth]].side_==0; } public void MoreGoodMoves(Chsq chsq) { } public void AssignVariantName(){ variant_name="ForChess (cutthroat)"; } 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:", 240, 15); } public void NextOrdinaryPlayer(Graphics g) { IsTheGameOver(); if (spite_game==false){FindWhoCanMove(g);} if(GameOver) return; ICanEscapeCheck[1]=true; ICanEscapeCheck[2]=true; ICanEscapeCheck[3]=true; ICanEscapeCheck[4]=true; CountAllThePieces(); whoseMove++; UnTwoThePawns(whoseMove); if(whoseMove==5) {whoseMove=1;turncounter++;} if (spite_game==true){FindWhoCanMove(g);} whatpiecescanmove(g); GenerateAttackersArrays(); if(!CanMove[whoseMove]) { whoseMove++; if(whoseMove==5) {whoseMove=1;turncounter++;} whatpiecescanmove(g); } if(!CanMove[whoseMove]) { whoseMove++; if(whoseMove==5) {whoseMove=1;turncounter++;} whatpiecescanmove(g); } if(!CanMove[whoseMove]) { whoseMove++; if(whoseMove==5) {whoseMove=1;turncounter++;} whatpiecescanmove(g); } if (teams==4){ if(whoseMove==1) {ShowStatusQ("Red moves!");} if(whoseMove==2) ShowStatusQ("White moves!"); if(whoseMove==3) ShowStatusQ("Blue moves!"); if(whoseMove==4) ShowStatusQ("Gold moves!");} if (teams==2){ if(whoseMove==1) {ShowStatusQ("Scarlet moves!");} if(whoseMove==2) ShowStatusQ("Azure moves!"); if(whoseMove==3) ShowStatusQ("Maroon moves!"); if(whoseMove==4) ShowStatusQ("Indigo moves!");} ICanEscapeCheck[whoseMove]=false; for(ff=1; ff < 9; ff++) for(ee=1; ee < 9; ee++) if(NowBoard.sq_[ff][ee].side_==whoseMove) { skipDtGM=true; findPieceMoves(g, NowBoard.sq_[ff][ee], NowBoard, MaybeBoard); skipDtGM=false; } } public void NightMoves(Chsq chsq) { } public int NightScore(Chsq chsq) { return 0; } public void pawntook(){ pawns_taken[whoseMove]++; if ((take_five_pawns[whoseMove]==true)&(pawns_taken[whoseMove]==5)) { GameOver=true; wins[whoseMove]++; switch (whoseMove){ case 1:{ShowStatusQ("C took fifth pawn");break;} case 2:{ShowStatusQ("Gold took fifth pawn");break;} case 3:{ShowStatusQ("Shadow took fifth pawn");break;} case 4:{ShowStatusQ("Temple took fifth pawn");break;} } repaint(); } } public void unittook(){ units_taken[whoseMove]++; if ((take_ten_units[whoseMove]==true)&(units_taken[whoseMove]==10)) { GameOver=true; wins[whoseMove]++; switch (whoseMove){ case 1:{ShowStatusQ("C took tenth unit");break;} case 2:{ShowStatusQ("Gold took tenth unit");break;} case 3:{ShowStatusQ("Shadow took tenth unit");break;} case 4:{ShowStatusQ("Temple took tenth unit");break;} } repaint(); } } public void destroy_corner(){ x=1;while (x<5){ if ( (kingzy==1)&(take_1_king[x]==true) | (kingzy==2)&(take_2_king[x]==true) | (kingzy==3)&(take_3_king[x]==true) | (kingzy==4)&(take_4_king[x]==true) ) { if (x==whoseMove) { GameOver=true; wins[whoseMove]++; repaint(); switch(whoseMove){ case 1:{stringy="C captures";break;} case 2:{stringy="Gold captures";break;} case 3:{stringy="Shadow captures";break;} case 4:{stringy="Temple captures";break;} } switch(kingzy){ case 1:{stringy=stringy+" C king!";break;} case 2:{stringy=stringy+" Gold king!";break;} case 3:{stringy=stringy+" Shadow king!";break;} case 4:{stringy=stringy+" Temple king!";break;} } showStatus(stringy); } if (x!=whoseMove) { take_1_king[x]=false; take_2_king[x]=false; take_3_king[x]=false; take_4_king[x]=false; switch(whoseMove){ case 1:{take_1_king[x]=true;motto[x]="Take C king";repaint();break;} case 2:{take_2_king[x]=true;motto[x]="Take Gold king";repaint();break;} case 3:{take_3_king[x]=true;motto[x]="Take Shadow king";repaint();break;} case 4:{take_4_king[x]=true;motto[x]="Take Temple king";repaint();break;} } } } x++;} } 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_[moveto_rank][moveto_file].piece_==1) { pawntook(); } if ((NowBoard.sq_[moveto_rank][moveto_file].piece_!=0)&((NowBoard.sq_[moveto_rank][moveto_file].piece_!=3)|(death_knight[NowBoard.sq_[moveto_rank][moveto_file].side_]==false))) { unittook(); } if(NowBoard.sq_[mover_rank][mover_file].piece_ < 0) { KingRank[whoseMove]=moveto_rank; KingFile[whoseMove]=moveto_file; } NormalMoveExtra(); PawnStuff(g); 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) | (NowBoard.sq_[mover_rank][mover_file].piece_==8101) | (NowBoard.sq_[mover_rank][mover_file].piece_==8102)) { if ((HalloweenBastardo==false)|(NowBoard.sq_[moveto_rank][moveto_file].piece_!=3)){fifty_move_rule=0;} } else { fifty_move_rule++; if(fifty_move_rule > fifties_got_to) fifties_got_to=fifty_move_rule; } switch(NowBoard.sq_[moveto_rank][moveto_file].piece_) { case 0: // '\0' case 7: // '\007' case 8: // '\b' default: break; case -1: CapturedAKing[whoseMove]=true; kings_taken[whoseMove]++; kingzy=NowBoard.sq_[moveto_rank][moveto_file].side_; who_took_this_king[kingzy]=whoseMove; destroy_corner(); royal_rank[kingzy]=0;royal_file[kingzy]=0; z_forchess=NowBoard.sq_[mover_rank][mover_file].side_; for(x_forchess=1; x_forchess < 9; x_forchess++) for(y_forchess=1; y_forchess < 9; y_forchess++) if(NowBoard.sq_[y_forchess][x_forchess].side_==kingzy) { NowBoard.sq_[y_forchess][x_forchess].side_=z_forchess; if (NowBoard.sq_[y_forchess][x_forchess].piece_==1){pawntook();} } break; case -2: CapturedAKing[whoseMove]=true; break; case 1: // '\001' CapturedAPawn[whoseMove]=true; break; case 2: // '\002' CapturedAPawn[whoseMove]=true; break; case 3: // '\003' CapturedAKnight[whoseMove]=true; break; case 4: // '\004' CapturedABishop[whoseMove]=true; break; case 5: // '\005' CapturedARook[whoseMove]=true; break; case 6: // '\006' CapturedARook[whoseMove]=true; break; case 9: // '\t' CapturedAQueen[whoseMove]=true; break; } plague(); if ((royal_rank[whoseMove]==mover_rank)&(royal_file[whoseMove]==mover_file)) {royal_rank[whoseMove]=moveto_rank;royal_file[whoseMove]=moveto_file;} NowBoard.sq_[moveto_rank][moveto_file].piece_=NowBoard.sq_[mover_rank][mover_file].piece_; i_began_as[moveto_rank][moveto_file]=i_began_as[mover_rank][mover_file]; i_began_as[mover_rank][mover_file]=0; 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_==-18) NowBoard.sq_[moveto_rank][moveto_file].piece_=-17; 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_==224) NowBoard.sq_[moveto_rank][moveto_file].piece_=223; if(NowBoard.sq_[moveto_rank][moveto_file].piece_==-14) NowBoard.sq_[moveto_rank][moveto_file].piece_=-13; PromoStuff(g); TwoingPawns(); NowBoard.sq_[mover_rank][mover_file].side_=0; NowBoard.sq_[mover_rank][mover_file].piece_=0; if ((mover_file<9)&(moveto_file==10)) { NowBoard.sq_[moveto_rank][moveto_file].piece_=0; NowBoard.sq_[moveto_rank][moveto_file].side_=0; } TotalMaybeBoard(NowBoard, MaybeBoard); TotalMaybeBoard(MaybeBoard, TwoBoard); TotalMaybeBoard(TwoBoard, ThreeBoard); TotalMaybeBoard(ThreeBoard, FourBoard); NormalMoveFinale(g); ShowStatusNothing(); Archives(); inquire_about_terms(); if (WhoIsHuman[whoseMove]==true){SayWhoIsHuman(g);} } public void NormalMoveExtra() { } public void NormalMoveFinale(Graphics g) { } public boolean PassedOtherRequirementsToKeep(Graphics g,Chsq chsq, CB10_14 cb10_14, CB10_14 cb10_14_1) { if(KingCount[chsq.side_]==0) return false; if(chsq.piece_==1) if((chsq.rank_==d[depth]) | (chsq.file_==c[depth])) { if(cb10_14.sq_[d[depth]][c[depth]].piece_==0) return false; } else if(cb10_14.sq_[d[depth]][c[depth]].piece_ !=0) return false; return true; } public void PawnStuff(Graphics g) { if((mover_rank - moveto_rank) * (mover_rank - moveto_rank) !=1) return; if((mover_file - moveto_file) * (mover_file - moveto_file) !=1) return; if(((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) | (NowBoard.sq_[mover_rank][mover_file].piece_==85) | (NowBoard.sq_[mover_rank][mover_file].piece_==8101) | (NowBoard.sq_[mover_rank][mover_file].piece_==8102)) && ((NowBoard.sq_[mover_rank][moveto_file].piece_==2) | (NowBoard.sq_[mover_rank][moveto_file].piece_==52) | (NowBoard.sq_[mover_rank][moveto_file].piece_==84) | (NowBoard.sq_[mover_rank][moveto_file].piece_==102) | (NowBoard.sq_[mover_rank][moveto_file].piece_==8102))) { NowBoard.sq_[mover_rank][moveto_file].piece_=0; NowBoard.sq_[mover_rank][moveto_file].side_=0; ShowStatusQ("En Passant");CapturedAPawn[whoseMove]=true; NowBoard.sq_[mover_rank][moveto_file].drawForchesschsq(g, 1, false, teams,i_began_as[mover_rank][moveto_file]); MaybeBoard.sq_[mover_rank][moveto_file].side_=0; MaybeBoard.sq_[mover_rank][moveto_file].piece_=0; } } public void PromoStuff(Graphics g) { if (mover_file>8){return;} if(NowBoard.sq_[moveto_rank][moveto_file].piece_ !=1) return; if((i_began_as[moveto_rank][moveto_file]==1) & ((moveto_rank==8) | (moveto_file==8)) | (i_began_as[moveto_rank][moveto_file]==2) & ((moveto_rank==1) | (moveto_file==8)) | (i_began_as[moveto_rank][moveto_file]==3) & ((moveto_rank==1) | (moveto_file==1)) | (i_began_as[moveto_rank][moveto_file]==4) & ((moveto_rank==8) | (moveto_file==1))) if(!WhoIsHuman[whoseMove]) { NowBoard.sq_[moveto_rank][moveto_file].piece_=9; } else { PromotingAPawn=true; queening_rank=moveto_rank; queening_file=moveto_file; DrawPromotionOptions(g); } } public boolean PromotionClicks(int i, int j) { if(j < 300) return false; if(j > 330) return false; if(i < 90) return false; if(i > 210) return false; if(i < 120) xxx=9; else if(i < 150) xxx=5; else if(i < 180) xxx=4; else xxx=3; return true; } public void SayWhoIsHuman(Graphics g) { if(PromotingAPawn) return; g.setColor(niceblue); g.fillRect(0, 271, 300, 114); g.setColor(Color.black); g.setFont(f1); if (one_human==false){ if(teams==4) { g.drawString("Red:", 10, 290); g.drawString("White:", 10, 310); g.drawString("Blue:", 10, 330); g.drawString("Gold:", 10, 350); } if(teams==2) { g.drawString("Red 1:", 10, 290); g.drawString("Blue 1:", 10, 310); g.drawString("Red 2:", 10, 330); g.drawString("Blue 2:", 10, 350); } g.drawString("Computer", 120, 290); g.drawString("Computer", 120, 310); g.drawString("Computer", 120, 330); g.drawString("Computer", 120, 350); g.drawString("Human", 60, 290); g.drawString("Human", 60, 310); g.drawString("Human", 60, 330); g.drawString("Human", 60, 350);} g.setFont(f1);NameThisChessVariant(g); if(teams==4) g.drawString("Red " + wins[1] + " White " + wins[2] + " Blue " + wins[3] + " Gold " + wins[4] + " Drawn " + drawn_games, 5, 400); if(teams==2) g.drawString("Red " + wins[1] + " Blue " + wins[2] + " Drawn " + drawn_games, 5, 400); g.setFont(f3); g.drawString("--Ed Friedlander", 235, 400); g.setFont(f2); if(humanizing) g.drawString("OKAY", 210, 300); g.setColor(Color.red); if(teams==2) g.setColor(Color.red); if(WhoIsHuman[1]) { g.drawRect(56, 276, 48, 18); g.drawRect(57, 277, 46, 16); } if(!WhoIsHuman[1]) { g.drawRect(117, 276, 61, 18); g.drawRect(118, 277, 59, 16); } g.setColor(Color.white); if(teams==2) g.setColor(Color.blue); if(WhoIsHuman[2]) { g.drawRect(56, 296, 48, 18); g.drawRect(57, 297, 46, 16); } if(!WhoIsHuman[2]) { g.drawRect(117, 296, 61, 18); g.drawRect(118, 297, 59, 16); } g.setColor(Color.blue); if(teams==2) g.setColor(Color.red); if(WhoIsHuman[3]) { g.drawRect(56, 316, 48, 18); g.drawRect(57, 317, 46, 16); } if(!WhoIsHuman[3]) { g.drawRect(117, 316, 61, 18); g.drawRect(118, 317, 59, 16); } g.setColor(Color.yellow); if(teams==2) g.setColor(Color.blue); if(WhoIsHuman[4]) { g.drawRect(56, 336, 48, 18); g.drawRect(57, 337, 46, 16); } if(!WhoIsHuman[4]) { g.drawRect(117, 336, 61, 18); g.drawRect(118, 337, 59, 16); } } public void ShowStatusNothing() { if(GameOver){return;} if (teams==4) { if(whoseMove==1) {ShowStatusQ("Red moves!");} if(whoseMove==2) {ShowStatusQ("White moves!");} if(whoseMove==3) {ShowStatusQ("Blue moves!");} if(whoseMove==4) {ShowStatusQ("Gold moves!");} } if (teams==2) { if(whoseMove==1) {ShowStatusQ("Scarlet moves!");} if(whoseMove==2) {ShowStatusQ("Azure moves!");} if(whoseMove==3) {ShowStatusQ("Maroon moves!");} if(whoseMove==4) {ShowStatusQ("Indigo moves!");} } } public void StartUp(Graphics g) { spite_game=false; spite_move=false; evict_pawn=false; evict_knight=false; evict_bishop=false; evict_rook=false; evict_queen=false; evict_king=false; halt_if_king_taken=false; x=1;while (x<5){ who_took_this_king[x]=0; bare_king_wins[x]=false; death_knight[x]=false; kings_taken[x]=0; spectre_king[x]=false; royal_queen[x]=false; motto[x]=""; three_checks[x]=false; checks_in_a_row[x]=0; pawns_taken[x]=0; units_taken[x]=0; take_five_pawns[x]=false; take_ten_units[x]=false; take_1_king[x]=false; take_2_king[x]=false; take_3_king[x]=false; take_4_king[x]=false; royal_rank[x]=0;royal_file[x]=0; x++;} one_human=false; infindhoo=false; turncounter=1;saved_fifty_move_rule=0;saved_turncounter=1; DynamicBastardo=false; HalloweenBastardo=false; accepted_terms=false; who_is_winning=0; for(a=0; a < 3; a++) { ICanEscapeCheck[a]=true; IHaveBeenInCheck[a]=false; CapturedAKing[a]=false; CapturedAQueen[a]=false; CapturedARook[a]=false; CapturedAKnight[a]=false; CapturedABishop[a]=false; CapturedAPawn[a]=false; } for(a=1; a <=8; a++) for(b=1; b <=8; b++) { NowBoard.sq_[b][a].piece_=0; if(b < 5) { if(a < 5) NowBoard.sq_[b][a].side_=1; else NowBoard.sq_[b][a].side_=4; } else if(a < 5) NowBoard.sq_[b][a].side_=2; else NowBoard.sq_[b][a].side_=3; if(((b==3) | (b==6)) & ((a==3) | (a==6))) NowBoard.sq_[b][a].side_=0; } for(x=1; x < 9; x++) { NowBoard.sq_[4][x].piece_=1; NowBoard.sq_[5][x].piece_=1; NowBoard.sq_[x][5].piece_=1; NowBoard.sq_[x][4].piece_=1; } NowBoard.sq_[1][1].piece_=-1; NowBoard.sq_[8][1].piece_=-1; NowBoard.sq_[1][8].piece_=-1; NowBoard.sq_[8][8].piece_=-1; NowBoard.sq_[1][2].piece_=5; NowBoard.sq_[2][1].piece_=5; NowBoard.sq_[1][7].piece_=5; NowBoard.sq_[7][1].piece_=5; NowBoard.sq_[7][8].piece_=5; NowBoard.sq_[8][7].piece_=5; NowBoard.sq_[8][2].piece_=5; NowBoard.sq_[2][8].piece_=5; NowBoard.sq_[2][2].piece_=9; NowBoard.sq_[7][2].piece_=9; NowBoard.sq_[2][7].piece_=9; NowBoard.sq_[7][7].piece_=9; NowBoard.sq_[2][3].piece_=3; NowBoard.sq_[2][6].piece_=3; NowBoard.sq_[3][1].piece_=3; NowBoard.sq_[3][8].piece_=3; NowBoard.sq_[6][2].piece_=3; NowBoard.sq_[7][6].piece_=3; NowBoard.sq_[6][8].piece_=3; NowBoard.sq_[8][3].piece_=3; NowBoard.sq_[1][3].piece_=4; NowBoard.sq_[1][6].piece_=4; NowBoard.sq_[3][2].piece_=4; NowBoard.sq_[3][7].piece_=4; NowBoard.sq_[6][1].piece_=4; NowBoard.sq_[6][7].piece_=4; NowBoard.sq_[7][3].piece_=4; NowBoard.sq_[8][6].piece_=4; SupplementalStartup(); ForGambler(g); PromotingAPawn=false; GameOver=false; fifty_move_rule=0; DrawNowBoard(g); CountAllThePieces(); TotalMaybeBoard(NowBoard, MaybeBoard); TotalMaybeBoard(MaybeBoard, TwoBoard); TotalMaybeBoard(TwoBoard, ThreeBoard); TotalMaybeBoard(ThreeBoard, FourBoard); whoseMove=1; for(x=1; x < 14; x++) for(y=1; y < 9; y++) { MaybeBoard.sq_[y][x].side_=NowBoard.sq_[y][x].side_; MaybeBoard.sq_[y][x].piece_=NowBoard.sq_[y][x].piece_; i_began_as[y][x]=NowBoard.sq_[y][x].side_; } whatpiecescanmove(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, CB10_14 cb10_14, CB10_14 cb10_14_1) { } public void SupplementalStartup() { ShowStatusQ("Red moves!"); teams=4; } public void SupplementalStartup(Graphics g) { } public void TotalMaybeBoard(CB10_14 cb10_14, CB10_14 cb10_14_1) { for(xxx=1; xxx < 13; xxx++) for(yyy=1; yyy < 9; yyy++) { cb10_14_1.sq_[yyy][xxx].side_=cb10_14.sq_[yyy][xxx].side_; cb10_14_1.sq_[yyy][xxx].piece_=cb10_14.sq_[yyy][xxx].piece_; } } public void TwoingPawns() { if((NowBoard.sq_[moveto_rank][moveto_file].side_==1) & (NowBoard.sq_[moveto_rank][moveto_file].piece_==1) & (moveto_rank==4) & (mover_rank < 3)) NowBoard.sq_[moveto_rank][moveto_file].piece_=2; if((NowBoard.sq_[moveto_rank][moveto_file].side_==8101) & (NowBoard.sq_[moveto_rank][moveto_file].piece_==1) & (moveto_rank==4) & (mover_rank < 3)) NowBoard.sq_[moveto_rank][moveto_file].piece_=8102; if((NowBoard.sq_[moveto_rank][moveto_file].side_==1) & (NowBoard.sq_[moveto_rank][moveto_file].piece_==51) & (moveto_rank==4) & (mover_rank < 3)) NowBoard.sq_[moveto_rank][moveto_file].piece_=52; if((NowBoard.sq_[moveto_rank][moveto_file].side_==1) & (NowBoard.sq_[moveto_rank][moveto_file].piece_==83) & (moveto_rank==4) & (mover_rank < 3)) NowBoard.sq_[moveto_rank][moveto_file].piece_=84; if((NowBoard.sq_[moveto_rank][moveto_file].side_==2) & (NowBoard.sq_[moveto_rank][moveto_file].piece_==1) & (moveto_rank==5) & (mover_rank > 6)) NowBoard.sq_[moveto_rank][moveto_file].piece_=2; if((NowBoard.sq_[moveto_rank][moveto_file].side_==2) & (NowBoard.sq_[moveto_rank][moveto_file].piece_==8101) & (moveto_rank==5) & (mover_rank > 6)) NowBoard.sq_[moveto_rank][moveto_file].piece_=8102; if((NowBoard.sq_[moveto_rank][moveto_file].side_==2) & (NowBoard.sq_[moveto_rank][moveto_file].piece_==51) & (moveto_rank==5) & (mover_rank > 6)) NowBoard.sq_[moveto_rank][moveto_file].piece_=52; if((NowBoard.sq_[moveto_rank][moveto_file].side_==2) & (NowBoard.sq_[moveto_rank][moveto_file].piece_==83) & (moveto_rank==5) & (mover_rank > 6)) NowBoard.sq_[moveto_rank][moveto_file].piece_=84; } public void UnTwoThePawns(int i) { } public void ZeroAllFiveCounts() { AmazonCount[0]=0; AmazonCount[1]=0; AmazonCount[2]=0; AmazonCount[3]=0; AmazonCount[4]=0; 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; KingCount[3]=0; QueenCount[3]=0; RookCount[3]=0; BishopCount[3]=0; KnightCount[3]=0; PawnCount[4]=0; KingCount[4]=0; QueenCount[4]=0; RookCount[4]=0; BishopCount[4]=0; KnightCount[4]=0; } public void alterMaybeBoard(Graphics g, Chsq chsq, Chsq chsq1, CB10_14 cb10_14, CB10_14 cb10_14_1) { cb10_14_1.sq_[chsq.rank_][chsq.file_].piece_=0; cb10_14_1.sq_[chsq.rank_][chsq.file_].side_=0; cb10_14_1.sq_[chsq1.rank_][chsq1.file_].piece_=cb10_14.sq_[chsq.rank_][chsq.file_].piece_; cb10_14_1.sq_[chsq1.rank_][chsq1.file_].side_=cb10_14.sq_[chsq.rank_][chsq.file_].side_; if((cb10_14.sq_[chsq.rank_][chsq.file_].piece_==1) & (cb10_14.sq_[chsq1.rank_][chsq1.file_].side_==0) & (chsq.file_ !=chsq1.file_) & ((chsq.rank_ - chsq1.rank_) * (chsq.rank_ - chsq1.rank_)==1) & ((chsq.file_ - chsq1.file_) * (chsq.file_ - chsq1.file_)==1)) { cb10_14_1.sq_[chsq.rank_][chsq1.file_].piece_=0; cb10_14_1.sq_[chsq.rank_][chsq1.file_].side_=0; } } public void ForChessPawns(Graphics g, Chsq chsq, CB10_14 cb10_14, CB10_14 cb10_14_1) { if(i_began_as[chsq.rank_][chsq.file_]==1) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb10_14, cb10_14_1); } if(i_began_as[chsq.rank_][chsq.file_]==2) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb10_14, cb10_14_1); } if(i_began_as[chsq.rank_][chsq.file_]==3) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb10_14, cb10_14_1); } if(i_began_as[chsq.rank_][chsq.file_]==4) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb10_14, cb10_14_1); } } public boolean findPieceMoves(Graphics g, Chsq chsq, CB10_14 cb10_14, CB10_14 cb10_14_1) { CheckSquare[depth]=false; SquatterOnCheckSquare[depth]=false; SupplementalMovers(g, chsq, cb10_14, cb10_14_1); if ((evict_pawn==true)&((chsq.piece_==1)|(chsq.piece_==2))) { c[depth]=10;d[depth]=4;MaybeAdd(g,chsq,cb10_14,cb10_14_1); } if ((evict_knight==true)&(chsq.piece_==3)) { c[depth]=10;d[depth]=4;MaybeAdd(g,chsq,cb10_14,cb10_14_1); } if ((evict_bishop==true)&(chsq.piece_==3)) { c[depth]=10;d[depth]=4;MaybeAdd(g,chsq,cb10_14,cb10_14_1); } if ((evict_rook==true)&((chsq.piece_==5)|(chsq.piece_==6))) { c[depth]=10;d[depth]=4;MaybeAdd(g,chsq,cb10_14,cb10_14_1); } if ((evict_queen==true)&(chsq.piece_==9)) { c[depth]=10;d[depth]=4;MaybeAdd(g,chsq,cb10_14,cb10_14_1); } if ((evict_king==true)&((chsq.piece_==-1)|(chsq.piece_==-2))) { c[depth]=10;d[depth]=4;MaybeAdd(g,chsq,cb10_14,cb10_14_1); } if (chsq.file_>8) { c[depth]=1;while (c[depth]<9){ d[depth]=1;while (d[depth]<9){ if (cb10_14.sq_[d[depth]][c[depth]].piece_==0) {MaybeAdd(g, chsq, cb10_14, cb10_14_1);} d[depth]++;}c[depth]++;} return true; } if((chsq.piece_==60) | (chsq.piece_==260) | (chsq.piece_==224)) { c[depth]=chsq.file_ - 2; d[depth]=chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 2; d[depth]=chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 2; d[depth]=chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 2; d[depth]=chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_14, cb10_14_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, cb10_14, cb10_14_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, cb10_14, cb10_14_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, cb10_14, cb10_14_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, cb10_14, cb10_14_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (!SquatterOnCheckSquare[depth]); d[depth]++); } if((chsq.piece_==9) | (chsq.piece_==4) | (chsq.piece_==21) | (chsq.piece_==28) | (chsq.piece_==109) | (chsq.piece_==104)) { c[depth]=chsq.file_ - 1; for(d[depth]=chsq.rank_ - 1; (MaybeAdd(g, chsq, cb10_14, cb10_14_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (!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) | (chsq.piece_==109) | (chsq.piece_==104)) { c[depth]=chsq.file_ - 1; for(d[depth]=chsq.rank_ + 1; (MaybeAdd(g, chsq, cb10_14, cb10_14_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (!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) | (chsq.piece_==109) | (chsq.piece_==104)) { c[depth]=chsq.file_ + 1; for(d[depth]=chsq.rank_ - 1; (MaybeAdd(g, chsq, cb10_14, cb10_14_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (!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) | (chsq.piece_==109) | (chsq.piece_==104)) { c[depth]=chsq.file_ + 1; for(d[depth]=chsq.rank_ + 1; (MaybeAdd(g, chsq, cb10_14, cb10_14_1)) | (CheckSquare[depth]) & (chsq.piece_ !=-9) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] + 1) c[depth]=c[depth] + 1; } if((chsq.piece_==-1) | (chsq.piece_==-2) | (chsq.piece_==-13) | (chsq.piece_==-14) | (chsq.piece_==25)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); } if(chsq.piece_==140) { c[depth]=chsq.file_; d[depth]=chsq.rank_ + 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_ !=0) MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ - 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_ !=0) MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_==0) MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_==0) MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_==0) MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_==0) MaybeAdd(g, chsq, cb10_14, cb10_14_1); } if((chsq.piece_==23) | (chsq.piece_==123) | (chsq.piece_==223) | (chsq.piece_==224)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); } if((chsq.piece_==3) | (chsq.piece_==193) | (chsq.piece_==-4) | (chsq.piece_==-5) | (chsq.piece_==21) | (chsq.piece_==28) | (chsq.piece_==57) | (chsq.piece_==29) | (chsq.piece_==103)) { c[depth]=chsq.file_ - 2; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 2; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 2; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 2; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_14, cb10_14_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_14, cb10_14_1); } if((chsq.piece_==1) | (chsq.piece_==2)) {ForChessPawns(g, chsq, cb10_14, cb10_14_1);} return true; } public int friend(int i) { if(teams==4) return 0; switch(i) { case 1: // '\001' return 3; case 2: // '\002' return 4; case 3: // '\003' return 1; case 4: // '\004' return 2; } return 0; } public void init() { seek_sacrificial_wins=false; spite_game=false; spite_move=false; evict_pawn=false; evict_knight=false; evict_bishop=false; evict_rook=false; evict_queen=false; evict_king=false; halt_if_king_taken=true; niceblue=new Color(0, 192, 255); CanMove=new boolean[5]; IHaveBeenInCheck=new boolean[5]; ICanEscapeCheck=new boolean[5]; CapturedAKing=new boolean[5]; bare_king_wins=new boolean[5]; death_knight=new boolean[5]; spectre_king=new boolean[5]; royal_queen=new boolean[5]; motto=new String[5]; three_checks=new boolean[5]; take_five_pawns=new boolean[5]; take_ten_units=new boolean[5]; take_1_king=new boolean[5]; take_2_king=new boolean[5]; take_3_king=new boolean[5]; take_4_king=new boolean[5]; PawnCount=new int[5]; KnightCount=new int[5]; BishopCount=new int[5]; RookCount=new int[5]; QueenCount=new int[5]; AmazonCount=new int[5]; KingCount=new int[5]; Attackers=new int[10][14][5]; StrongestAttacker=new int[10][14][5]; WeakestAttacker=new int[10][14][5]; NowBoard=new CB10_14(308); SaveBoard=new CB10_14(308); BackBoard=new CB10_14(308); MaybeBoard=new CB10_14(308); OneBoard=new CB10_14(308); TwoBoard=new CB10_14(308); ThreeBoard=new CB10_14(308); FourBoard=new CB10_14(308); icanmove=new boolean[10][14]; ArchiveBoard=new CB10_14[102]; 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]; wins=new int[5]; depth=0; WhoIsHuman[1]=true; WhoIsHuman[2]=true; WhoIsHuman[3]=true; WhoIsHuman[4]=true; SupplementalInit(); GameOver=false; PromotingAPawn=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 CB10_14(310);} millipede2=System.currentTimeMillis(); how_deep_to_seek=1; i_began_as=new int[10][14]; who_took_this_king=new int[5]; kings_taken=new int[5]; royal_rank=new int[5]; royal_file=new int[5]; term_counts=new int[5]; best_four_count=new int[7]; KingFile=new int[6]; KingRank=new int[6]; CapturedAQueen=new boolean[5]; CapturedABishop=new boolean[5]; CapturedARook=new boolean[5]; CapturedAKnight=new boolean[5]; CapturedAPawn=new boolean[5]; checks_in_a_row=new int[5]; pawns_taken=new int[5]; units_taken=new int[5]; back_i_began_as=new int[10][14]; back_who_took_this_king=new int[5]; back_kings_taken=new int[5]; back_royal_rank=new int[5]; back_royal_file=new int[5]; back_term_counts=new int[5]; back_best_four_count=new int[7]; back_KingFile=new int[6]; back_KingRank=new int[6]; back_CapturedAKing=new boolean[5]; back_CapturedAQueen=new boolean[5]; back_CapturedABishop=new boolean[5]; back_CapturedARook=new boolean[5]; back_CapturedAKnight=new boolean[5]; back_CapturedAPawn=new boolean[5]; back_checks_in_a_row=new int[5]; back_pawns_taken=new int[5]; back_units_taken=new int[5]; save_i_began_as=new int[10][14]; save_who_took_this_king=new int[5]; save_kings_taken=new int[5]; save_royal_rank=new int[5]; save_royal_file=new int[5]; save_term_counts=new int[5]; save_best_four_count=new int[7]; save_KingFile=new int[6]; save_KingRank=new int[6]; save_CapturedAKing=new boolean[5]; save_CapturedAQueen=new boolean[5]; save_CapturedABishop=new boolean[5]; save_CapturedARook=new boolean[5]; save_CapturedAKnight=new boolean[5]; save_CapturedAPawn=new boolean[5]; save_checks_in_a_row=new int[5]; save_pawns_taken=new int[5]; save_units_taken=new int[5]; 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; AlsoMark(g); 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].drawForchesschsq(g, 1, icanmove[i][j], teams,i_began_as[i][j]); return false; } NowBoard.sq_[i][j].drawForchesschsq(g, 2, icanmove[i][j], teams,i_began_as[i][j]); for(x=1; x <=moveCounter; x++) MaybeMoves[x].endingsquare_.markchsq(g); 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) | (PromotingAPawn)) { return true; } else { DisplayRules(g); return true; } if(!PromotingAPawn) SayWhoIsHuman(g); if(PromotingAPawn) DrawPromotionOptions(g); if(GameOver) { GameOver=false; StartUp(g); repaint(); return true; } a=i / 30; b=9 - j / 30; if(!PromotingAPawn) if((i >=56) & (j >=276) & (i <=104) & (j <=294) & (one_human==false)) { humanizing=true; WhoIsHuman[1]=true; SayWhoIsHuman(g); } else if((i >=117) & (j >=276) & (i <=178) & (j <=294) & (one_human==false)) { humanizing=true; WhoIsHuman[1]=false; SayWhoIsHuman(g); } else if((i >=56) & (j >=296) & (i <=104) & (j <=314) & (one_human==false)) { humanizing=true; WhoIsHuman[2]=true; SayWhoIsHuman(g); } else if((i >=117) & (j >=296) & (i <=178) & (j <=314) & (one_human==false)) { humanizing=true; WhoIsHuman[2]=false; SayWhoIsHuman(g); } else if((i >=26) & (j > 356) & (i <=93) & (j <=374)) { if(who_is_winning==0) return true; humanizing=true; accepted_terms=true; SayWhoIsHuman(g); } else if((i >=147) & (j >=356) & (i < 242) & (j < 374)) { if(who_is_winning==0) return true; humanizing=true; accepted_terms=false; SayWhoIsHuman(g); } else if((i >=56) & (j >=316) & (i <=104) & (j <=334) & (one_human==false)) { humanizing=true; WhoIsHuman[3]=true; SayWhoIsHuman(g); } else if((i >=117) & (j >=316) & (i <=178) & (j <=334) & (one_human==false)) { humanizing=true; WhoIsHuman[3]=false; SayWhoIsHuman(g); } else if((i >=56) & (j >=336) & (i <=104) & (j <=354) & (one_human==false)) { humanizing=true; WhoIsHuman[4]=true; SayWhoIsHuman(g); } else if((i >=117) & (j >=336) & (i <=178) & (j <=354) & (one_human==false)) { humanizing=true; WhoIsHuman[4]=false; SayWhoIsHuman(g); } else if((i >=210) & (j >=285) & (i < 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].drawForchesschsq(g, 1, false, teams,i_began_as[queening_rank][queening_file]); TotalMaybeBoard(NowBoard,MaybeBoard);DidICheckOrStalemate(g, whoseMove); PromotingAPawn=false; if (WhoIsHuman[whoseMove]==true){SayWhoIsHuman(g);} NextOrdinaryPlayer(g); if(WhoIsHuman[whoseMove]) { markingAPiece=true; return true; } } if((a < 1) | (a > 12) | (b < 1) | (b > 8) && WhoIsHuman[whoseMove]) return true; if(WhoIsHuman[whoseMove]) if(markingAPiece) markAPiece(g, b, a); else if(HumanMoveAPiece(g, b, a)) { if(GameOver) return true; if(PromotingAPawn) return true; NextOrdinaryPlayer(g); } while((!WhoIsHuman[whoseMove]) & (!GameOver) & (!PromotingAPawn)) { MachineMoves(g, whoseMove); if(GameOver) return true; NextOrdinaryPlayer(g); 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); if(teams==4) g.drawString("Final totals: Red " + wins[1] + " White " + wins[2] + " Blue " + wins[3] + " Gold " + wins[4] + " Drawn " + drawn_games, 5, 400); if(teams==2) g.drawString("Final totals: Red " + wins[1] + " Blue " + wins[2] + " Drawn " + drawn_games, 5, 400); return; } paintSomethingElse(g); DrawNowBoard(g); g.setColor(niceblue); g.fillRect(0, 271, 300, 49); g.setColor(Color.black); g.setFont(f1); g.setColor(Color.black); if(!PromotingAPawn) SayWhoIsHuman(g); if(PromotingAPawn) DrawPromotionOptions(g); if((!markingAPiece) & (WhoIsHuman[whoseMove])) { NowBoard.sq_[mover_rank][mover_file].drawForchesschsq(g, 2, icanmove[mover_rank][mover_file], teams,i_began_as[mover_rank][mover_file]); for(x=1; x <=moveCounter; x++) MaybeMoves[x].endingsquare_.markchsq(g); } paintSomethingElse2(g); } public void paintSomethingElse(Graphics g) { } public void paintSomethingElse2(Graphics g) { } 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, CB10_14 cb10_14, CB10_14 cb10_14_1) { cb10_14_1.sq_[chsq.rank_][chsq.file_].piece_=cb10_14.sq_[chsq.rank_][chsq.file_].piece_; cb10_14_1.sq_[chsq.rank_][chsq.file_].side_=cb10_14.sq_[chsq.rank_][chsq.file_].side_; cb10_14_1.sq_[chsq1.rank_][chsq1.file_].piece_=cb10_14.sq_[chsq1.rank_][chsq1.file_].piece_; cb10_14_1.sq_[chsq1.rank_][chsq1.file_].side_=cb10_14.sq_[chsq1.rank_][chsq1.file_].side_; cb10_14_1.sq_[chsq.rank_][chsq1.file_].piece_=cb10_14.sq_[chsq.rank_][chsq1.file_].piece_; cb10_14_1.sq_[chsq.rank_][chsq1.file_].side_=cb10_14.sq_[chsq.rank_][chsq1.file_].side_; cb10_14_1.sq_[chsq1.rank_][chsq.file_].piece_=cb10_14.sq_[chsq1.rank_][chsq.file_].piece_; cb10_14_1.sq_[chsq1.rank_][chsq.file_].side_=cb10_14.sq_[chsq1.rank_][chsq.file_].side_; } public void DeclareADraw(){ drawn_games++; } public void whatpiecescanmove(Graphics g) { for(ee=1; ee < 13; ee++) for(ff=1; ff < 9; ff++) { if(NowBoard.sq_[ff][ee].piece_ < 0) { KingRank[NowBoard.sq_[ff][ee].side_]=ff; KingFile[NowBoard.sq_[ff][ee].side_]=ee; } icanmove[ff][ee]=false; moveCounter=0; 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; 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; 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 boolean skipDtGM; static boolean worried; static int teams; static int whoisconcerned; Color niceblue; 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; boolean CanMove[]; boolean IHaveBeenInCheck[]; boolean ICanEscapeCheck[]; int PawnCount[]; int KnightCount[]; int BishopCount[]; int RookCount[]; int QueenCount[]; int AmazonCount[]; int KingCount[]; int Attackers[][][]; int StrongestAttacker[][][]; int WeakestAttacker[][][]; CB10_14 NowBoard; CB10_14 BackBoard; CB10_14 SaveBoard; CB10_14 MaybeBoard; CB10_14 OneBoard; CB10_14 TwoBoard; CB10_14 ThreeBoard; CB10_14 FourBoard; boolean icanmove[][]; CB10_14 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; static int z_forchess; static int y_forchess; static int x_forchess; 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 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 DynamicBastardo; static boolean HalloweenBastardo; static boolean PromotingAPawn; static boolean humanizing; static boolean infindhoo; static boolean one_human; static int mover_rank; static int mover_file; static int moveto_rank; static int moveto_file; static int queening_rank; static int kingzy; static int queening_file; Font f1; Font f2; Font f3; static int turncounter;static int saved_turncounter;static int back_turncounter;static int saved_fifty_move_rule;static int back_fifty_move_rule; static int drawn_games; static int fifty_move_rule; static int whoseMove; boolean WhoIsHuman[]; int wins[]; boolean bare_king_wins[]; boolean death_knight []; boolean spectre_king []; boolean royal_queen []; String motto[]; boolean take_1_king[]; boolean take_2_king[]; boolean take_3_king[]; boolean take_4_king[]; static boolean halt_if_king_taken; boolean three_checks[]; static String stringy; static boolean spite_game; static boolean spite_move; static boolean evict_pawn; static boolean evict_knight; static boolean evict_bishop; static boolean evict_rook; static boolean evict_queen; static boolean evict_king; static char oopsKey; static char loadKey; static char saveKey; static int who_backed; static int who_saved;static int when_saved; static boolean seek_sacrificial_wins; int KingFile[]; int KingRank[]; int checks_in_a_row[]; int pawns_taken[]; int i_began_as[][]; int who_took_this_king[]; int units_taken[]; boolean take_five_pawns[]; boolean take_ten_units[]; int royal_rank[]; int royal_file[]; int kings_taken[]; boolean CapturedAKing[]; boolean CapturedAQueen[]; boolean CapturedABishop[]; boolean CapturedARook[]; boolean CapturedAKnight[]; boolean CapturedAPawn[]; int term_counts[]; int best_four_count[]; int back_KingFile[]; int back_KingRank[]; int back_checks_in_a_row[]; int back_pawns_taken[]; int back_i_began_as[][]; int back_who_took_this_king[]; int back_units_taken[]; int back_royal_rank[]; int back_royal_file[]; int back_kings_taken[]; boolean back_CapturedAKing[]; boolean back_CapturedAQueen[]; boolean back_CapturedABishop[]; boolean back_CapturedARook[]; boolean back_CapturedAKnight[]; boolean back_CapturedAPawn[]; int back_term_counts[]; int back_best_four_count[]; int save_KingFile[]; int save_KingRank[]; int save_checks_in_a_row[]; int save_pawns_taken[]; int save_i_began_as[][]; int save_who_took_this_king[]; int save_units_taken[]; int save_royal_rank[]; int save_royal_file[]; int save_kings_taken[]; boolean save_CapturedAKing[]; boolean save_CapturedAQueen[]; boolean save_CapturedABishop[]; boolean save_CapturedARook[]; boolean save_CapturedAKnight[]; boolean save_CapturedAPawn[]; int save_term_counts[]; int save_best_four_count[]; }