Gurudas Bhandarkar wrote:@Fred
I took a look.
I will work it out as you said, alpha-beta should work the same in any game no matter its chess, connect4 or any other.
So just a query, why can't we just copy paste your code that you used for chess(of course if you permit).
Also please provide me with the suggestions so as to how can I transform this into a gomoku, or I can modify the grid and the shape into gomoku variant so that even I would learn.
and then you can correct me if I go wrong, would this be alright?
Gurudas Bhandarkar wrote:It was just a query from my side, never tried to emphasize i apologize if I may have sounded
that way.
Coming back to themain game called gomoku,
I modified your GameBoard class
...
Gurudas Bhandarkar wrote:Just help me out in locating the variable which is used to refer the maximum search depth and
also the depth counter.
private int findBestMove(Move[] mList) {
int maxEval = mList[0].eval; // Here it will always compare with the mList[0] eval,
//even when there is 1st or second iteration and so on. I don't know what exactly is to be
//written but do think that this is what is causing problem.
int maxIndex = 0;
Move m;
for (int i = 1; i < mList.length; i++) {
if (mList[i].eval > maxEval) {
maxEval = mList[i].eval;
maxIndex = i;
}
}
return maxIndex;
}
Gurudas Bhandarkar wrote:But in that case, this logic could not be applied in games where search space is very huge,
like chess or checkers and in this case its gomoku( later on trying to modify tic tac toe).
even if its played on 13x13 board, the complexity is of 10^70.
and tic-tac-toe is of 9!.
So I guess a universal strategy of implementing this for any game would be better.
I don't know if I have explained properly, but changing this every time for new game seems to be difficult.
Gurudas Bhandarkar wrote:
Also the eval signs had to be changed ass for X it is 1 and for O it is -1.
But in engine class it is declared 1 for both x and o.
So what should be done now?
Anyways just a question, in what field you have done your education?
I started liking Java after doing introductory course in it.
But I am undergraduate student of electronics. If I have to make career in Java, what should I do?
Gurudas Bhandarkar wrote:I have just the idea for it,
maybe we can increase the value for eval on the next move.
the program, finds the winning move in 3, and in 1 now it can win in 1 or in 3, still it prefers the win in 3.
so something like eval=(maxdepth-currdepth) so eval for 3 will be less than that of eval for 1.
so it will take the value when there is win for one.
I don't know how to code this.
Also do you mind to repost all the classes which were modified?
also let me know how did you learn program basic in java and then programing AI in java, which books did you refer to.
Gurudas Bhandarkar wrote:i guess the computer is taking long route to win because in the above program,
it searches for the entire game tree. So at a time its taking only one way to win
(need not be the immediate win).
It will search through the entire game tree and as of now, depth now is maximum.
i.e 9 so it will search first for win in 9 then after the first move,
depth reduces to 8 and then to 7 and so on.
so if it finds win in 3(after 6 moves),
then it will not bother to see immediate win,
because it knows that its going to win in next 3 moves by force.
Now the AI calculates step by step. So as it sees first if there is win for opponent,
it will block it.
Suppose human has win in 1, then it will block the square ,
if human has chance in 2, then blocking the required squares.
So coming back to why AI doesn't go for immediate win,
my reason would be that if it is sure that it has win on final move,
it will still follow the same path ignoring even if there is win is 1.
Gurudas Bhandarkar wrote:@ Fred
Thanks a million.
But I guess that I can approach you for any help required for gomuko, only if you permit.
Gurudas Bhandarkar wrote:@Fred
I am having a hard time in writing evaluation function of gomuko.
I thought that othello and reversi might be more difficult to write.
well do you any idea how can write the evaluate function? (ofcourse I cant ask for more as you have done a lot for me, but if you find time then I would like to discuss this with you.)
Gurudas Bhandarkar wrote:Exactly I tried to do the same but I am stuck up with the String methods.
Gurudas Bhandarkar wrote:Hey it was a mistake on my part as I posted the wrong code.
Actually I implemented you Grid code but the thing is I sent you the wrong code.
I am really sorry for that and hope you are not angry off by my foolish mistake.
Consider Paul's rocket mass heater. |