// 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: Millenni.java import java.applet.Applet; import java.awt.*; import java.io.PrintStream; public class Millenni extends Applet { public Millenni() { } public void SomethingElseForTotalBackBoard() { } public void SomethingElseForTotalSaveBoard() { } public void SomethingElseForUnBackBoard() { } public void SomethingElseForLoadSavedBoard() { } public boolean SomeInitialConditionForKeydown(){ return false; } public boolean keyDown(Event e, int k) { if (humanizing==true){return false;} if (SomeInitialConditionForKeydown()==true){return true;} Graphics g=getGraphics(); oopsKey=getParameter("OOPS").charAt(0); saveKey=getParameter("SAVE").charAt(0); loadKey=getParameter("LOAD").charAt(0); if (k==oopsKey) { PromotingAPawn=false; GameOver=false; UnBackBoard();TotalMaybeBoard(NowBoard, MaybeBoard); markingAPiece=true; whoseMove=who_backed; SayWhoIsHuman(g); whatpiecescanmove(g); TotalMaybeBoard(NowBoard, MaybeBoard); GenerateAttackersArrays(); CountAllThePieces(); DrawNowBoard(g); return true; } if (k==saveKey) { TotalSaveBoard();TotalMaybeBoard(NowBoard, MaybeBoard); who_saved=whoseMove; } if (k==loadKey) { PromotingAPawn=false; GameOver=false; LoadSavedBoard();TotalMaybeBoard(NowBoard, MaybeBoard); markingAPiece=true; whoseMove=who_backed; SayWhoIsHuman(g); whatpiecescanmove(g); TotalMaybeBoard(NowBoard, MaybeBoard); GenerateAttackersArrays(); CountAllThePieces(); DrawNowBoard(g); return true; } System.out.println("kurwa"); return false; } public void TotalBackBoard(){back_turncounter=turncounter;back_fifty_move_rule=fifty_move_rule; for(xxx=0; xxx < 16; xxx++) for(yyy=0; 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=0; xxx < 16; xxx++) for(yyy=0; 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=0; xxx < 16; xxx++) for(yyy=0; 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=0; xxx < 16; xxx++) for(yyy=0; 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 void DisplayRules(Graphics g) { LowRectangle(g); g.drawString("Capture one king, checkmate the second", 5, 285); g.drawString("Pawns promote only to previous captured units.", 5, 301); g.drawString("Castle out of or through check if two kings", 5, 317); g.drawString("remain. Proprietary game, circa 2003.", 5, 333); } public int PromoUnit(int i){ if (QueenCount[i]<2){return 9;} if (RookCount[i]<3){return 5;} if (BishopCount[i]<4){return 4;} if (KnightCount[i]<4){return 3;} return 21; } public boolean WinsAnotherWay(Chsq chsq){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 A2PromoSpecial(Graphics g){} public void AddACLCAttacker() { //System.out.println("EasyChss.AddACLCAttacker"); if((xatt==catt) & (yatt==datt)) return; if((catt>15) | (datt>8) | (catt<1) | (datt<1)) return; if(satt>2) { return; } else { CLCAttackers[datt][catt][satt]++; return; } } public void AddAnAttacker() { //System.out.println("EasyChss.AddAnAttacker"); if((xatt==catt) & (yatt==datt)) return; if((catt>15) | (datt>8) | (catt<1) | (datt<1)) return; if(satt>2) { return; } else { Attackers[datt][catt][satt]++; if (StrongestAttacker[datt][catt][satt]NowBoard.sq_[yatt][xatt].m_strength()) | (WeakestAttacker[datt][catt][satt]==0)) {WeakestAttacker[datt][catt][satt]=NowBoard.sq_[yatt][xatt].m_strength();} return; } } public void AlsoMark(Graphics g) { } public boolean AmIUnderAttack(int i, int j, int k) { //System.out.println("EasyChss.AmIUnderAttack"); if(SupplementalAmIUnderAttackers(i, j, k)) return true; cc=j + 1; dd=i; while(cc<16) 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<16) & (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<16) & (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(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; } return false; } public boolean AmIUnderSparrowAttack(int i, int j, int k) { //System.out.println("EasyChss.AmIUnderSparrowAttack"); if(SupplementalAmIUnderSparrowAttackers(i, j, k)) return true; cc=j + 1; dd=i; while(cc<16) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=10; } else { if(IsEnemyRook(dd, cc) && MaybeBoard.sq_[dd][cc].m_strength()0) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=-1; } else { if(IsEnemyRook(dd, cc) && MaybeBoard.sq_[dd][cc].m_strength()0;) if(MaybeBoard.sq_[dd][cc].side_==k) { dd=-1; } else { if(IsEnemyRook(dd, cc) && MaybeBoard.sq_[dd][cc].m_strength() 0);) if(MaybeBoard.sq_[dd][cc].side_==k) { cc=20; } else { if((MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength())&&(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((MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength())&&(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((MaybeBoard.sq_[dd][cc].strength() < MaybeBoard.sq_[i][j].strength())&&(IsEnemyBishop(dd, cc))) return true; if(MaybeBoard.sq_[dd][cc].piece_ !=0) cc=-1; cc--; dd--; } cc=j - 2; dd=i - 1; if(IsEnemyKnight(dd, cc, k) && MaybeBoard.sq_[dd][cc].m_strength()1)) return false; if(i !=whoseMove) return false; for(xxx=1; xxx<16; xxx++) for(yyy=1; yyy<16; yyy++) if((MaybeBoard.sq_[yyy][xxx].side_==i) & (MaybeBoard.sq_[yyy][xxx].m_strength()>1) & (MaybeBoard.sq_[yyy][xxx].m_strength()>NowBoard.sq_[d[depth]][c[depth]].m_strength()) && AmIUnderSparrowAttack(yyy, xxx, i)) return true; return false; } public boolean AnotherReasonNotToCastleKingside(int i) { return false; } public boolean AnotherReasonNotToCastleQueenside(int i) { return false; } public boolean AnotherWayToCheck(int i) { return false; } public boolean AnotherWayToEndGame(Graphics g, int i) { return false; } public void Archives() { //System.out.println("EasyChss.Archives"); ArchiveCounter=0; for(ff=1; ff<9; ff++) for(ee=1; ee<16; ee++) { ArchiveBoard[fifty_move_rule].sq_[ff][ee].piece_=NowBoard.sq_[ff][ee].piece_; ArchiveBoard[fifty_move_rule].sq_[ff][ee].side_=NowBoard.sq_[ff][ee].side_; } ArchiveBoard[fifty_move_rule].sq_[0][0].side_=whoseMove; for(xxx=0; xxx1) { if ((perpetual_check_wins==false)|(IsMySideInCheck(3-whoseMove)==false)) { drawn_games++; ShowStatusQ("Draw By Repetition"); } else { wins[whoseMove]++; ShowStatusQ("Perpetual check wins!"); } GameOver=true; return; } } } public void BlackCastleMessage() { } public void CastleStuff(Graphics g) { //System.out.println("EasyChss.CastleStuff"); if((NowBoard.sq_[moveto_rank][moveto_file].piece_==-2) | (NowBoard.sq_[moveto_rank][moveto_file].piece_==-14)) { if(moveto_file==7) { ShowStatusQ("Castling King Side"); NowBoard.sq_[moveto_rank][6].side_=NowBoard.sq_[mover_rank][mover_file].side_; NowBoard.sq_[moveto_rank][6].piece_=5; NowBoard.sq_[moveto_rank][8].side_=0; NowBoard.sq_[moveto_rank][8].piece_=0; NowBoard.sq_[moveto_rank][6].drawchsq(g, 1, false); NowBoard.sq_[moveto_rank][8].drawchsq(g, 1, false); MaybeBoard.sq_[moveto_rank][6].side_=NowBoard.sq_[mover_rank][mover_file].side_; MaybeBoard.sq_[moveto_rank][6].piece_=5; MaybeBoard.sq_[moveto_rank][8].side_=0; MaybeBoard.sq_[moveto_rank][8].piece_=0; } if(moveto_file==3) { ShowStatusQ("Castling Queen Side"); NowBoard.sq_[moveto_rank][4].side_=NowBoard.sq_[mover_rank][mover_file].side_; NowBoard.sq_[moveto_rank][4].piece_=5; NowBoard.sq_[moveto_rank][1].side_=0; NowBoard.sq_[moveto_rank][1].piece_=0; NowBoard.sq_[moveto_rank][4].drawchsq(g, 1, false); NowBoard.sq_[moveto_rank][1].drawchsq(g, 1, false); MaybeBoard.sq_[moveto_rank][4].side_=NowBoard.sq_[mover_rank][mover_file].side_; MaybeBoard.sq_[moveto_rank][4].piece_=5; MaybeBoard.sq_[moveto_rank][1].side_=0; MaybeBoard.sq_[moveto_rank][1].piece_=0; } if(moveto_file==13) { ShowStatusQ("Castling King Side"); NowBoard.sq_[moveto_rank][12].side_=NowBoard.sq_[mover_rank][mover_file].side_; NowBoard.sq_[moveto_rank][12].piece_=5; NowBoard.sq_[moveto_rank][15].side_=0; NowBoard.sq_[moveto_rank][15].piece_=0; NowBoard.sq_[moveto_rank][12].drawchsq(g, 1, false); NowBoard.sq_[moveto_rank][15].drawchsq(g, 1, false); MaybeBoard.sq_[moveto_rank][12].side_=NowBoard.sq_[mover_rank][mover_file].side_; MaybeBoard.sq_[moveto_rank][12].piece_=5; MaybeBoard.sq_[moveto_rank][15].side_=0; MaybeBoard.sq_[moveto_rank][15].piece_=0; } if(moveto_file==9) { ShowStatusQ("Castling Queen Side"); NowBoard.sq_[moveto_rank][10].side_=NowBoard.sq_[mover_rank][mover_file].side_; NowBoard.sq_[moveto_rank][10].piece_=5; NowBoard.sq_[moveto_rank][8].side_=0; NowBoard.sq_[moveto_rank][8].piece_=0; NowBoard.sq_[moveto_rank][10].drawchsq(g, 1, false); NowBoard.sq_[moveto_rank][8].drawchsq(g, 1, false); MaybeBoard.sq_[moveto_rank][10].side_=NowBoard.sq_[mover_rank][mover_file].side_; MaybeBoard.sq_[moveto_rank][10].piece_=5; MaybeBoard.sq_[moveto_rank][8].side_=0; MaybeBoard.sq_[moveto_rank][8].piece_=0; } NowBoard.sq_[moveto_rank][moveto_file].piece_++; } } public void CountAllThePieces() { //System.out.println("EasyChss.CountAllThePieces"); undef_enemy_pawn_most_advanced_file[1]=0; undef_enemy_pawn_most_advanced_file[2]=0; undef_enemy_pawn_most_advanced_rank[1]=0; undef_enemy_pawn_most_advanced_rank[2]=0; undef_enemy_pawn_nearest_king_file[1]=0; undef_enemy_pawn_nearest_king_file[2]=0; undef_enemy_pawn_nearest_king_rank[1]=0; undef_enemy_pawn_nearest_king_rank[2]=0; distance_to_edible_pawn[1]=200; distance_to_edible_pawn[2]=200; for(xxx=1; xxx<16; xxx++) for(yyy=1; yyy<9; yyy++) if(NowBoard.sq_[yyy][xxx].pawn()) { pawnowner=NowBoard.sq_[yyy][xxx].side_; if(Attackers[yyy][xxx][pawnowner]==0) { if((pawnowner==1) & ((undef_enemy_pawn_most_advanced_rank[2]==0) | (yyy>undef_enemy_pawn_most_advanced_rank[2]))) { undef_enemy_pawn_most_advanced_rank[2]=yyy; undef_enemy_pawn_most_advanced_file[2]=xxx; } if((pawnowner==2) & ((undef_enemy_pawn_most_advanced_rank[1]==0) | (yyy(KingRank[3 - pawnowner] - yyy) * (KingRank[3 - pawnowner] - yyy) + (KingFile[3 - pawnowner] - xxx) * (KingFile[3 - pawnowner] - xxx)) { undef_enemy_pawn_nearest_king_rank[3 - pawnowner]=yyy; undef_enemy_pawn_nearest_king_file[3 - pawnowner]=xxx; } } } ZeroAllFiveCounts(); for(xxx=1; xxx<16; xxx++) for(yyy=1; yyy<9; 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 9: // '\t' 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 DesignateTheGoodMoves(Chsq chsq) { //System.out.println("EasyChss.DesignateTheGoodMoves"); if((whoseMove !=chsq.side_) | skipDtGM | (depth>1)) return; IncrediblyGoodMove(chsq); /*whazzis*/ 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(); } if((WeakestAttacker[d[depth]][c[depth]][3-chsq.side_]>=chsq.m_strength())&(AmIUnderAttack(d[depth],c[depth],whoseMove)==false)&(NowBoard.sq_[d[depth]][c[depth]].m_strength()>3) && Math.random() * 100D<169D) AssignGoodMove9(); /*take much stronger unit*/ if(NowBoard.sq_[d[depth]][c[depth]].m_strength()>1 + chsq.m_strength() && Math.random() * 100D<168D) AssignGoodMove9(); /*same*/ if(NowBoard.sq_[d[depth]][c[depth]].m_strength()>2 + chsq.m_strength()) AssignGoodMove9(); /*q retreats*/ if((chsq.m_strength()>3) & (Attackers[chsq.rank_][chsq.file_][3 - chsq.side_]>0) & (AmIUnderAttack(d[depth],c[depth],whoseMove)==false) && Math.random() * 100D<168D) {AssignGoodMove8();if (NowBoard.sq_[d[depth]][c[depth]].piece_!=0){AssignGoodMove9();}} /*take undefended q*/ if((AmIUnderAttack(d[depth],c[depth],whoseMove)==false) & (NowBoard.sq_[d[depth]][c[depth]].m_strength()>3) && Math.random() * 100D<168D) AssignGoodMove7(); /*minor piece takes queen*/ if((chsq.m_strength()<3) & (NowBoard.sq_[d[depth]][c[depth]].m_strength()>3) && Math.random() * 100D<168D) AssignGoodMove6(); /*rook or better retreats*/ if((chsq.m_strength()>2) & (Attackers[chsq.rank_][chsq.file_][3 - chsq.side_]>0) & (AmIUnderAttack(d[depth],c[depth],whoseMove)==false) && Math.random() * 100D<168D) AssignGoodMove5(); /*he queens*/ if((chsq.piece_==1) & ((d[depth]==1) & (chsq.side_==2) | (d[depth]==8) & (chsq.side_==1)) & (AmIUnderAttack(d[depth],c[depth],whoseMove)==false) && Math.random() * 100D<168D) AssignGoodMove5(); /*take undefended unit*/ if((AmIUnderAttack(d[depth],c[depth],whoseMove)==false) & (NowBoard.sq_[d[depth]][c[depth]].m_strength()>1) && Math.random() * 100D<168D) AssignGoodMove4(); /*take stronger unit*/ if(chsq.m_strength()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<168D) ) { switch(chsq.m_strength()){ case 5:{AssignGoodMove9();break;} case 4:{AssignGoodMove7();break;} case 3:{AssignGoodMove5();break;} case 2:{AssignGoodMove3();break;} case 1:{AssignGoodMove2();break;} } } /*take me under attack to a better-defended square*/ if((WeakestAttacker[d[depth]][c[depth]][3-chsq.side_]>=chsq.m_strength())&(Attackers[d[depth]][c[depth]][3-chsq.side_]term_counts[3-chsq.side_])&(chsq.m_strength()<=NowBoard.sq_[d[depth]][c[depth]].m_strength())) { switch(chsq.m_strength()){ case 5:{AssignGoodMove9();break;} case 4:{AssignGoodMove8();break;} case 3:{AssignGoodMove6();break;} case 2:{AssignGoodMove4();break;} case 1:{AssignGoodMove1();break;} } } MoreGoodMoves(chsq); NightMoves(chsq); if(IsMySideInCheck(3 - chsq.side_) && !IGaveEscapableCheck(chsq.side_)) goodmove10=moveCounter; } public void DidICheckOrStalemate(Graphics g, int i) { //System.out.println("EasyChss.DidICheckOrStalemate"); CountAllThePieces();if(AnotherWayToEndGame(g, i)) { GameOver=true; return; } if(GameOver) return; moveCounter=0; for(xx=1; (xx<16) & (moveCounter==0); xx++) for(yy=1; (yy<9) & (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) { ShowStatusQ("Checkmate!"); DrawNowBoard(g); GameOver=true;KnightRiderBouncy(g); wins[i]=wins[i] + 1; return; } else { ShowStatusQ("Check!"); IHaveBeenInCheck[3-i]=true; return; } if(moveCounter==0) { ShowStatusQ("Stalemate!"); GameOver=true; drawn_games++; return; } else { return; } } public void AmICheckedOrStalemated(Graphics g, int i) { //System.out.println("EasyChss.AmICheckedOrStalemated"); DidICheckOrStalemate(g,3-i);} public boolean DoesArchiveMatchNowBoard() { //System.out.println("EasyChss.DoesArchiveMatchNowBoard"); if(whoseMove !=ArchiveBoard[xxx].sq_[0][0].side_) return false; for(ff=1; ff<9; ff++) for(ee=1; ee<16; 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) { //System.out.println("EasyChss.DrawMaybeBoard"); for(ee=1; ee<16; ee++) for(ff=1; ff<9; ff++) MaybeBoard.sq_[ff][ee].drawchsq2(g, 1); } public void DrawNowBoard(Graphics g) { //System.out.println("EasyChss.DrawNowBoard"); for(ee=1; ee<16; ee++) for(ff=1; ff<9; ff++) { NowBoard.sq_[ff][ee].drawchsq(g, 1, icanmove[ff][ee]); } } public void DrawPromotionOptions(Graphics g) { //System.out.println("EasyChss.DrawPromotionOptions"); g.setColor(niceblue); g.fillRect(0, 271, 300, 94); g.setColor(Color.black); g.setFont(f2); g.drawString("Choose: ", 5, 320); happySquare.side_=whoseMove; happySquare.rank_=-1; happySquare.file_=3; happySquare.piece_=9; if (QueenCount[whoseMove]<2){happySquare.drawchsq(g, 11, false);} happySquare.file_=4; happySquare.piece_=5; if (RookCount[whoseMove]<3){happySquare.drawchsq(g, 11, false);} happySquare.file_=5; happySquare.piece_=4; if (BishopCount[whoseMove]<4){happySquare.drawchsq(g, 11, false);} happySquare.file_=6; happySquare.piece_=3; if (KnightCount[whoseMove]<4){happySquare.drawchsq(g, 11, false);} } public void ForGambler(Graphics g) { } public void GenerateAttackersArrays() { //System.out.println("EasyChss.GenerateAttackersArrays"); for(zatt=1; zatt<3; zatt++) for(yatt=1; yatt<9; yatt++) for(xatt=1; xatt<16; 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<16; xatt++) { satt=NowBoard.sq_[yatt][xatt].side_; patt=NowBoard.sq_[yatt][xatt].piece_; SupplementalAddAnAttacker(); if((patt==5) | (patt==2205) | (patt==6) | (patt==105) | (patt==109) | (patt==163) | (patt==165) | (patt==9) | (patt==-3) | (patt==2209) | (patt==-9) | (patt==-67) | (patt==-68) | (patt==57) | (patt==29) | (patt==28)) { catt=xatt; datt=yatt; for(; catt<16; 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==2204) | (patt==9) | (patt==-3) | (patt==2209) | (patt==-9) | (patt==-67) | (patt==-68) | (patt==21) | (patt==28) | (patt==104) | (patt==109) | (patt==161) | (patt==166)) { catt=xatt; for(datt=yatt; (catt<16) & (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<16) & (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) | (patt==-3) | (patt==-67) | (patt==-68) | (patt==2203) | (patt==103) | (patt==-4) | (patt==-5) | (patt==21) | (patt==28) | (patt==29) | (patt==57) | (patt==193) | (patt==162) | (patt==164)) { 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 + 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(); } } } } public void GenerateCLCAttackersArrays(boolean flag, boolean flag1) { //System.out.println("EasyChss.GenerateCLCAttackersArrays"); for(zatt=1; zatt<3; zatt++) for(yatt=1; yatt<9; yatt++) for(xatt=1; xatt<16; xatt++) CLCAttackers[yatt][xatt][zatt]=0; for(yatt=1; yatt<9; yatt++) for(xatt=1; xatt<16; xatt++) { satt=MaybeBoard.sq_[yatt][xatt].side_; patt=MaybeBoard.sq_[yatt][xatt].piece_; SupplementalAddACLCAttacker(); if((patt==5) | (patt==2205) | (patt==6) | (patt==105) | (patt==109) | (patt==163) | (patt==165) | (patt==9) | (patt==-3) | (patt==2209) | (patt==-9) | (patt==-67) | (patt==-68) | (patt==57) | (patt==29) | (patt==28)) { catt=xatt; datt=yatt; for(; catt<16; catt++) { AddACLCAttacker(); if((catt !=xatt) & (MaybeBoard.sq_[datt][catt].side_ !=0)) catt=20; } catt=xatt; datt=yatt; for(; catt>0; catt--) { AddACLCAttacker(); if((catt !=xatt) & (MaybeBoard.sq_[datt][catt].side_ !=0)) catt=-20; } catt=xatt; for(datt=yatt; datt<9; datt++) { AddACLCAttacker(); if((datt !=yatt) & (MaybeBoard.sq_[datt][catt].side_ !=0)) datt=20; } catt=xatt; for(datt=yatt; datt>0; datt--) { AddACLCAttacker(); if((datt !=yatt) & (MaybeBoard.sq_[datt][catt].side_ !=0)) datt=-20; } } if((patt==4) | (patt==2204) | (patt==9) | (patt==-3) | (patt==2209) | (patt==-9) | (patt==-67) | (patt==-68) | (patt==21) | (patt==28) | (patt==104) | (patt==109) | (patt==161) | (patt==166)) { catt=xatt; for(datt=yatt; (catt<16) & (datt<9); datt++) { AddACLCAttacker(); if((catt !=xatt) & (MaybeBoard.sq_[datt][catt].side_ !=0)) catt=20; catt++; } catt=xatt; for(datt=yatt; (catt>0) & (datt<9); datt++) { AddACLCAttacker(); if((catt !=xatt) & (MaybeBoard.sq_[datt][catt].side_ !=0)) catt=-20; catt--; } catt=xatt; for(datt=yatt; (catt<16) & (datt>0); catt++) { AddACLCAttacker(); if((datt !=yatt) & (MaybeBoard.sq_[datt][catt].side_ !=0)) catt=20; datt--; } catt=xatt; for(datt=yatt; (catt>0) & (datt>0); catt--) { AddACLCAttacker(); if((datt !=yatt) & (MaybeBoard.sq_[datt][catt].side_ !=0)) catt=-20; datt--; } } if((patt==60) | (patt==260) | (patt==224)) { catt=xatt + 2; datt=yatt + 2; AddACLCAttacker(); catt=xatt + 2; datt=yatt - 2; AddACLCAttacker(); catt=xatt - 2; datt=yatt + 2; AddACLCAttacker(); catt=xatt - 2; datt=yatt - 2; AddACLCAttacker(); } if((patt==3) | (patt==-3) | (patt==-67) | (patt==-68) | (patt==2203) | (patt==103) | (patt==-4) | (patt==-5) | (patt==21) | (patt==28) | (patt==29) | (patt==57) | (patt==193) | (patt==162) | (patt==164)) { catt=xatt + 1; datt=yatt + 2; AddACLCAttacker(); catt=xatt + 1; datt=yatt - 2; AddACLCAttacker(); catt=xatt - 1; datt=yatt + 2; AddACLCAttacker(); catt=xatt - 1; datt=yatt - 2; AddACLCAttacker(); catt=xatt + 2; datt=yatt + 1; AddACLCAttacker(); catt=xatt + 2; datt=yatt - 1; AddACLCAttacker(); catt=xatt - 2; datt=yatt + 1; AddACLCAttacker(); catt=xatt - 2; datt=yatt - 1; AddACLCAttacker(); } if(flag1 & (patt<0) | (patt==25)) { catt=xatt + 1; datt=yatt + 1; AddACLCAttacker(); catt=xatt + 1; datt=yatt - 1; AddACLCAttacker(); catt=xatt - 1; datt=yatt + 1; AddACLCAttacker(); catt=xatt - 1; datt=yatt - 1; AddACLCAttacker(); catt=xatt; datt=yatt + 1; AddACLCAttacker(); catt=xatt; datt=yatt - 1; AddACLCAttacker(); catt=xatt + 1; datt=yatt; AddACLCAttacker(); catt=xatt - 1; datt=yatt; AddACLCAttacker(); } if((patt==1) | (patt==2)) { if(satt==1) if(flag) { datt=yatt + 1; catt=xatt + 1; AddACLCAttacker(); datt=yatt + 1; catt=xatt - 1; AddACLCAttacker(); } else if(yatt<8 && MaybeBoard.sq_[yatt + 1][xatt].piece_==0) { datt=yatt + 1; catt=xatt; AddACLCAttacker(); if((MaybeBoard.sq_[yatt + 1][xatt].piece_==0) & (MaybeBoard.sq_[yatt + 2][xatt].piece_==0) & (satt==1) & (yatt==2)) { datt=4; catt=xatt; AddACLCAttacker(); } } if(satt==2) if(flag) { datt=yatt - 1; catt=xatt + 1; AddACLCAttacker(); datt=yatt - 1; catt=xatt - 1; AddACLCAttacker(); } else if(yatt>1 && MaybeBoard.sq_[yatt - 1][xatt].piece_==0) { datt=yatt - 1; catt=xatt; AddACLCAttacker(); if((MaybeBoard.sq_[yatt - 1][xatt].piece_==0) & (MaybeBoard.sq_[yatt - 2][xatt].piece_==0) & (satt==2) & (yatt==7)) { datt=5; catt=xatt; AddACLCAttacker(); } } } } } public void HappyFiftyMoveRule() { //System.out.println("EasyChss.HappyFiftyMoveRule"); if((NowBoard.sq_[moveto_rank][moveto_file].piece_>0) | (NowBoard.sq_[mover_rank][mover_file].piece_==1)) { fifty_move_rule=0; return; } fifty_move_rule++; if((fifty_move_rule>fifties_got_to) & (fifty_move_rule<102)) fifties_got_to=fifty_move_rule; } public boolean HumanMoveAPiece(Graphics g, int i, int j) { //System.out.println("EasyChss.HumanMoveAPiece"); if((mover_rank==i) & (mover_file==j)) { markingAPiece=true; DrawNowBoard(g); return false; } if(!IsMyMoveListed()) { return false; } else { moveto_rank=i; moveto_file=j; TotalBackBoard(); who_backed=whoseMove; NormalMove(g); TotalMaybeBoard(NowBoard,MaybeBoard);DidICheckOrStalemate(g, whoseMove); markingAPiece=true; DrawNowBoard(g); TotalMaybeBoard(NowBoard, MaybeBoard); return true; } } public boolean IGaveEscapableCheck(int i) { //System.out.println("EasyChss.IGaveEscapableCheck"); if(i>2) return false; if(!IsMySideInCheck(3 - i)) return false; GenerateCLCAttackersArrays(true, true); cee=KingFile[3 - i]; dee=KingRank[3 - i] + 1; if(KingCanEscape(3 - i)) {return true;} cee=KingFile[3 - i] + 1; dee=KingRank[3 - i] + 1; if(KingCanEscape(3 - i)) {return true;} cee=KingFile[3 - i] + 1; dee=KingRank[3 - i]; if(KingCanEscape(3 - i)) {return true;} cee=KingFile[3 - i] + 1; dee=KingRank[3 - i] - 1; if(KingCanEscape(3 - i)) {return true;} cee=KingFile[3 - i]; dee=KingRank[3 - i] - 1; if(KingCanEscape(3 - i)) {return true;} cee=KingFile[3 - i] - 1; dee=KingRank[3 - i] - 1; if(KingCanEscape(3 - i)) {return true;} cee=KingFile[3 - i] - 1; dee=KingRank[3 - i]; if(KingCanEscape(3 - i)) {return true;} cee=KingFile[3 - i] - 1; dee=KingRank[3 - i] + 1; if(KingCanEscape(3 - i)) {return true;} if(CLCAttackers[KingRank[3 - i]][KingFile[3 - i]][i]>1) return false; GenerateCLCAttackersArrays(true, false); if(CLCAttackers[assailant_rank][assailant_file][3 - i]>0) {return true;} if((assailant_file - KingFile[3 - i]) * (assailant_file - KingFile[3 - i]) + (assailant_rank - KingRank[3 - i]) * (assailant_rank - KingRank[3 - i])==5) return false; GenerateCLCAttackersArrays(false, false); if(assailant_fileKingFile[3 - i]) xee=-1; if(assailant_rankKingRank[3 - i]) yee=-1; cee=assailant_file; dee=assailant_rank; if((cee<1)|(dee<1)|(cee>15)|(dee>8)) {return true;} while((cee !=KingFile[3 - i]) | (dee !=KingRank[3 - i])) { if(CLCAttackers[dee][cee][3 - i]>0) {return true;} cee +=xee; dee +=yee; if((cee<1) | (cee>15) | (dee<1) | (dee>8)) { //System.out.println("Error in IGaveEscapableCheck"); return true; } } return false; } public void IncrediblyGoodMove(Chsq chsq) { } public boolean IsEnemyBishop(int i, int j) { //System.out.println("EasyChss.IsEnemyBishop"); if((j>15) | (j<1) | (i>8) | (i<1)) return false; if(MaybeBoard.sq_[i][j].piece_==4) { if(assailant_rank !=0) { assailant2_rank=assailant_rank; assailant2_file=assailant_file; } assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==9) { if(assailant_rank !=0) { assailant2_rank=assailant_rank; assailant2_file=assailant_file; } assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyKing(int i, int j, int k) { //System.out.println("EasyChss.IsEnemyKing"); if((j>15) | (j<1) | (i>8) | (i<1)) return false; if(MaybeBoard.sq_[i][j].side_==k) return false; if(MaybeBoard.sq_[i][j].piece_==-1) { if(assailant_rank !=0) { assailant2_rank=assailant_rank; assailant2_file=assailant_file; } assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==-2) { if(assailant_rank !=0) { assailant2_rank=assailant_rank; assailant2_file=assailant_file; } assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyKnight(int i, int j, int k) { //System.out.println("EasyChss.IsEnemyKnight"); if((j>15) | (j<1) | (i>8) | (i<1)) return false; if(MaybeBoard.sq_[i][j].side_==k) return false; if(MaybeBoard.sq_[i][j].piece_==3) { if(assailant_rank !=0) { assailant2_rank=assailant_rank; assailant2_file=assailant_file; } assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyPawn(int i, int j, int k) { //System.out.println("EasyChss.IsEnemyPawn"); if((j>15) | (j<1) | (i>8) | (i<1)) return false; if(MaybeBoard.sq_[i][j].side_==k) return false; if(MaybeBoard.sq_[i][j].piece_==1) { if(assailant_rank !=0) { assailant2_rank=assailant_rank; assailant2_file=assailant_file; } assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==2) { if(assailant_rank !=0) { assailant2_rank=assailant_rank; assailant2_file=assailant_file; } assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsEnemyRook(int i, int j) { //System.out.println("EasyChss.IsEnemyRook"); if((j>15) | (j<1) | (i>8) | (i<1)) return false; if(MaybeBoard.sq_[i][j].piece_==5) { if(assailant_rank !=0) { assailant2_rank=assailant_rank; assailant2_file=assailant_file; } assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==6) { if(assailant_rank !=0) { assailant2_rank=assailant_rank; assailant2_file=assailant_file; } assailant_rank=i; assailant_file=j; return true; } if(MaybeBoard.sq_[i][j].piece_==9) { if(assailant_rank !=0) { assailant2_rank=assailant_rank; assailant2_file=assailant_file; } assailant_rank=i; assailant_file=j; return true; } else { return false; } } public boolean IsMyMoveListed() { //System.out.println("EasyChss.IsMyMoveListed"); for(x=1; x<=moveCounter; x++) if((MaybeMoves[x].endingsquare_.rank_==b) & (MaybeMoves[x].endingsquare_.file_==a)) return true; return false; } public boolean IsMySideInCheck(int i) { if (KingCount[i]==2){return false;} //System.out.println("EasyChss.IsMySideInCheck"); whichkingisworried=i; if(AnotherWayToCheck(i)) return true; for(xxx=1; xxx<16; 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() { //System.out.println("EasyChss.IsTheGameOver"); if(GameOver) return true; CountAllThePieces(); if((QueenCount[1]==0) & (QueenCount[2]==0) & (RookCount[1]==0) & (RookCount[2]==0) & (PawnCount[1]==0) & (PawnCount[2]==0)) { if((BishopCount[1]==0) & (BishopCount[2]==0) & (KnightCount[1]<3) & (KnightCount[2]<3)) { GameOver=true; drawn_games++; ShowStatusQ("Lack of force"); return true; } if((BishopCount[1]<2) & (BishopCount[2]<2) & (KnightCount[1]==0) & (KnightCount[2]==0)) { GameOver=true; drawn_games++; ShowStatusQ("Lack of force"); return true; } if((BishopCount[1] + KnightCount[1]<2) & (BishopCount[2] + KnightCount[2]<2)) { GameOver=true; drawn_games++; ShowStatusQ("Lack of force"); return true; } } return false; } public boolean KingCanEscape(int i) { //System.out.println("EasyChss.KingCanEscape"); if(cee>15) return false; if(cee<1) return false; if(dee>8) return false; if(dee<1) return false; if(MaybeBoard.sq_[dee][cee].side_==i) return false; if ((KingRank[i]-assailant_rank)*(cee-assailant_file)==(dee-assailant_rank)*(KingFile[i]-assailant_file)) { if ((assailant_rank!=dee)|(assailant_file!=cee))if (MaybeBoard.sq_[assailant_rank][assailant_file].piece_>2){return false;} } if (assailant2_rank>0) { if ((KingRank[i]-assailant2_rank)*(cee-assailant2_file)==(dee-assailant2_rank)*(KingFile[i]-assailant2_file)) { if ((assailant2_rank!=dee)|(assailant2_file!=cee))if (MaybeBoard.sq_[assailant2_rank][assailant2_file].piece_>2){return false;} } } return CLCAttackers[dee][cee][3 - i]<=0; } public void LowRectangle(Graphics g) { //System.out.println("EasyChss.LowRectangle"); g.setColor(niceblue); g.fillRect(0, 271, 300, 94); 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 void MachineMoveExtra(Graphics g, int i) { } public boolean MachineMoves(Graphics g, int i) { //System.out.println("EasyChss.MachineMoves"); if(GameOver) return true; //System.out.print("1"); NegateGMCounts();goodmove1=0; goodmove2=0; goodmove3=0; goodmove4=0; goodmove5=0; goodmove6=0; goodmove7=0; goodmove8=0; goodmove9=0; goodmove10=0; moveCounter=0; depth=1; //System.out.print("2"); for(xx=1; xx<16; xx++) for(yy=1; yy<9; yy++) if(NowBoard.sq_[yy][xx].side_==i) findPieceMoves(g, NowBoard.sq_[yy][xx], NowBoard, MaybeBoard); //System.out.print("["+goodmove4+"]["+MaybeMoves[goodmove4].startingsquare_.file_+""+MaybeMoves[goodmove4].startingsquare_.rank_+""+MaybeMoves[goodmove4].endingsquare_.file_+""+MaybeMoves[goodmove4].endingsquare_.rank_+"]"); //System.out.print("3"); depth=0; ShowStatusNothing(); if(moveCounter==0) { System.out.println("No Moves");WhoIsHuman[1]=true;WhoIsHuman[2]=true;ShowStatusQ("No Moves"); return false; } //System.out.print("4"); 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;/*System.out.print("A");*/} if(goodmove2>0) {x=goodmove2;/*System.out.print("B");*/} if(goodmove3>0) {x=goodmove3;/*System.out.print("C");*/} if(goodmove4>0) {x=goodmove4;/*System.out.print("D");*/} if(goodmove5>0) {x=goodmove5;/*System.out.print("E");*/} if(goodmove6>0) {x=goodmove6;/*System.out.print("F");*/} if(goodmove7>0) {x=goodmove7;/*System.out.print("G");*/} if(goodmove8>0) {x=goodmove8;/*System.out.print("H");*/} if(goodmove9>0) {x=goodmove9;/*System.out.print("I");*/} if(goodmove10>0) {x=goodmove10;/*System.out.print("J");*/} //System.out.print("5"); moveto_file=MaybeMoves[x].endingsquare_.file_; moveto_rank=MaybeMoves[x].endingsquare_.rank_; mover_file=MaybeMoves[x].startingsquare_.file_; mover_rank=MaybeMoves[x].startingsquare_.rank_; //System.out.print("6"); RedCastleCheat(); NormalMove(g); NowBoard.sq_[mover_rank][mover_file].drawchsq(g, 1, false); NowBoard.sq_[moveto_rank][moveto_file].drawchsq(g, 1, 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_; //System.out.print("7"); TotalMaybeBoard(NowBoard,MaybeBoard);DidICheckOrStalemate(g, i); if(GameOver) return true; //System.out.print("8"); if(fifty_move_rule>100) { fifty_move_rule=0; DrawNowBoard(g);ShowStatusQ("Fifty move rule!"); drawn_games++; GameOver=true; return false; } else { MachineMoveExtra(g, i); return true; } } public boolean MaybeAdd(Graphics g, Chsq chsq, CB10_17 cb10_17, CB10_17 cb10_17_1) { //System.out.println("EasyChss.MaybeAdd"); CheckSquare[depth]=false; SquatterOnCheckSquare[depth]=false; if((c[depth]<1) | (c[depth]>15) | (d[depth]<1) | (d[depth]>8)) return false; if(!PassedOtherRequirementsToKeep(chsq, cb10_17, cb10_17_1)) return false; if(cb10_17.sq_[d[depth]][c[depth]].side_==chsq.side_) return false; alterMaybeBoard(g, chsq, cb10_17.sq_[d[depth]][c[depth]], cb10_17, cb10_17_1); if(IsMySideInCheck(chsq.side_)) { unalterMaybeBoard(g, chsq, cb10_17.sq_[d[depth]][c[depth]], cb10_17, cb10_17_1); CheckSquare[depth]=true; if(cb10_17.sq_[d[depth]][c[depth]].piece_ !=0) SquatterOnCheckSquare[depth]=true; return false; } // if ((d[depth]==4)&(c[depth]==8)){System.out.print(" "+Attackers[d[depth]][c[depth]][3-chsq.side_]+"."+WeakestAttacker[d[depth]][c[depth]][3-chsq.side_]+"."+chsq.m_strength()+"."+how_deep_to_seek+"."+moveCounter+"."+chsq.side_+"."+whoseMove);} if ((how_deep_to_seek<4)&(seek_sacrificial_wins==false)&(WhoIsHuman[whoseMove]==false)&(moveCounter>0)&(chsq.side_==whoseMove)) { // System.out.print("!"); if ((Attackers[d[depth]][c[depth]][3-chsq.side_]>0)&(chsq.m_strength()>NowBoard.sq_[d[depth]][c[depth]].m_strength())& ( (WeakestAttacker[d[depth]][c[depth]][3-chsq.side_]Attackers[d[depth]][c[depth]][chsq.side_]-1) ) &(IsMySideInCheck(3-chsq.side_)==false) /// HEEEERE &(WinsAnotherWay(chsq)==false) ) { // SquatterOnCheckSquare[depth]=true; // System.out.print("*"); SquatterOnCheckSquare[depth]=false; if(cb10_17.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_17.sq_[d[depth]][c[depth]], cb10_17, cb10_17_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)&(KingCount[whoseMove]==1)&(skipDtGM==false)&(depth<2)&(NowBoard.sq_[d[depth]][c[depth]].piece_<0)){goodmove10=moveCounter;System.out.println("King captured"+chsq.piece_+""+chsq.file_+""+chsq.rank_+""+c[depth]+""+d[depth]);WhoIsHuman[1]=true;WhoIsHuman[2]=true;} MaybeMoves[moveCounter].startingsquare_.rank_=chsq.rank_; MaybeMoves[moveCounter].startingsquare_.file_=chsq.file_; MaybeMoves[moveCounter].endingsquare_.rank_=cb10_17.sq_[d[depth]][c[depth]].rank_; MaybeMoves[moveCounter].endingsquare_.file_=cb10_17.sq_[d[depth]][c[depth]].file_; } DesignateTheGoodMoves(chsq); unalterMaybeBoard(g, chsq, cb10_17.sq_[d[depth]][c[depth]], cb10_17, cb10_17_1); return cb10_17.sq_[d[depth]][c[depth]].side_==0; } public void MaybeCastleKingsideA(Graphics g, int i) { //System.out.println("EasyChss.MaybeCastleKingside"); if(depth>1) {return;} if(AnotherReasonNotToCastleKingside(i)) {return;} if(i==1) { if(NowBoard.sq_[1][8].piece_ !=6) return; if(NowBoard.sq_[1][7].piece_ !=0) return; if(NowBoard.sq_[1][6].piece_ !=0) return; if (KingCount[i]<2){ if(AmIUnderAttack(1, 5, 1)) return; if(AmIUnderAttack(1, 6, 1)) return; if(AmIUnderAttack(1, 7, 1)) return;} d[depth]=1; c[depth]=7; MaybeAdd(g, NowBoard.sq_[1][5], NowBoard, MaybeBoard); } if(i==2) { if(NowBoard.sq_[8][8].piece_ !=6) return; if(NowBoard.sq_[8][7].piece_ !=0) return; if(NowBoard.sq_[8][6].piece_ !=0) return; if (KingCount[i]<2){ if(AmIUnderAttack(8, 5, 2)) return; if(AmIUnderAttack(8, 6, 2)) return; if(AmIUnderAttack(8, 7, 2)) return;} d[depth]=8; c[depth]=7; MaybeAdd(g, NowBoard.sq_[8][5], NowBoard, MaybeBoard); } } public void MaybeCastleQueensideA(Graphics g, int i) { //System.out.println("EasyChss.MaybeCastleQueenside"); if(depth>1) return; if(AnotherReasonNotToCastleQueenside(i)) return; if(i==1) { if((NowBoard.sq_[1][1].piece_ !=6) & (NowBoard.sq_[1][1].piece_ !=57)) return; if(NowBoard.sq_[1][2].piece_ !=0) return; if(NowBoard.sq_[1][3].piece_ !=0) return; if(NowBoard.sq_[1][4].piece_ !=0) return; if (KingCount[i]<2){ if(AmIUnderAttack(1, 5, 1)) return; if(AmIUnderAttack(1, 4, 1)) return; if(AmIUnderAttack(1, 3, 1)) return;} d[depth]=1; c[depth]=3; MaybeAdd(g, NowBoard.sq_[1][5], NowBoard, MaybeBoard); } if(i==2) { if((NowBoard.sq_[8][1].piece_ !=6) & (NowBoard.sq_[8][1].piece_ !=28)) return; if(NowBoard.sq_[8][2].piece_ !=0) return; if(NowBoard.sq_[8][3].piece_ !=0) return; if(NowBoard.sq_[8][4].piece_ !=0) return; if (KingCount[i]<2){ if(AmIUnderAttack(8, 5, 2)) return; if(AmIUnderAttack(8, 4, 2)) return; if(AmIUnderAttack(8, 3, 2)) return;} d[depth]=8; c[depth]=3; MaybeAdd(g, NowBoard.sq_[8][5], NowBoard, MaybeBoard); } } public void MaybeCastleKingsideB(Graphics g, int i) { //System.out.println("EasyChss.MaybeCastleKingside"); if(depth>1) {return;} if(AnotherReasonNotToCastleKingside(i)) {return;} if(i==1) { if(NowBoard.sq_[1][15].piece_ !=6) return; if(NowBoard.sq_[1][14].piece_ !=0) return; if(NowBoard.sq_[1][13].piece_ !=0) return; if(NowBoard.sq_[1][12].piece_ !=0) return; if (KingCount[i]<2){ if(AmIUnderAttack(1, 12, 1)) return; if(AmIUnderAttack(1, 13, 1)) return; if(AmIUnderAttack(1, 14, 1)) return;} d[depth]=1; c[depth]=13; MaybeAdd(g, NowBoard.sq_[1][11], NowBoard, MaybeBoard); } if(i==2) { if(NowBoard.sq_[8][15].piece_ !=6) return; if(NowBoard.sq_[8][14].piece_ !=0) return; if(NowBoard.sq_[8][13].piece_ !=0) return; if(NowBoard.sq_[8][12].piece_ !=0) return; if (KingCount[i]<2){ if(AmIUnderAttack(8, 12, 2)) return; if(AmIUnderAttack(8, 13, 2)) return; if(AmIUnderAttack(8, 14, 2)) return;} d[depth]=8; c[depth]=13; MaybeAdd(g, NowBoard.sq_[8][11], NowBoard, MaybeBoard); } } public void MaybeCastleQueensideB(Graphics g, int i) { //System.out.println("EasyChss.MaybeCastleQueenside"); if(depth>1) return; if(AnotherReasonNotToCastleQueenside(i)) return; if(i==1) { if (NowBoard.sq_[1][8].piece_ !=6) return; if(NowBoard.sq_[1][9].piece_ !=0) return; if(NowBoard.sq_[1][10].piece_ !=0) return; if (KingCount[i]<2){ if(AmIUnderAttack(1, 11, 1)) return; if(AmIUnderAttack(1, 10, 1)) return; if(AmIUnderAttack(1, 9, 1)) return;} d[depth]=1; c[depth]=9; MaybeAdd(g, NowBoard.sq_[1][11], NowBoard, MaybeBoard); } if(i==2) { if (NowBoard.sq_[8][8].piece_ !=6) return; if(NowBoard.sq_[8][9].piece_ !=0) return; if(NowBoard.sq_[8][10].piece_ !=0) return; if (KingCount[i]<2){ if(AmIUnderAttack(8, 9, 2)) return; if(AmIUnderAttack(8, 10, 2)) return; if(AmIUnderAttack(8, 11, 2)) return;} d[depth]=8; c[depth]=9; MaybeAdd(g, NowBoard.sq_[8][11], NowBoard, MaybeBoard); } } public void MoreGoodMoves(Chsq chsq) { } public void AssignVariantName(){ //System.out.println("EasyChss.AssignVariantName"); variant_name="Millennium Chess"; } public void NameThisChessVariant(Graphics g) { //System.out.println("EasyChss.NameThisChessVariant"); 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 KnightRiderBouncy(Graphics g){} public void NextOrdinaryPlayer(Graphics g) { //System.out.println(""+NowBoard.sq_[moveto_rank][moveto_file].piece_+""+mover_file+""+mover_rank+""+moveto_file+""+moveto_rank); //System.out.println("EasyChss.NextOrdinaryPlayer"); IsTheGameOver(); if(GameOver) {KnightRiderBouncy(g);return;} failsafe(g); whoseMove=3 - whoseMove; UnTwoThePawns(whoseMove); if(whoseMove==1) turncounter++; if (WhoIsHuman[whoseMove]==true){SayWhoIsHuman(g);} whatpiecescanmove(g); TotalMaybeBoard(NowBoard, MaybeBoard); GenerateAttackersArrays(); CountAllThePieces(); DrawNowBoard(g); } public void NightMoves(Chsq chsq) { //System.out.println("EasyChss.NightMoves"); if ((goodmove1>0)|(goodmove2>0)|(goodmove3>0)|(goodmove4>0)|(goodmove5>0)|(goodmove6>0)|(goodmove7>0)|(goodmove8>0)|(goodmove9>0)|(goodmove10>0)){return;} if (worried==true){return;} if (chsq.side_!=whoseMove){return;} if(chsq.piece_==9 && (KingRank[3 - chsq.side_]==1) | (KingRank[3 - chsq.side_]==8) && (KingFile[3 - chsq.side_]==1) | (KingFile[3 - chsq.side_]==8) && (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<168D) AssignGoodMove8(); if(forked_rookage>1 && Math.random() * 100D<168D) AssignGoodMove5(); } if((chsq.piece_==1) | (chsq.piece_==2)) { pawnforks(chsq); if(forked_royalty>1 && Math.random() * 100D<168D) AssignGoodMove8(); if(forked_rookage>1 && Math.random() * 100D<168D) AssignGoodMove9(); if(forked_pieceage>1 && Math.random() * 100D<168D) AssignGoodMove4(); } if((chsq.piece_==1) & (QueenCount[3 - chsq.side_] + RookCount[3 - chsq.side_] + KnightCount[3 - chsq.side_] + BishopCount[3 - chsq.side_]<=2)) { if(chsq.side_==1 && Attackers[d[depth]][c[depth]][2]<=Attackers[d[depth]][c[depth]][1] && Math.random() * 100D<168D) { AssignGoodMove8(); return; } if(chsq.side_==2 && Attackers[d[depth]][c[depth]][1]<=Attackers[d[depth]][c[depth]][2] && Math.random() * 100D<168D) { AssignGoodMove8(); 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<168D) { 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<168D) { AssignGoodMove7(); return; } if((Attackers[d[depth]][c[depth]][3 - chsq.side_]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_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]0) & (chsq.piece_==1) & (Math.random() * 100D<168D)) AssignGoodMove1(); if(RookCount[3 - chsq.side_] + BishopCount[3 - chsq.side_] + QueenCount[3 - chsq.side_] + KnightCount[3 - chsq.side_]>2) return; if((chsq.piece_==1) & (Attackers[d[depth]][c[depth]][3 - chsq.side_]0) return; if(KnightCount[3 - chsq.side_]>0) return; goodmove2=0; if((Attackers[d[depth]][c[depth]][3 - chsq.side_]2)) { AssignGoodMove1(); if(chsq.piece_<0) { if((strategos==6) & (d[depth]=KingRank[3 - chsq.side_] + 2) & ((c[depth] - chsq.file_) * (c[depth] - KingFile[3 - chsq.side_])<0)) 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)) 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)) AssignGoodMove8(); if((strategos==9) & (c[depth]=KingFile[3 - chsq.side_] + 2) & ((d[depth] - chsq.rank_) * (d[depth] - KingRank[3 - chsq.side_])<0)) AssignGoodMove8(); if((strategos==6) & (d[depth]=KingRank[3 - chsq.side_] + 2) & ((c[depth] - chsq.file_) * (c[depth] - KingFile[3 - chsq.side_])<=0)) AssignGoodMove7(); 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)) AssignGoodMove7(); 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)) AssignGoodMove7(); if((strategos==9) & (c[depth]=KingFile[3 - chsq.side_] + 2) & ((d[depth] - chsq.rank_) * (d[depth] - KingRank[3 - chsq.side_])<=0)) AssignGoodMove7(); } if(chsq.piece_>0) { if((d[depth]d[depth]) & ((strategos==6) | (strategos==0)) | (d[depth]>chsq.rank_) & (KingRank[3 - chsq.side_]>d[depth]) & (KingRank[chsq.side_]c[depth]) & ((strategos==9) | (strategos==0)) | (c[depth]>chsq.file_) & (KingFile[3 - chsq.side_]>c[depth]) & (KingFile[chsq.side_]d[depth]) & ((strategos==6) | (strategos==0)) | (d[depth]==chsq.rank_) & (KingRank[3 - chsq.side_]>d[depth]) & (KingRank[chsq.side_]c[depth]) & ((strategos==9) | (strategos==0)) | (c[depth]==chsq.file_) & (KingFile[3 - chsq.side_]>c[depth]) & (KingFile[chsq.side_]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))) AssignGoodMove9(); if((d[depth]==chsq.rank_) & ((strategos==12) | (strategos==6) | (strategos==0))) AssignGoodMove9(); } } if((d[depth]d[depth]) & (strategos==0)) strategos=6; if((d[depth]>chsq.rank_) & (KingRank[3 - chsq.side_]>d[depth]) & (KingRank[chsq.side_]c[depth]) & (strategos==0)) strategos=9; if((c[depth]>chsq.file_) & (KingFile[3 - chsq.side_]>c[depth]) & (KingFile[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 DeclareWho(){} public void NormalMove(Graphics g) { //System.out.println("EasyChss.NormalMove"); DeclareWho(); //** 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[NowBoard.sq_[mover_rank][mover_file].side_]=moveto_rank; KingFile[whoseMove]=moveto_file; } NormalMoveExtra(); PawnStuff(g); HappyFiftyMoveRule(); switch(NowBoard.sq_[moveto_rank][moveto_file].piece_) { case -1: CapturedAKing[whoseMove]=true; 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; } 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(); CastleStuff(g); if(NowBoard.sq_[moveto_rank][moveto_file].piece_==6) NowBoard.sq_[moveto_rank][moveto_file].piece_=5; if(NowBoard.sq_[moveto_rank][moveto_file].piece_==-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; if(NowBoard.sq_[moveto_rank][moveto_file].piece_<0) { KingRank[whoseMove]=moveto_rank; KingFile[whoseMove]=moveto_file; } PromoStuff(g); TwoingPawns(); if((NowBoard.sq_[moveto_rank][moveto_file].piece_>2200) & (NowBoard.sq_[moveto_rank][moveto_file].piece_<2300)) { NowBoard.sq_[mover_rank][mover_file].piece_=NowBoard.sq_[mover_rank][mover_file].piece_ - 2200; NowBoard.sq_[moveto_rank][moveto_file].piece_=NowBoard.sq_[moveto_rank][moveto_file].piece_ - 2200; } else { NowBoard.sq_[mover_rank][mover_file].side_=0; NowBoard.sq_[mover_rank][mover_file].piece_=0; } NormalMoveFinale(g); TotalMaybeBoard(NowBoard, MaybeBoard); ShowStatusNothing(); Archives(); inquire_about_terms(); if (WhoIsHuman[whoseMove]==true){SayWhoIsHuman(g);} } public void NormalMoveExtra() { if (NowBoard.sq_[moveto_rank][moveto_file].piece_>2) { if (whoseMove==1){y=1;} if (whoseMove==2){y=8;} x=1;while (x<16){ if (NowBoard.sq_[y][x].piece_==1) { NowBoard.sq_[y][x].piece_=NowBoard.sq_[moveto_rank][moveto_file].piece_; x=99; } x++;} } } public void NormalMoveFinale(Graphics g) { } public void NullifySomethingElse() { } public boolean PassedOtherRequirementsToKeep(Chsq chsq, CB10_17 cb10_17, CB10_17 cb10_17_1) { return true; } public void PawnStuff(Graphics g) { //System.out.println("EasyChss.PawnStuff"); if(NowBoard.sq_[mover_rank][mover_file].piece_==2) NowBoard.sq_[mover_rank][mover_file].piece_=1; I_just_took_en_passant=false; 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_=0; NowBoard.sq_[mover_rank][moveto_file].side_=0; if (GameOver==false){ShowStatusQ("En Passant");CapturedAPawn[whoseMove]=true;} I_just_took_en_passant=true; NowBoard.sq_[mover_rank][moveto_file].drawchsq(g, 1, false); MaybeBoard.sq_[mover_rank][moveto_file].side_=0; MaybeBoard.sq_[mover_rank][moveto_file].piece_=0; } } public void PromoStuff(Graphics g) { //System.out.println("EasyChss.PromoStuff"); if (PromoUnit(whoseMove)==21){return;} if((moveto_rank==8) & (NowBoard.sq_[moveto_rank][moveto_file].side_==1) & ((NowBoard.sq_[moveto_rank][moveto_file].piece_==1) | (NowBoard.sq_[moveto_rank][moveto_file].piece_==51) | (NowBoard.sq_[moveto_rank][moveto_file].piece_==83) | (NowBoard.sq_[moveto_rank][moveto_file].piece_==140))) { if(!WhoIsHuman[1]) { NowBoard.sq_[moveto_rank][moveto_file].piece_=PromoUnit(whoseMove);CountAllThePieces(); return; } else { PromotingAPawn=true; queening_rank=moveto_rank; queening_file=moveto_file; DrawPromotionOptions(g); } } if((moveto_rank==1) & (NowBoard.sq_[moveto_rank][moveto_file].side_==2) & ((NowBoard.sq_[moveto_rank][moveto_file].piece_==1) | (NowBoard.sq_[moveto_rank][moveto_file].piece_==51) | (NowBoard.sq_[moveto_rank][moveto_file].piece_==83)| (NowBoard.sq_[moveto_rank][moveto_file].piece_==140))) { if(!WhoIsHuman[2]) { NowBoard.sq_[moveto_rank][moveto_file].piece_=PromoUnit(whoseMove);CountAllThePieces(); return; } PromotingAPawn=true; queening_rank=moveto_rank; queening_file=moveto_file; DrawPromotionOptions(g); } } public boolean PromotionClicks(int i, int j) { CountAllThePieces(); System.out.println(" i="+i+" j="+j+" RookCount="+RookCount[whoseMove]); if(j<300) {System.out.print("1");return false;} if(j>330) {System.out.print("2");return false;} if(i<90) {System.out.print("3");return false;} if(i>210) {System.out.print("4");return false;} if(i<120) {if (QueenCount[whoseMove]==2){System.out.print("Q");return false;}xxx=9;System.out.print("q");return true;} else if(i<150) {if (RookCount[whoseMove]==3){System.out.print("R");return false;}xxx=5;System.out.print("r");return true;} else if(i<180) {if (BishopCount[whoseMove]==4){System.out.print("B");return false;}xxx=4;System.out.print("b");return true;} else {if (KnightCount[whoseMove]==4){System.out.print("N");return false;}xxx=3;System.out.print("n");return true;} } public void RedCastleCheat() { } public void SaySomethingElseAboutWhoIsHuman(Graphics g) { } public void SayWhoIsHuman(Graphics g) { //System.out.println("EasyChss.SayWhoIsHuman"); if(PromotingAPawn) return; g.setColor(niceblue); g.fillRect(0, 271, 300, 94); g.setColor(Color.black); g.setFont(f1); g.drawString("White:", 10, 290); g.drawString("Red:", 10, 310); g.drawString("Computer", 120, 290); g.drawString("Computer", 120, 310); g.drawString("Human", 60, 290); g.drawString("Human", 60, 310); g.setFont(f1);NameThisChessVariant(g); g.drawString("White " + wins[1] + " Red " + wins[2] + " Drawn " + drawn_games, 5, 360); switch(who_is_winning) { case 1: // '\001' g.drawString("White wins", 30, 330); break; case 2: // '\002' g.drawString("Red wins", 30, 330); break; case 3: // '\003' g.drawString("Draw", 30, 330); break; } if(who_is_winning>0) g.drawString("Continue Game", 150, 330); g.setFont(f3); // g.drawString("Java applet by", 235, 350); g.drawString("-- Ed Friedlander", 235, 360); g.setFont(f2); if(humanizing) g.drawString("OKAY", 210, 300); g.setColor(Color.white); 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.red); 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.black); if(who_is_winning>0) { if(accepted_terms) { g.drawRect(26, 316, 67, 18); g.drawRect(27, 317, 65, 16); } if(!accepted_terms) { g.drawRect(147, 316, 95, 18); g.drawRect(148, 317, 93, 16); } } SaySomethingElseAboutWhoIsHuman(g); } public void ShowStatusNothing() { if(!GameOver) ShowStatusQ(""); } public void StartUp(Graphics g) { perpetual_check_wins=false; accepted_terms=false; who_is_winning=0; assailant_rank=0; assailant_file=0; assailant2_rank=0; assailant2_file=0; fifty_move_rule=0; knights_are_knightriders=false; turncounter=1;saved_fifty_move_rule=0;saved_turncounter=1;ShowStatusNothing(); markingAPiece=true; KingRank[0]=0; KingFile[0]=0; KingRank[1]=1; KingFile[1]=5; KingRank[2]=8; KingFile[2]=5; for(a=0; a<3; a++) { 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<16; a++) for(b=1; b<9; b++) { NowBoard.sq_[b][a].piece_=0; NowBoard.sq_[b][a].side_=0; if (b==1){NowBoard.sq_[b][a].side_=1;} if (b==8){NowBoard.sq_[b][a].side_=2;} } NowBoard.sq_[1][1].piece_=6; NowBoard.sq_[1][8].piece_=6; NowBoard.sq_[8][1].piece_=6; NowBoard.sq_[8][8].piece_=6; NowBoard.sq_[1][3].piece_=4; NowBoard.sq_[1][6].piece_=4; NowBoard.sq_[8][3].piece_=4; NowBoard.sq_[8][6].piece_=4; NowBoard.sq_[1][4].piece_=9; NowBoard.sq_[8][4].piece_=9; NowBoard.sq_[1][5].piece_=-2; NowBoard.sq_[8][5].piece_=-2; NowBoard.sq_[1][2].piece_=3; NowBoard.sq_[1][7].piece_=3; NowBoard.sq_[8][2].piece_=3; NowBoard.sq_[8][7].piece_=3; NowBoard.sq_[1][ 9].piece_=3; NowBoard.sq_[1][10].piece_=4; NowBoard.sq_[1][11].piece_=-2; NowBoard.sq_[1][12].piece_=9; NowBoard.sq_[1][13].piece_=4; NowBoard.sq_[1][14].piece_=3; NowBoard.sq_[1][15].piece_=6; NowBoard.sq_[8][ 9].piece_=3; NowBoard.sq_[8][10].piece_=4; NowBoard.sq_[8][11].piece_=-2; NowBoard.sq_[8][12].piece_=9; NowBoard.sq_[8][13].piece_=4; NowBoard.sq_[8][14].piece_=3; NowBoard.sq_[8][15].piece_=6; for(x=1; x<16; x++) { NowBoard.sq_[2][x].side_=1; NowBoard.sq_[2][x].piece_=1; NowBoard.sq_[7][x].side_=2; NowBoard.sq_[7][x].piece_=1; } SupplementalStartup(); whoseMove=1; ForGambler(g); PromotingAPawn=false; GameOver=false; fifty_move_rule=0; DrawNowBoard(g); TotalMaybeBoard(NowBoard, MaybeBoard); GenerateAttackersArrays(); SupplementalStartup(g); IsTheGameOver(); whatpiecescanmove(g); TotalSaveBoard(); TotalBackBoard(); } public void SupplementForInsaneChess() { } public void SupplementalAddACLCAttacker() { } 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_17 cb10_17, CB10_17 cb10_17_1) { } public void SupplementalStartup() { } public void SupplementalStartup(Graphics g) { } public void TotalMaybeBoard(CB10_17 cb10_17, CB10_17 cb10_17_1) { //System.out.println("EasyChss.TotalMaybeBoard"); for(xxx=1; xxx<16; xxx++) for(yyy=1; yyy<9; yyy++) { cb10_17_1.sq_[yyy][xxx].side_=cb10_17.sq_[yyy][xxx].side_; cb10_17_1.sq_[yyy][xxx].piece_=cb10_17.sq_[yyy][xxx].piece_; } } public void TwoingPawns() { //System.out.println("EasyChss.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_==2) & (NowBoard.sq_[moveto_rank][moveto_file].piece_==1) & (moveto_rank==5) & (mover_rank>6)) NowBoard.sq_[moveto_rank][moveto_file].piece_=2; } public void UnTwoThePawns(int i) { //System.out.println("EasyChss.UnTwoThePawns"); if((mover_rank==moveto_rank) & (mover_file==moveto_file)) return; for(xq=1; xq<16; xq++) for(yq=1; yq<9; yq++) if((NowBoard.sq_[yq][xq].side_==i) & (NowBoard.sq_[yq][xq].piece_==2)) NowBoard.sq_[yq][xq].piece_=1; } public void ZeroAllFiveCounts() { //System.out.println("EasyChss.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, CB10_17 cb10_17, CB10_17 cb10_17_1) { //System.out.println("EasyChss.AlterMaybeBoard"); cb10_17_1.sq_[chsq.rank_][chsq.file_].piece_=0; cb10_17_1.sq_[chsq.rank_][chsq.file_].side_=0; cb10_17_1.sq_[chsq1.rank_][chsq1.file_].piece_=cb10_17.sq_[chsq.rank_][chsq.file_].piece_; cb10_17_1.sq_[chsq1.rank_][chsq1.file_].side_=cb10_17.sq_[chsq.rank_][chsq.file_].side_; if((cb10_17.sq_[chsq.rank_][chsq.file_].piece_==1) & (cb10_17.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_17.sq_[chsq.rank_][chsq1.file_].piece_==2)) { cb10_17_1.sq_[chsq.rank_][chsq1.file_].piece_=0; cb10_17_1.sq_[chsq.rank_][chsq1.file_].side_=0; } } public void alterforked(Chsq chsq) { //System.out.println("EasyChss.AlterForked"); if((fork_c>0) & (fork_c<16) & (fork_d>0) & (fork_d<9)) { if(NowBoard.sq_[fork_d][fork_c].side_==chsq.side_) return; if((NowBoard.sq_[fork_d][fork_c].m_strength()>3) | (NowBoard.sq_[fork_d][fork_c].piece_<0)) forked_royalty++; if((NowBoard.sq_[fork_d][fork_c].m_strength()>2) | (NowBoard.sq_[fork_d][fork_c].piece_<0)) forked_rookage++; if((NowBoard.sq_[fork_d][fork_c].m_strength()>1) | (NowBoard.sq_[fork_d][fork_c].piece_<0)) forked_pieceage++; } } public void failsafe(Graphics g) { } public boolean findPieceMoves(Graphics g, Chsq chsq, CB10_17 cb10_17, CB10_17 cb10_17_1) { //System.out.println("EasyChss.FindPieceMoves"); CheckSquare[depth]=false; SquatterOnCheckSquare[depth]=false; SupplementalMovers(g, chsq, cb10_17, cb10_17_1); if((chsq.piece_==9) | (chsq.piece_==5) | (chsq.piece_==6)) { c[depth]=chsq.file_ - 1; for(d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb10_17, cb10_17_1) | CheckSquare[depth] & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); c[depth]=c[depth] - 1); } if((chsq.piece_==9) | (chsq.piece_==5) | (chsq.piece_==6)) { c[depth]=chsq.file_ + 1; for(d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb10_17, cb10_17_1) | CheckSquare[depth] & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); c[depth]++); } if((chsq.piece_==9) | (chsq.piece_==5) | (chsq.piece_==6)) { c[depth]=chsq.file_; for(d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1) | CheckSquare[depth] & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] - 1); } if((chsq.piece_==9) | (chsq.piece_==5) | (chsq.piece_==6)) { c[depth]=chsq.file_; for(d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1) | CheckSquare[depth] & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); d[depth]++); } if((chsq.piece_==9) | (chsq.piece_==4)) { c[depth]=chsq.file_ - 1; for(d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1) | CheckSquare[depth] & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] - 1) c[depth]=c[depth] - 1; } if((chsq.piece_==9) | (chsq.piece_==4)) { c[depth]=chsq.file_ - 1; for(d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1) | CheckSquare[depth] & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] + 1) c[depth]=c[depth] - 1; } if((chsq.piece_==9) | (chsq.piece_==4)) { c[depth]=chsq.file_ + 1; for(d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1) | CheckSquare[depth] & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] - 1) c[depth]=c[depth] + 1; } if((chsq.piece_==9) | (chsq.piece_==4)) { c[depth]=chsq.file_ + 1; for(d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1) | CheckSquare[depth] & (chsq.piece_ !=-9) & (chsq.piece_ !=-67) & (!SquatterOnCheckSquare[depth]); d[depth]=d[depth] + 1) c[depth]=c[depth] + 1; } if((chsq.piece_==-1) | (chsq.piece_==-2)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); if(chsq.piece_==-2) { if (chsq.file_==5) { MaybeCastleKingsideA(g, chsq.side_); MaybeCastleQueensideA(g, chsq.side_); } if (chsq.file_==11) { MaybeCastleKingsideB(g, chsq.side_); MaybeCastleQueensideB(g, chsq.side_); } } } if(chsq.piece_==3) { c[depth]=chsq.file_ - 2; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ - 2; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ + 2; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ + 2; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_17, cb10_17_1); c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } if((chsq.piece_==1) | (chsq.piece_==2)) { if((chsq.side_==1) & (chsq.rank_<8)) { if(NowBoard.sq_[chsq.rank_ + 1][chsq.file_].piece_==0) { c[depth]=chsq.file_; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } if((chsq.rank_==2) & (NowBoard.sq_[3][chsq.file_].piece_==0) & (NowBoard.sq_[4][chsq.file_].piece_==0)) { c[depth]=chsq.file_; d[depth]=4; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } if(chsq.file_>1) { if((NowBoard.sq_[chsq.rank_ + 1][chsq.file_ - 1].side_ !=0) & (NowBoard.sq_[chsq.rank_ + 1][chsq.file_ - 1].side_ !=chsq.side_) & (NowBoard.sq_[chsq.rank_ + 1][chsq.file_ - 1].piece_ !=0)) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } if((NowBoard.sq_[chsq.rank_ + 1][chsq.file_ - 1].side_==0) & (NowBoard.sq_[chsq.rank_][chsq.file_ - 1].side_ !=chsq.side_) & (NowBoard.sq_[chsq.rank_][chsq.file_ - 1].piece_==2)) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } } if(chsq.file_<15) { if((NowBoard.sq_[chsq.rank_ + 1][chsq.file_ + 1].side_ !=0) & (NowBoard.sq_[chsq.rank_ + 1][chsq.file_ + 1].side_ !=chsq.side_) & (NowBoard.sq_[chsq.rank_ + 1][chsq.file_ + 1].piece_ !=0)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } if((NowBoard.sq_[chsq.rank_ + 1][chsq.file_ + 1].side_==0) & (NowBoard.sq_[chsq.rank_][chsq.file_ + 1].side_ !=chsq.side_) & (NowBoard.sq_[chsq.rank_][chsq.file_ + 1].piece_==2)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } } } if((chsq.side_==2) & (chsq.rank_>1)) { if(NowBoard.sq_[chsq.rank_ - 1][chsq.file_].piece_==0) { c[depth]=chsq.file_; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } if((chsq.rank_==7) & (NowBoard.sq_[6][chsq.file_].piece_==0) & (NowBoard.sq_[5][chsq.file_].piece_==0)) { c[depth]=chsq.file_; d[depth]=5; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } if(chsq.file_>1) { if((NowBoard.sq_[chsq.rank_ - 1][chsq.file_ - 1].side_ !=0) & (NowBoard.sq_[chsq.rank_ - 1][chsq.file_ - 1].side_ !=chsq.side_) & (NowBoard.sq_[chsq.rank_ - 1][chsq.file_ - 1].piece_ !=0)) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } if((NowBoard.sq_[chsq.rank_ - 1][chsq.file_ - 1].side_==0) & (NowBoard.sq_[chsq.rank_][chsq.file_ - 1].side_ !=chsq.side_) & (NowBoard.sq_[chsq.rank_][chsq.file_ - 1].piece_==2)) { c[depth]=chsq.file_ - 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } } if(chsq.file_<15) { if((NowBoard.sq_[chsq.rank_ - 1][chsq.file_ + 1].side_ !=0) & (NowBoard.sq_[chsq.rank_ - 1][chsq.file_ + 1].side_ !=chsq.side_) & (NowBoard.sq_[chsq.rank_ - 1][chsq.file_ + 1].piece_ !=0)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } if((NowBoard.sq_[chsq.rank_ - 1][chsq.file_ + 1].side_==0) & (NowBoard.sq_[chsq.rank_][chsq.file_ + 1].side_ !=chsq.side_) & (NowBoard.sq_[chsq.rank_][chsq.file_ + 1].piece_==2)) { c[depth]=chsq.file_ + 1; d[depth]=chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_17, cb10_17_1); } } } } return moveCounter !=0; } public void init() { seek_sacrificial_wins=false; halt_if_king_taken=true; term_counts=new int[5]; best_four_count=new int[7]; niceblue=new Color(0, 192, 255); IHaveBeenInCheck=new boolean[5]; CapturedAKing=new boolean[5]; CapturedAQueen=new boolean[5]; CapturedABishop=new boolean[5]; CapturedARook=new boolean[5]; CapturedAKnight=new boolean[5]; CapturedAPawn=new boolean[5]; KingFile=new int[4]; KingRank=new int[4]; PawnCount=new int[4]; KnightCount=new int[4]; BishopCount=new int[4]; RookCount=new int[4]; QueenCount=new int[4]; KingCount=new int[4]; Attackers=new int[10][17][3]; StrongestAttacker=new int[10][17][3]; WeakestAttacker=new int[10][17][3]; CLCAttackers=new int[10][17][3]; NowBoard=new CB10_17(308); SaveBoard=new CB10_17(308); BackBoard=new CB10_17(308); MaybeBoard=new CB10_17(308); OneBoard=new CB10_17(308); TwoBoard=new CB10_17(308); ThreeBoard=new CB10_17(308); FourBoard=new CB10_17(308); icanmove=new boolean[10][17]; happySquare=new Chsq(1, 1, 5, 1); ArchiveBoard=new CB10_17[102]; MaybeMoves=new Chmo[2001]; CheckSquare=new boolean[7]; SquatterOnCheckSquare=new boolean[7]; c=new int[7]; d=new int[7]; x_run=new int[7]; y_run=new int[7]; z_run=new int[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; WhoIsHuman[3]=false; WhoIsHuman[4]=false; SupplementalInit(); GameOver=false; PromotingAPawn=false; drawn_games=0; Graphics g=getGraphics(); setBackground(niceblue); markingAPiece=true; for(a=1; a<=2000; a++) MaybeMoves[a]=new Chmo(); WhoIsHuman[0]=true; wins=new int[3]; wins[0]=0; wins[1]=0; wins[2]=0; StartUp(g); millipede1=System.currentTimeMillis(); for(xxx=0; xxx<102; xxx++) ArchiveBoard[xxx]=new CB10_17(308); millipede2=System.currentTimeMillis(); how_deep_to_seek=1; } public void inquire_about_terms() { //System.out.println("EasyChss.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]=90 * QueenCount[1] + 50 * RookCount[1] + 30 * BishopCount[1] + 30 * KnightCount[1] + 10 * PawnCount[1]; term_counts[2]=90 * 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) { //System.out.println("EasyChss.knightforks"); 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) { //System.out.println("EasyChss.markapiece"); 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].drawchsq(g, 1, icanmove[i][j]); return false; } NowBoard.sq_[i][j].drawchsq(g, 2, false); for(x=1; x<=moveCounter; x++) MaybeMoves[x].endingsquare_.markchsq(g); markingAPiece=false; return true; } public void start(){ //System.out.println("EasyChss.start"); if (NowBoard==null){init();repaint();ShowStatusQ("Applet Re-Started");} } public boolean mouseDown(Event event, int i, int j) { //System.out.println("EasyChss.mousedown"); if (NowBoard==null){return true;} Graphics g=getGraphics(); TotalMaybeBoard(NowBoard, MaybeBoard); 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)) { humanizing=true; WhoIsHuman[1]=true; SayWhoIsHuman(g); } else if((i>=117) & (j>=276) & (i<=178) & (j<=294)) { humanizing=true; WhoIsHuman[1]=false; SayWhoIsHuman(g); } else if((i>=56) & (j>=296) & (i<=104) & (j<=314)) { humanizing=true; WhoIsHuman[2]=true; SayWhoIsHuman(g); } else if((i>=117) & (j>=296) & (i<=178) & (j<=314)) { humanizing=true; WhoIsHuman[2]=false; SayWhoIsHuman(g); } else if((i>=26) & (j>=316) & (i<=93) & (j<=334)) { if(who_is_winning==0) return true; humanizing=true; accepted_terms=true; SayWhoIsHuman(g); } else if((i>=147) & (j>=316) & (i<=242) & (j<=334)) { if(who_is_winning==0) return true; humanizing=true; accepted_terms=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((a<1) | (a>15) | (b<1) | (b>8) && !PromotingAPawn) return true; if(PromotingAPawn) { if(!PromotionClicks(i, j)) return true; NowBoard.sq_[queening_rank][queening_file].piece_=xxx;CountAllThePieces(); TotalMaybeBoard(NowBoard,MaybeBoard); NowBoard.sq_[queening_rank][queening_file].drawchsq(g, 1, false); A2PromoSpecial(g); TotalMaybeBoard(NowBoard,MaybeBoard);DidICheckOrStalemate(g, whoseMove); PromotingAPawn=false; if (WhoIsHuman[whoseMove]==true){SayWhoIsHuman(g);} NextOrdinaryPlayer(g); if(WhoIsHuman[whoseMove]) { markingAPiece=true; 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(GameOver) return true; if(WhoIsHuman[whoseMove]) markingAPiece=true; } return true; } public boolean opening_library() { return false; } public void paint(Graphics g) { //System.out.println("EasyChss.paint"); 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; } paintSomethingElse(g); DrawNowBoard(g); g.setColor(niceblue); g.fillRect(0, 271, 300, 29);g.setColor(Color.black);g.setFont(f1);NameThisChessVariant(g); 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].drawchsq(g, 2, false); 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 pawnforks(Chsq chsq) { //System.out.println("EasyChss.pawnforks"); forked_royalty=0; forked_rookage=0; forked_pieceage=0; if(chsq.side_==1) { fork_c=c[depth] + 1; fork_d=d[depth] + 1; alterforked(chsq); fork_c=c[depth] - 1; fork_d=d[depth] + 1; alterforked(chsq); } if(chsq.side_==2) { fork_c=c[depth] + 1; fork_d=d[depth] - 1; alterforked(chsq); fork_c=c[depth] - 1; fork_d=d[depth] - 1; alterforked(chsq); } } public void stop() { //System.out.println("EasyChss.stop"); NullifySomethingElse(); NowBoard=null; MaybeBoard=null; OneBoard=null; TwoBoard=null; ThreeBoard=null; FourBoard=null; ArchiveBoard=null; MaybeMoves=null; Attackers=null; CLCAttackers=null; destroy(); } public void unalterMaybeBoard(Graphics g, Chsq chsq, Chsq chsq1, CB10_17 cb10_17, CB10_17 cb10_17_1) { //System.out.println("EasyChss.unaltermaybeboard"); cb10_17_1.sq_[chsq.rank_][chsq.file_].piece_=cb10_17.sq_[chsq.rank_][chsq.file_].piece_; cb10_17_1.sq_[chsq.rank_][chsq.file_].side_=cb10_17.sq_[chsq.rank_][chsq.file_].side_; cb10_17_1.sq_[chsq1.rank_][chsq1.file_].piece_=cb10_17.sq_[chsq1.rank_][chsq1.file_].piece_; cb10_17_1.sq_[chsq1.rank_][chsq1.file_].side_=cb10_17.sq_[chsq1.rank_][chsq1.file_].side_; cb10_17_1.sq_[chsq.rank_][chsq1.file_].side_=cb10_17.sq_[chsq.rank_][chsq1.file_].side_; cb10_17_1.sq_[chsq.rank_][chsq1.file_].piece_=cb10_17.sq_[chsq.rank_][chsq1.file_].piece_; } public void whatpiecescanmove(Graphics g) { //System.out.println("EasyChss.whatpiecescanmove"); for(ee=1; ee<16; ee++) for(ff=1; ff<9; 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 boolean skipDtGM; static boolean worried; static int forked_royalty; static int forked_rookage; static int forked_pieceage; static int fork_c; static int fork_d; static int undef_enemy_pawn_most_advanced_file[]=new int[3]; static int undef_enemy_pawn_most_advanced_rank[]=new int[3]; static int undef_enemy_pawn_nearest_king_file[]=new int[3]; static int undef_enemy_pawn_nearest_king_rank[]=new int[3]; static int distance_to_edible_pawn[]=new int[3]; static int pawnowner; static int strategos; Color niceblue; boolean IHaveBeenInCheck[]; boolean CapturedAKing[]; boolean CapturedAQueen[]; boolean CapturedABishop[]; boolean CapturedARook[]; boolean CapturedAKnight[]; boolean CapturedAPawn[]; static int cee; static int dee; static int eee; static int xee; static int yee; 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 fifties_got_to; static int assailant_rank; static int assailant_file; static int assailant2_rank; static int assailant2_file; int KingFile[]; int KingRank[]; int PawnCount[]; int KnightCount[]; int BishopCount[]; int RookCount[]; int QueenCount[]; int KingCount[]; int Attackers[][][]; int StrongestAttacker[][][]; int WeakestAttacker[][][]; int CLCAttackers[][][]; CB10_17 NowBoard; CB10_17 BackBoard; CB10_17 SaveBoard; CB10_17 MaybeBoard; CB10_17 OneBoard; CB10_17 TwoBoard; CB10_17 ThreeBoard; CB10_17 FourBoard; boolean icanmove[][]; Chsq happySquare; CB10_17 ArchiveBoard[]; Chmo MaybeMoves[]; static int ArchiveCounter; static int whichkingisworried; 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; boolean CheckSquare[]; boolean SquatterOnCheckSquare[]; 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; static boolean markingAPiece; static boolean GameOver; static boolean PromotingAPawn; static boolean humanizing; static boolean I_just_took_en_passant; static boolean knights_are_knightriders; 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 perpetual_check_wins; 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; }