Evil Tesuji
My jouney to the secrets of go.
Search
Friday, August 24, 2012
Day 16: Ko, part III
Well, something like a ko was implemented in the program, but still couldn't test it.
First I changed tryToKill from void to integer and return number of killed stones:
public int tryToKill(int color){ Ruleset ruleset=new Ruleset(); int killed=0; //return the number of killed stones ArrayList
group=new ArrayList<>(); boolean isDead; for(int i=0;i
So now, main loop will take the result when killing stones.
And now I have to pass as parameters the last board, number of killed stones in the last turn and the color to evaluate. So I changed the getPossibleMoves method:
public ArrayList
getPossibleMoves(Board mainBoard,Board lastBoard, int captured,int color){ //This method returns all the possible places to put a stone ArrayList
posibleMoves=new ArrayList<>(); boolean possibleMove=false; boolean koMove; for(int i=0;i
Now I know that the engine should send more parameters to the getPossibleMoves method of the ruleset:
public int play(Board board,Board lastBoard, int captured,int color){ int move; ArrayList
posibleMoves; ArrayList
group; Ruleset ruleset=new Ruleset(); //group=this.getGroups(board,1); this.getGroups(board, 1); this.getGroups(board, 2); posibleMoves=ruleset.getPossibleMoves(board,lastBoard,captured,color); move=makeMove(posibleMoves); return move; }
So, last thing to show is the "isKo" method, that returns true if the move is a ko and false if it is not:
public boolean isKo(Board board, Board lastBoard,int move,int color){ //This method will tell if there is a board repetition //to verify ko. //first play te move boolean isEqual=true; board.setMove(move, color); if(color==1){ board.tryToKill(2); }else{ board.tryToKill(1); } //now compare for(int i=0;i
Next: I know I should start with suicide rule, but... I want to see it on a better graphic interface so I will work on GTP and loging.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment