// 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: Monochro.java import java.applet.Applet; import java.awt.*; import java.io.PrintStream; public class Monochro extends Applet { public Monochro() { } public void SomethingElseForTotalBackBoard() { backed_red_score=red_score; backed_white_score=white_score; ShowStatusNothing(); } public void SomethingElseForTotalSaveBoard() { saved_red_score=red_score; saved_white_score=white_score; ShowStatusNothing(); } public void SomethingElseForUnBackBoard() { red_score=backed_red_score; white_score=backed_white_score; ShowStatusNothing(); } public void SomethingElseForLoadSavedBoard() { red_score=saved_red_score; white_score=saved_white_score; ShowStatusNothing(); } public boolean SomeInitialConditionForKeydown() { return false; } public boolean keyDown(Event event, int i) { requestFocus(); if(humanizing) return false; if(SomeInitialConditionForKeydown()) return true; Graphics g = getGraphics(); oopsKey = getParameter("OOPS").charAt(0); saveKey = getParameter("SAVE").charAt(0); loadKey = getParameter("LOAD").charAt(0); if(i == 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(i == saveKey) { TotalSaveBoard(); TotalMaybeBoard(NowBoard, MaybeBoard); who_saved = whoseMove; } if(i == 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; } else { return false; } } public void TotalBackBoard() { back_turncounter = turncounter; back_fifty_move_rule = fifty_move_rule; for(xxx = 0; xxx < 9; 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_whoseMove = whoseMove; saved_fifty_move_rule = fifty_move_rule; saved_turncounter = turncounter; for(xxx = 0; xxx < 9; 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 < 9; 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() { whoseMove = saved_whoseMove; turncounter = saved_turncounter; fifty_move_rule = saved_fifty_move_rule; ShowStatusNothing(); for(xxx = 0; xxx < 9; 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 s) { if(turncounter == 0) { showStatus(s); return; } else { showStatus(s + " [" + turncounter + "]"); return; } } public void TotalMaybeBoard(CB10_10 cb10_10, CB10_10 cb10_10_1) { } public void whowon() { if(white_score > red_score) { wins[1]++; ShowStatusQ("South " + white_score + " North " + red_score + " South wins!"); } if(white_score < red_score) { wins[2]++; ShowStatusQ("South " + white_score + " North " + red_score + " North wins!"); } if(white_score == red_score) { wins[1]++; ShowStatusQ("South " + white_score + " North " + red_score + " Draw!"); } } 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() * (double)GM1count < 1.0D) | (GM1count == 1)) goodmove1 = moveCounter; } public void AssignGoodMove2() { GM2count++; if((Math.random() * (double)GM2count < 1.0D) | (GM2count == 1)) goodmove2 = moveCounter; } public void AssignGoodMove3() { GM3count++; if((Math.random() * (double)GM3count < 1.0D) | (GM3count == 1)) goodmove3 = moveCounter; } public void AssignGoodMove4() { GM4count++; if((Math.random() * (double)GM4count < 1.0D) | (GM4count == 1)) goodmove4 = moveCounter; } public void AssignGoodMove5() { GM5count++; if((Math.random() * (double)GM5count < 1.0D) | (GM5count == 1)) goodmove5 = moveCounter; } public void AssignGoodMove6() { GM6count++; if((Math.random() * (double)GM6count < 1.0D) | (GM6count == 1)) goodmove6 = moveCounter; } public void AssignGoodMove7() { GM7count++; if((Math.random() * (double)GM7count < 1.0D) | (GM7count == 1)) goodmove7 = moveCounter; } public void AssignGoodMove8() { GM8count++; if((Math.random() * (double)GM8count < 1.0D) | (GM8count == 1)) goodmove8 = moveCounter; } public void AssignGoodMove9() { GM9count++; if((Math.random() * (double)GM9count < 1.0D) | (GM9count == 1)) goodmove9 = moveCounter; } public void AssignGoodMove10() { GM10count++; if((Math.random() * (double)GM10count < 1.0D) | (GM10count == 1)) goodmove10 = moveCounter; } public void start() { if(NowBoard == null) { init(); repaint(); ShowStatusQ("Applet Re-Started"); } } public void AddAnAttacker() { if((xatt == catt) & (yatt == datt)) return; if((catt > 8) | (datt > 8) | (catt < 1) | (datt < 1)) return; if(satt > 2) return; Attackers[datt][catt][satt] = Attackers[datt][catt][satt] + 1; if(StrongestAttacker[datt][catt][satt] < NowBoard.sq_[yatt][xatt].strength()) StrongestAttacker[datt][catt][satt] = NowBoard.sq_[yatt][xatt].strength(); if((WeakestAttacker[datt][catt][satt] > NowBoard.sq_[yatt][xatt].strength()) | (WeakestAttacker[datt][catt][satt] == 0)) WeakestAttacker[datt][catt][satt] = NowBoard.sq_[yatt][xatt].strength(); } public void AlsoMark(Graphics g) { } public boolean AnotherWayToEndGame(Graphics g, int i) { return false; } 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) { GameOver = true; whowon(); return; } } } public void CastleStuff(Graphics g) { 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].draw_monochrome(g, 1, false); NowBoard.sq_[moveto_rank][8].draw_monochrome(g, 1, false); } 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].draw_monochrome(g, 1, false); NowBoard.sq_[moveto_rank][1].draw_monochrome(g, 1, false); } NowBoard.sq_[moveto_rank][moveto_file].piece_++; } } public void CountAllThePieces() { ZeroAllFiveCounts(); for(xxx = 1; xxx < 9; 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(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_]++; } } public void DesignateTheFineMoves(Chsq chsq) { good_move = 1; if(skipDtGM | (depth > 1) | worried) return; if(chsq.strength() < NowBoard.sq_[d[depth]][c[depth]].strength()) good_move = (good_move + 3 * NowBoard.sq_[d[depth]][c[depth]].strength()) - chsq.strength(); if((Attackers[chsq.rank_][chsq.file_][3 - chsq.side_] > 0) & (Attackers[d[depth]][c[depth]][3 - chsq.side_] == 0)) good_move += 5 * chsq.strength(); if((NowBoard.sq_[d[depth]][c[depth]].piece_ > 0) & (Attackers[d[depth]][c[depth]][chsq.side_] > Attackers[d[depth]][c[depth]][3 - chsq.side_])) good_move += 3 * NowBoard.sq_[d[depth]][c[depth]].strength(); } public void DesignateTheGoodMoves(Chsq chsq) { if((whoseMove != chsq.side_) | (skipDtGM | (depth > 1))) return; IncrediblyGoodMove(chsq); if((Attackers[d[depth]][c[depth]][3 - chsq.side_] == 0) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) && Math.random() * 100D < 99D) AssignGoodMove9(); if(NowBoard.sq_[d[depth]][c[depth]].strength() > 1 + chsq.strength() && Math.random() * 100D < 98D && !worried) AssignGoodMove9(); if(NowBoard.sq_[d[depth]][c[depth]].strength() > 2 + chsq.strength() && !worried) AssignGoodMove9(); if((chsq.strength() > 3) & (Attackers[chsq.rank_][chsq.file_][3 - chsq.side_] > 0) & (Attackers[d[depth]][c[depth]][3 - chsq.side_] == 0) && (Math.random() * 100D < 98D && !worried)) { AssignGoodMove8(); if(NowBoard.sq_[d[depth]][c[depth]].piece_ != 0) AssignGoodMove9(); } if((Attackers[d[depth]][c[depth]][3 - chsq.side_] == 0) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove7(); if((chsq.strength() < 3) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 3) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove6(); if((chsq.strength() > 2) & (Attackers[chsq.rank_][chsq.file_][3 - chsq.side_] > 0) & (Attackers[d[depth]][c[depth]][3 - chsq.side_] == 0) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove5(); if((Attackers[d[depth]][c[depth]][3 - chsq.side_] == 0) & (NowBoard.sq_[d[depth]][c[depth]].strength() > 1) && (Math.random() * 100D < 98D && !worried)) AssignGoodMove4(); MoreGoodMoves(chsq); } public void DidICheckOrStalemate(Graphics g, int i) { if(GameOver) return; if(AnotherWayToEndGame(g, i)) { GameOver = true; whowon(); return; } moveCounter = 0; for(xx = 1; (xx < 9) & (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(moveCounter == 0) { GameOver = true; whowon(); return; } else { return; } } public void DisplayRules(Graphics g) { LowRectangle(g); g.drawString("Move the units on your side, and score by capturing", 5, 285); g.drawString("opposing units. Pawns can move forward or", 5, 301); g.drawString("backward. K=10 Q=9 R=5 B=4 N=3 P=1.", 5, 317); } 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 DrawNowBoard(Graphics g) { for(ee = 1; ee < 9; ee++) for(ff = 1; ff < 9; ff++) NowBoard.sq_[ff][ee].draw_monochrome(g, 1, false); } public void DrawPromotionOptions(Graphics g) { 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; happySquare.draw_monochrome(g, 11, false); happySquare.file_ = 4; happySquare.piece_ = 5; happySquare.draw_monochrome(g, 11, false); happySquare.file_ = 5; happySquare.piece_ = 4; happySquare.draw_monochrome(g, 11, false); happySquare.file_ = 6; happySquare.piece_ = 3; happySquare.draw_monochrome(g, 11, false); } public void ForGambler(Graphics g) { } public void GenerateAttackersArrays() { for(zatt = 1; zatt < 3; 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) { 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) | (patt == -9) | (patt == 21) | (patt == 28) | (patt == 104) | (patt == 109)) { 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) | (patt == 103) | (patt == -4) | (patt == -5) | (patt == 21) | (patt == 28) | (patt == 29) | (patt == 57) | (patt == 193)) { 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 == 23) | (patt == 123) | (patt == 140) | (patt == 223) | (patt == 224)) { catt = xatt + 1; datt = yatt + 1; AddAnAttacker(); catt = xatt + 1; datt = yatt - 1; AddAnAttacker(); catt = xatt - 1; datt = yatt + 1; AddAnAttacker(); catt = xatt - 1; datt = yatt - 1; AddAnAttacker(); } if((patt == 1) | (patt == 2) | (patt == 51) | (patt == 52) | (patt == 101) | (patt == 102) | (patt == 83) | (patt == 84) | (patt == 85) | (patt == 8101) | (patt == 8102)) { datt = yatt + 1; catt = xatt + 1; AddAnAttacker(); datt = yatt + 1; catt = xatt - 1; AddAnAttacker(); datt = yatt - 1; catt = xatt + 1; AddAnAttacker(); datt = yatt - 1; catt = xatt - 1; AddAnAttacker(); } } } 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); return true; } } public void IncrediblyGoodMove(Chsq chsq) { } 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 IsTheGameOver() { 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; whowon(); drawn_games++; return true; } if((BishopCount[1] < 2) & (BishopCount[2] < 2) & (KnightCount[1] == 0) & (KnightCount[2] == 0)) { GameOver = true; whowon(); drawn_games++; return true; } } return false; } public void LowRectangle(Graphics g) { 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 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; UnTwoThePawns(i); moveCounter = 0; if(!opening_library()) { gametreecounter = 0; if(how_deep_to_seek > 3) depth = 1; bestvcom1 = -5000; for(x_run[1] = 1; x_run[1] < 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_][3 - i] > Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][i]) x = 1 + (int)Math.floor(Math.random() * (double)moveCounter); if(Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][3 - i] > Attackers[MaybeMoves[x].endingsquare_.rank_][MaybeMoves[x].endingsquare_.file_][i]) x = 1 + (int)Math.floor(Math.random() * (double)moveCounter); if(goodmove1 > 0) x = goodmove1; if(goodmove2 > 0) x = goodmove2; if(goodmove3 > 0) x = goodmove3; if(goodmove4 > 0) x = goodmove4; if(goodmove5 > 0) x = goodmove5; if(goodmove6 > 0) x = goodmove6; if(goodmove7 > 0) x = goodmove7; if(goodmove8 > 0) x = goodmove8; if(goodmove9 > 0) x = goodmove9; if(goodmove10 > 0) x = goodmove10; moveto_file = MaybeMoves[x].endingsquare_.file_; moveto_rank = MaybeMoves[x].endingsquare_.rank_; mover_file = MaybeMoves[x].startingsquare_.file_; mover_rank = MaybeMoves[x].startingsquare_.rank_; } NormalMove(g); NowBoard.sq_[mover_rank][mover_file].draw_monochrome(g, 1, false); NowBoard.sq_[moveto_rank][moveto_file].draw_monochrome(g, 1, false); TotalMaybeBoard(NowBoard, MaybeBoard); DidICheckOrStalemate(g, i); if(GameOver) return true; if(fifty_move_rule > 55) { fifty_move_rule = 0; ShowStatusQ("Game Over"); GameOver = true; whowon(); return false; } else { return true; } } public boolean MaybeAdd(Graphics g, Chsq chsq, CB10_10 cb10_10, CB10_10 cb10_10_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)) return false; if(!PassedOtherRequirementsToKeep(chsq, cb10_10, cb10_10_1)) return false; if(NowBoard.sq_[d[depth]][c[depth]].piece_ == 193) return false; if(NowBoard.sq_[d[depth]][c[depth]].piece_ == 85) return false; if(NowBoard.sq_[d[depth]][c[depth]].piece_ == 123) return false; if(NowBoard.sq_[d[depth]][c[depth]].piece_ == 124) return false; if(NowBoard.sq_[d[depth]][c[depth]].side_ == chsq.side_) 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) & (!skipDtGM) & (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_10.sq_[d[depth]][c[depth]]; } DesignateTheGoodMoves(chsq); return NowBoard.sq_[d[depth]][c[depth]].side_ == 0; } public void MaybeCastleKingside(Graphics g, int i) { if(depth > 1) 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; 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; d[depth] = 8; c[depth] = 7; MaybeAdd(g, NowBoard.sq_[8][5], NowBoard, MaybeBoard); } } public void MaybeCastleQueenside(Graphics g, int i) { if(depth > 1) 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; 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; d[depth] = 8; c[depth] = 3; MaybeAdd(g, NowBoard.sq_[8][5], NowBoard, MaybeBoard); } } public void MoreGoodMoves(Chsq chsq) { } public void AssignVariantName() { halt_if_king_taken = false; variant_name = "Monochrome Chess"; } 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(GameOver) { whowon(); SayWhoIsHuman(g); return; } if(WhoIsHuman[whoseMove]) SayWhoIsHuman(g); whoseMove = 3 - whoseMove; if(whoseMove == 1) turncounter++; UnTwoThePawns(whoseMove); whatpiecescanmove(g); GenerateAttackersArrays(); } public void NormalMove(Graphics g) { if(NowBoard.sq_[mover_rank][mover_file].piece_ < 0) { KingRank[whoseMove] = moveto_rank; KingFile[whoseMove] = moveto_file; } NormalMoveExtra(); if(whoseMove == 1) switch(NowBoard.sq_[moveto_rank][moveto_file].piece_) { case -1: white_score += 10; break; case 1: // '\001' white_score++; break; case 2: // '\002' white_score++; break; case 3: // '\003' white_score += 3; break; case 4: // '\004' white_score += 4; break; case 5: // '\005' white_score += 5; break; case 9: // '\t' white_score += 9; break; } if(whoseMove == 2) switch(NowBoard.sq_[moveto_rank][moveto_file].piece_) { case -1: red_score += 10; break; case 1: // '\001' red_score++; break; case 2: // '\002' red_score++; break; case 3: // '\003' red_score += 3; break; case 4: // '\004' red_score += 4; break; case 5: // '\005' red_score += 5; break; case 6: // '\005' red_score += 5; break; case 9: // '\t' red_score += 9; break; } 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)) { 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 -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_ == -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; NormalMoveFinale(g); if(moveto_rank > 4) NowBoard.sq_[moveto_rank][moveto_file].side_ = 2; else NowBoard.sq_[moveto_rank][moveto_file].side_ = 1; ShowStatusNothing(); Archives(); inquire_about_terms(); if(WhoIsHuman[whoseMove]) SayWhoIsHuman(g); } public void NormalMoveExtra() { } public void NormalMoveFinale(Graphics g) { } public boolean PassedOtherRequirementsToKeep(Chsq chsq, CB10_10 cb10_10, CB10_10 cb10_10_1) { return true; } public void PawnStuff(Graphics g) { } public void PromoStuff(Graphics g) { 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_ = 9; } 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))) { if(!WhoIsHuman[2]) { NowBoard.sq_[moveto_rank][moveto_file].piece_ = 9; return; } 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, 94); g.setColor(Color.black); g.setFont(f1); g.drawString("South", 10, 290); g.drawString("North:", 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("South " + wins[1] + " North " + wins[2] + " Drawn " + drawn_games, 5, 360); g.setFont(f3); g.drawString("--Ed Friedlander", 235, 360); g.setFont(f2); if(humanizing) g.drawString("OKAY", 210, 300); if((!humanizing) & (white_score + red_score > 0) & (!GameOver)) g.drawString("QUIT", 210, 300); g.setColor(Color.blue); 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.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); } } public void ShowStatusNothing() { if(!GameOver) ShowStatusQ("South " + white_score + " North " + red_score + " "); } public void StartUp(Graphics g) { turncounter = 1; saved_fifty_move_rule = 0; saved_turncounter = 1; ShowStatusNothing(); accepted_terms = false; who_is_winning = 0; white_score = 0; red_score = 0; 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 <= 8; a++) for(b = 1; b <= 8; b++) { NowBoard.sq_[b][a].piece_ = 0; NowBoard.sq_[b][a].side_ = 0; } NowBoard.sq_[1][1].side_ = 1; NowBoard.sq_[1][1].piece_ = 6; NowBoard.sq_[1][8].side_ = 1; NowBoard.sq_[1][8].piece_ = 6; NowBoard.sq_[8][1].side_ = 2; NowBoard.sq_[8][1].piece_ = 6; NowBoard.sq_[8][8].side_ = 2; NowBoard.sq_[8][8].piece_ = 6; NowBoard.sq_[1][3].side_ = 1; NowBoard.sq_[1][3].piece_ = 4; NowBoard.sq_[1][6].side_ = 1; NowBoard.sq_[1][6].piece_ = 4; NowBoard.sq_[8][3].side_ = 2; NowBoard.sq_[8][3].piece_ = 4; NowBoard.sq_[8][6].side_ = 2; NowBoard.sq_[8][6].piece_ = 4; NowBoard.sq_[1][4].side_ = 1; NowBoard.sq_[1][4].piece_ = 9; NowBoard.sq_[8][4].side_ = 2; NowBoard.sq_[8][4].piece_ = 9; NowBoard.sq_[1][5].side_ = 1; NowBoard.sq_[1][5].piece_ = -2; NowBoard.sq_[8][5].side_ = 2; NowBoard.sq_[8][5].piece_ = -2; NowBoard.sq_[1][2].side_ = 1; NowBoard.sq_[1][2].piece_ = 3; NowBoard.sq_[1][7].side_ = 1; NowBoard.sq_[1][7].piece_ = 3; NowBoard.sq_[8][2].side_ = 2; NowBoard.sq_[8][2].piece_ = 3; NowBoard.sq_[8][7].side_ = 2; NowBoard.sq_[8][7].piece_ = 3; for(x = 1; x < 9; 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; whatpiecescanmove(g); ForGambler(g); PromotingAPawn = false; GameOver = false; fifty_move_rule = 0; DrawNowBoard(g); TotalSaveBoard(); TotalBackBoard(); } public void SupplementForInsaneChess() { } public void SupplementalAddAnAttacker() { } public void SupplementalInit() { } public void SupplementalMovers(Graphics g, Chsq chsq, CB10_10 cb10_10, CB10_10 cb10_10_1) { } public void SupplementalStartup() { } public void SupplementalStartup(Graphics g) { } public void TwoingPawns() { } public void UnTwoThePawns(int i) { for(xq = 1; xq < 9; 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() { 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 boolean findPieceMoves(Graphics g, Chsq chsq, CB10_10 cb10_10, CB10_10 cb10_10_1) { CheckSquare[depth] = false; SquatterOnCheckSquare[depth] = false; SupplementalMovers(g, chsq, cb10_10, cb10_10_1); if((chsq.piece_ == 60) | (chsq.piece_ == 260) | (chsq.piece_ == 224)) { c[depth] = chsq.file_ - 2; d[depth] = chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ - 2; d[depth] = chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ + 2; d[depth] = chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ + 2; d[depth] = chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_10, cb10_10_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_10, cb10_10_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_10, cb10_10_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_10, cb10_10_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_10, cb10_10_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_10, cb10_10_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_10, cb10_10_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_10, cb10_10_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_10, cb10_10_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_10, cb10_10_1); c[depth] = chsq.file_; d[depth] = chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ + 1; d[depth] = chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ + 1; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_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_10, cb10_10_1); c[depth] = chsq.file_; d[depth] = chsq.rank_ - 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_ != 0) MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ + 1; d[depth] = chsq.rank_ + 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_ == 0) MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ + 1; d[depth] = chsq.rank_ - 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_ == 0) MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_ + 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_ == 0) MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_ - 1; if(NowBoard.sq_[d[depth]][c[depth]].piece_ == 0) MaybeAdd(g, chsq, cb10_10, cb10_10_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_10, cb10_10_1); c[depth] = chsq.file_ + 1; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_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_10, cb10_10_1); c[depth] = chsq.file_ - 2; d[depth] = chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ + 2; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ + 2; d[depth] = chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ + 1; d[depth] = chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_10, cb10_10_1); c[depth] = chsq.file_ + 1; d[depth] = chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_10, cb10_10_1); } if((chsq.piece_ == 1) | (chsq.piece_ == 51) | (chsq.piece_ == 83) | (chsq.piece_ == 85) | (chsq.piece_ == 8101) | (chsq.piece_ == 8102) | (chsq.piece_ == 101)) { if(chsq.rank_ < 8) { if(chsq.rank_ > 1 && chsq.piece_ == 51 && NowBoard.sq_[chsq.rank_ - 1][chsq.file_].piece_ == 0) { c[depth] = chsq.file_; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); } if(chsq.piece_ == 83) for(d[depth] = chsq.rank_ - 1; (d[depth] > 1) & (NowBoard.sq_[d[depth]][chsq.file_].piece_ == 0); d[depth] = d[depth] - 1) if(d[depth] > 0) MaybeAdd(g, chsq, cb10_10, cb10_10_1); if(NowBoard.sq_[chsq.rank_ + 1][chsq.file_].piece_ == 0) { c[depth] = chsq.file_; d[depth] = chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); } if((chsq.rank_ < 3) & (NowBoard.sq_[chsq.rank_ + 1][chsq.file_].piece_ == 0) & (NowBoard.sq_[chsq.rank_ + 2][chsq.file_].piece_ == 0) & ((chsq.rank_ == 2) | (chsq.piece_ != 101))) { c[depth] = chsq.file_; d[depth] = chsq.rank_ + 2; MaybeAdd(g, chsq, cb10_10, cb10_10_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_10, cb10_10_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) | (NowBoard.sq_[chsq.rank_][chsq.file_ - 1].piece_ == 52) | (NowBoard.sq_[chsq.rank_][chsq.file_ - 1].piece_ == 102) | (NowBoard.sq_[chsq.rank_][chsq.file_ - 1].piece_ == 84))) { c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); } } if(chsq.file_ < 8) { 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_10, cb10_10_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) | (NowBoard.sq_[chsq.rank_][chsq.file_ + 1].piece_ == 52) | (NowBoard.sq_[chsq.rank_][chsq.file_ + 1].piece_ == 102) | (NowBoard.sq_[chsq.rank_][chsq.file_ + 1].piece_ == 84))) { c[depth] = chsq.file_ + 1; d[depth] = chsq.rank_ + 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); } } } if(chsq.rank_ > 1) { if(chsq.rank_ < 8 && chsq.piece_ == 51 && NowBoard.sq_[chsq.rank_ - 1][chsq.file_].piece_ == 0) { c[depth] = chsq.file_; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); } if(chsq.piece_ == 83) for(d[depth] = chsq.rank_ + 1; (d[depth] < 8) & (NowBoard.sq_[d[depth]][chsq.file_].piece_ == 0); d[depth]++) if(d[depth] < 9) MaybeAdd(g, chsq, cb10_10, cb10_10_1); if(NowBoard.sq_[chsq.rank_ - 1][chsq.file_].piece_ == 0) { c[depth] = chsq.file_; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); } if((chsq.rank_ >= 7) & (NowBoard.sq_[chsq.rank_ - 1][chsq.file_].piece_ == 0) & (NowBoard.sq_[chsq.rank_ - 2][chsq.file_].piece_ == 0) & ((chsq.rank_ == 7) | (chsq.piece_ != 101))) { c[depth] = chsq.file_; d[depth] = chsq.rank_ - 2; MaybeAdd(g, chsq, cb10_10, cb10_10_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_10, cb10_10_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) | (NowBoard.sq_[chsq.rank_][chsq.file_ - 1].piece_ == 52) | (NowBoard.sq_[chsq.rank_][chsq.file_ - 1].piece_ == 102) | (NowBoard.sq_[chsq.rank_][chsq.file_ - 1].piece_ == 84))) { c[depth] = chsq.file_ - 1; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); } } if(chsq.file_ < 8) { 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_10, cb10_10_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) | (NowBoard.sq_[chsq.rank_][chsq.file_ + 1].piece_ == 52) | (NowBoard.sq_[chsq.rank_][chsq.file_ + 1].piece_ == 102) | (NowBoard.sq_[chsq.rank_][chsq.file_ + 1].piece_ == 84))) { c[depth] = chsq.file_ + 1; d[depth] = chsq.rank_ - 1; MaybeAdd(g, chsq, cb10_10, cb10_10_1); } } } } if(((chsq.piece_ == -2) | (chsq.piece_ == -14)) & (chsq.file_ == 5)) { MaybeCastleKingside(g, chsq.side_); MaybeCastleQueenside(g, chsq.side_); } return true; } public void init() { requestFocus(); seek_sacrificial_wins = false; halt_if_king_taken = true; term_counts = new int[5]; best_four_count = new int[7]; KingRank = new int[5]; KingFile = new int[5]; 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]; PawnCount = new int[3]; KnightCount = new int[3]; BishopCount = new int[3]; RookCount = new int[3]; QueenCount = new int[3]; KingCount = new int[3]; Attackers = new int[10][10][3]; StrongestAttacker = new int[10][10][3]; WeakestAttacker = new int[10][10][3]; NowBoard = new CB10_10(308); SaveBoard = new CB10_10(308); BackBoard = new CB10_10(308); MaybeBoard = new CB10_10(308); OneBoard = new CB10_10(308); TwoBoard = new CB10_10(308); ThreeBoard = new CB10_10(308); FourBoard = new CB10_10(308); icanmove = new boolean[10][10]; ArchiveBoard = new CB10_10[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[3]; depth = 0; WhoIsHuman[1] = true; WhoIsHuman[2] = false; 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; wins[0] = 0; wins[1] = 0; wins[2] = 0; StartUp(g); millipede1 = System.currentTimeMillis(); for(xxx = 0; xxx < 102; xxx++) ArchiveBoard[xxx] = new CB10_10(310); millipede2 = System.currentTimeMillis(); how_deep_to_seek = /*4*/3; if(millipede2 - millipede1 < 1000L) how_deep_to_seek = /*4*/3; } 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].draw_monochrome(g, 1, false); return false; } NowBoard.sq_[i][j].draw_monochrome(g, 2, false); 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((!humanizing) & (white_score + red_score > 0) & (i >= 210) & (j >= 285) & (i < 270) & (j < 320)) { GameOver = true; whowon(); SayWhoIsHuman(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(PromotingAPawn) { if(!PromotionClicks(i, j)) return true; NowBoard.sq_[queening_rank][queening_file].piece_ = xxx; NowBoard.sq_[queening_rank][queening_file].draw_monochrome(g, 1, false); TotalMaybeBoard(NowBoard, MaybeBoard); DidICheckOrStalemate(g, whoseMove); PromotingAPawn = false; if(WhoIsHuman[whoseMove]) SayWhoIsHuman(g); NextOrdinaryPlayer(g); if(WhoIsHuman[whoseMove]) { markingAPiece = true; return true; } } UnTwoThePawns(whoseMove); if((a < 1) | (a > 8) | (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); UnTwoThePawns(whoseMove); if(WhoIsHuman[whoseMove]) markingAPiece = true; } return true; } public boolean opening_library() { return false; } public void paint(Graphics g) { setBackground(niceblue); if(NowBoard == null) { g.setColor(Color.black); g.setFont(f1); AssignVariantName(); g.drawString("Thank you for playing " + variant_name + "!", 5, 20); g.drawString("Final totals: White " + wins[1] + " Red " + wins[2] + " Drawn " + drawn_games, 5, 50); return; } 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].draw_monochrome(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 stop() { NowBoard = null; MaybeBoard = null; OneBoard = null; TwoBoard = null; ThreeBoard = null; FourBoard = null; ArchiveBoard = null; MaybeMoves = null; Attackers = null; destroy(); } public void whatpiecescanmove(Graphics g) { for(ee = 1; ee < 9; 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; } } } 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 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; int KingRank[]; int KingFile[]; Color niceblue; static int white_score; static int red_score; static int backed_white_score; static int backed_red_score; static int saved_white_score; static int saved_red_score; boolean IHaveBeenInCheck[]; boolean CapturedAKing[]; boolean CapturedAQueen[]; boolean CapturedABishop[]; boolean CapturedARook[]; boolean CapturedAKnight[]; boolean CapturedAPawn[]; int PawnCount[]; int KnightCount[]; int BishopCount[]; int RookCount[]; int QueenCount[]; int KingCount[]; int Attackers[][][]; int StrongestAttacker[][][]; int WeakestAttacker[][][]; CB10_10 NowBoard; CB10_10 BackBoard; CB10_10 SaveBoard; CB10_10 MaybeBoard; CB10_10 OneBoard; CB10_10 TwoBoard; CB10_10 ThreeBoard; CB10_10 FourBoard; boolean icanmove[][]; CB10_10 ArchiveBoard[]; Chsq happySquare; Chmo MaybeMoves[]; static int ArchiveCounter; static int fifties_got_to; static int goodmove1; static int goodmove2; static int goodmove3; static int goodmove4; static int goodmove5; static int goodmove6; static int goodmove7; static int goodmove8; static int goodmove9; static int goodmove10; static int GM1count; static int GM2count; static int GM3count; static int GM4count; static int GM5count; static int GM6count; static int GM7count; static int GM8count; static int GM9count; static int GM10count; int c[]; int d[]; int x_run[]; int y_run[]; int z_run[]; static int x; static int y; static int z; static int a; static int b; static int depth; static int e; static int f; static int h; static int moveCounter; static int xx; static int yy; static int cc; static int dd; static int ee; static int ff; static int xxx; static int yyy; static int 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 PromotingAPawn; static boolean humanizing; 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; static int saved_whoseMove; boolean WhoIsHuman[]; int wins[]; static String stringy; static boolean halt_if_king_taken; static boolean seek_sacrificial_wins; static int turncounter; static int saved_turncounter; static int back_turncounter; static int saved_fifty_move_rule; static int back_fifty_move_rule; static char oopsKey; static char loadKey; static char saveKey; static int who_backed; static int who_saved; static int when_saved; }