Skip to content

Commit

Permalink
Merge pull request #136 from kenshinthebattosai/working
Browse files Browse the repository at this point in the history
Version 0.0.17
adds to the misery of #132
fixes #129
  • Loading branch information
artfuldev committed Feb 12, 2013
2 parents 3e7280c + c47eda8 commit d22d924
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 23 deletions.
Binary file modified KennyClassIQ.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Kenny ClassIQ
* Author: Kenshin Himura *(Sudarsan Balaji)*
* License: *GNU GPL v3 and CC-BY-NC-SA Licenses* (see gpl.txt and ccbyncsa.txt)
* Latest Application Version: 0.0.16 build 1677 *([Version History](Version%20History.md#version-history))*
* Latest Application Version: 0.0.17 build 1698 *([Version History](Version%20History.md#version-history))*
* Latest Stable Version: [-.--](https://github.com/kenshinthebattosai/KennyClassIQ/tree/stable) *([Versioning](Versioning.md#versioning))*
* ReadMe Version: 2.4

Expand All @@ -17,7 +17,6 @@ Having completed it successfully, I've gained the confidence to proceed with Ken
Game-breaking features (why you *can't* play against it now):

* Plays only the first move it can find.
* Cannot make promotion moves.
* Does not know about checks or mates or draw.
* Does not do search or evaluation.
* Does not know set-up position properly.
Expand Down
12 changes: 11 additions & 1 deletion Version History.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#Kenny ClassIQ
* Author: Kenshin Himura *(Sudarsan Balaji)*
* License: *GNU GPL v3 and CC-BY-NC-SA Licenses* (see gpl.txt and ccbyncsa.txt)
* Latest Application Version: 0.0.16 build 1677
* Latest Application Version: 0.0.17 build 1698
* Latest Stable Version: [-.--](https://github.com/kenshinthebattosai/KennyClassIQ/tree/stable) *([Versioning](Versioning.md#versioning))*
* Version History Document Version: 1.6

##Version History

#####Version 0.0.17 (1698)
* Improved *Player*.
* Added promotion moves to *Pawn*.
* Improved *Move* for promotion.
* Improved *XBoard, Uci*.
* Improved *Player*'s *makeMove()* for promotion.
* Changed version output.
* Changed exe's and names.
* Included jlaunch.

#####Version 0.0.16 (1677)
* Yes, the updates are coming in a frenzy!
* Added basic UCI support. Now engine supports both UCI and XBoard
Expand Down
2 changes: 2 additions & 0 deletions jlaunch.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mainClassName=com.kenny.classiq.Main
classPath=./KennyClassIQ.jar
32 changes: 32 additions & 0 deletions jlaunch_debug.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
rem @echo off
rem ======================================================================
rem This script will run jlaunch in debug mode. By default all messages are
rem printed in a DOS box (mode=box). As an alternative you can redirect all
rem messages to the file jlaunch_log.txt (mode=logging).
rem
rem ======================================================================
rem
set mode=box
rem set mode=logging
rem
rem ======================================================================
rem
if "%mode%" == "box" goto runBox
goto runLogging
rem
rem ======================================================================
rem
:runBox
.\jlaunch.exe -v
pause
goto ende
rem
rem ======================================================================
rem
:runLogging
.\jlaunch.exe -L
goto ende
rem
rem ======================================================================
rem
:ende
Binary file added kenny-classiq-fritz-aquarium.exe
Binary file not shown.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/com/kenny/classiq/console/UCI.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void start()
public void init()
{
System.out.println("id name "+Definitions.engineName+" "
+Definitions.engineVersion);
+Definitions.engineMainVersion);
System.out.println("id author "+Definitions.authorName);
System.out.println("uciok");
String[] knownCommands={"go",
Expand Down
2 changes: 1 addition & 1 deletion src/com/kenny/classiq/console/XBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void setFeatures()
+"time=0 sigint=0 sigterm=0 colors=0 ping=1 "
+"draw=0 pause=0 variants=normal myname="
+Definitions.engineName+" "
+Definitions.engineVersion);
+Definitions.engineMainVersion);
//feature setting done
System.out.println("feature done=1");
}
Expand Down
12 changes: 10 additions & 2 deletions src/com/kenny/classiq/definitions/Definitions.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ public class Definitions
*/
public static final String engineName="Kenny ClassIQ";
/**
* Holds the version of the engine.
* Holds the main version (MaVN.MiVn) of the engine.
*/
public static final String engineVersion="0.0.16 build 1677";
public static final String engineMainVersion="0.0";
/**
* Holds the sub version (.MaRN.MiRN build BN) of the engine.
*/
public static final String engineSubVersion=".17 build 1698";
/**
* Holds the complete version of the engine
*/
public static final String engineVersion=engineMainVersion+engineSubVersion;
/**
* Holds the error string.
*/
Expand Down
88 changes: 73 additions & 15 deletions src/com/kenny/classiq/game/Move.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ public class Move
* the capture of an opponent piece or not.
*/
private boolean capturingMove=false;
/**
* Holds a boolean value specifying if the move is a move involving
* a promotion or not.
*/
private boolean promotingMove=false;
/**
* Holds a reference to the piece to which the move will result in
* promotion.
*/
private Piece promotedPiece=null;
/**
* Default Constructor of <code>Move</code>.
*/
Expand Down Expand Up @@ -149,6 +159,26 @@ public Move(Square fromSquare,Square toSquare)
blackCastleQueenside=board.getGame().isBlackCastleQueenside();
enPassantSquare=board.getGame().getEnPassantSquare();
}
public Move(Square fromSquare, Square toSquare, String pieceType)
{
this.fromSquare=fromSquare;
this.toSquare=toSquare;
pieceMoved=fromSquare.getPiece();
moveString=fromSquare.getName()+toSquare.getName();
board=fromSquare.getBoard();
capturedPiece=toSquare.getPiece();
if(capturedPiece!=null)
capturingMove=true;
if(pieceMoved.getClass().getName().matches("Pawn")||
capturingMove)
halfMoveClock=board.getGame().getHalfMoveClock();
whiteCastleKingside=board.getGame().isWhiteCastleKingside();
whiteCastleQueenside=board.getGame().isWhiteCastleQueenside();
blackCastleKingside=board.getGame().isBlackCastleKingside();
blackCastleQueenside=board.getGame().isBlackCastleQueenside();
enPassantSquare=board.getGame().getEnPassantSquare();
promoteTo(pieceType);
}
/**
* Generic getter method of the variable pieceMoved. Since its a
* private variable, a public getter method has to be used to access
Expand Down Expand Up @@ -358,24 +388,22 @@ public void setMoveString(String moveString)
for(byte i=0;i<64;i++)
{
if(moveString.startsWith(board.getSquare(i).getName()))
fromSquare=board.getSquare(i);
if(moveString.endsWith(board.getSquare(i).getName()))
toSquare=board.getSquare(i);
setFromSquare(board.getSquare(i));
if((!moveString.startsWith(board.getSquare(i).getName()))&&
(moveString.contains(board.getSquare(i).getName())))
setToSquare(board.getSquare(i));
if((fromSquare!=null)&&(toSquare!=null))
break;
}
pieceMoved=fromSquare.getPiece();
capturedPiece=toSquare.getPiece();
if(capturedPiece!=null)
capturingMove=true;
if(pieceMoved.getShortAlgebraicNotation().matches("P")||
capturingMove)
halfMoveClock=board.getGame().getHalfMoveClock();
whiteCastleKingside=board.getGame().isWhiteCastleKingside();
whiteCastleQueenside=board.getGame().isWhiteCastleQueenside();
blackCastleKingside=board.getGame().isBlackCastleKingside();
blackCastleQueenside=board.getGame().isBlackCastleQueenside();
enPassantSquare=board.getGame().getEnPassantSquare();
if(moveString.endsWith("Q"))
promoteTo("queen");
if(moveString.endsWith("R"))
promoteTo("rook");
if(moveString.endsWith("B"))
promoteTo("bishop");
if(moveString.endsWith("N"))
promoteTo("knight");

}
/**
* Generic getter method used to access the private data member
Expand Down Expand Up @@ -535,6 +563,33 @@ public void setEnPassantSquare(Square enPassantSquare)
{
this.enPassantSquare = enPassantSquare;
}
public boolean isPromotingMove()
{
return promotingMove;
}
public Piece getPromotedPiece()
{
return promotedPiece;
}
public void promoteTo(String pieceType)
{
promotingMove=true;
String colourString;
if(pieceMoved.isWhite())
colourString="white";
else
colourString="black";
promotedPiece=board.getGame().getPieceSet().getPiece(colourString,pieceType);
moveString+=promotedPiece.getShortAlgebraicNotation();
}
public void setPromotedPiece(Piece promotedPiece)
{
this.promotedPiece = promotedPiece;
}
public void setPromotingMove(boolean promotingMove)
{
this.promotingMove = promotingMove;
}
/**
* Returns the string to be displayed to the user as a description
* of the move, substituting appropriate strings or adding such
Expand Down Expand Up @@ -572,6 +627,9 @@ public String toString()
}
//add destination square either way
returnString+=toSquare.toString();
//for promotions
if(promotingMove)
returnString+="="+promotedPiece.getShortAlgebraicNotation();
//for checking and mating moves
if(matingMove)
returnString+="#";
Expand Down
24 changes: 24 additions & 0 deletions src/com/kenny/classiq/junit/PromotionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.kenny.classiq.junit;

import org.junit.Test;

import com.kenny.classiq.game.Game;

public class PromotionTest
{
@Test
public void test()
{
String newFEN="rnbqkbnr/pppPpppp/8/8/8/8/PPPPPPpP/RNBQKB1R w KQkq - 0 1";
Game chessGame=new Game(newFEN);
chessGame.showBoard();
System.out.println(chessGame.getGameBoard().getSquare("g2").
getPiece().getMoves());
System.out.println(chessGame.getGameBoard().getSquare("g2").
getPiece().getMoves().get(0).getMoveString());
System.out.println(chessGame.getGameBoard().getSquare("d7").
getPiece().getMoves());
System.out.println(chessGame.getGameBoard().getSquare("d7").
getPiece().getMoves().get(0).getMoveString());
}
}
14 changes: 13 additions & 1 deletion src/com/kenny/classiq/pieces/Pawn.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,19 @@ public ArrayList<Move> getMoves()
}
if(!toSquares.isEmpty())
for(byte i=0;i<toSquares.size();i++)
returnList.add(new Move(square,toSquares.get(i)));
{
Move tempMove=new Move(square,toSquares.get(i));
returnList.add(tempMove);
if( (toSquares.get(i).getRankIndex()==0)||
(toSquares.get(i).getRankIndex()==7))
{
returnList.remove(tempMove);
returnList.add(new Move(square,toSquares.get(i),"queen"));
returnList.add(new Move(square,toSquares.get(i),"rook"));
returnList.add(new Move(square,toSquares.get(i),"bishop"));
returnList.add(new Move(square,toSquares.get(i),"knight"));
}
}
if(!returnList.isEmpty())
return returnList;
}
Expand Down
2 changes: 2 additions & 0 deletions src/com/kenny/classiq/players/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ public void makeMove(Move moveToMake)
moveToMake.getBoard().getGame().setEnPassantSquare(
moveToMake.getBoard().getSquare(moveToMake.getFromSquare().
getFile().getName()+avg));
if(moveToMake.isPromotingMove())
moveToMake.getToSquare().setPiece(moveToMake.getPromotedPiece());
}
game.setWhiteToMove(!game.isWhiteToMove());
}
Expand Down

0 comments on commit d22d924

Please sign in to comment.