help in alpha beta pruning
Can you please provide code for it, modified one. It will be better for me to understand
Please explain how to undo the move.
I have done with the break statement.
Do you know any forum which is active and helps other people and has many java users?
[Edited by - mandar9589 on August 4, 2009 10:06:21 AM]
I have done with the break statement.
double minmax(int player, int column,double a,double b) { double value=0,v=0; if(columnHeight[column]>=HEIGHT) return 0; recurDepth++; grid[column][columnHeight[column]]=player; columnHeight[column]++; if(fourInARow()>0) { if(player==2) value=MAX_RECURDEPTH+1-recurDepth; else value=-MAX_RECURDEPTH-1+recurDepth; } if(recurDepth<MAX_RECURDEPTH && value==0) { value=MAX_RECURDEPTH+1; for(int x=0; x<WIDTH; x++) { if(columnHeight[x]>=HEIGHT) continue; v=-minmax(3-player, x,-b,-a); if(value==(MAX_RECURDEPTH+1)) value=v; else if(player==2) { if(value>v) value=v; } else if (v>value) value=v; if(v>a) { a=v; } else if(a>=b) break; } } recurDepth--; columnHeight[column]--; grid[column][columnHeight[column]]=0; return value; }
Do you know any forum which is active and helps other people and has many java users?
[Edited by - mandar9589 on August 4, 2009 10:06:21 AM]
Quote: Original post by mandar9589
Please explain how to undo the move.
recurDepth--; columnHeight[column]--; grid[column][columnHeight[column]]=0;
Quote: Do you know any forum which is active and helps other people and has many java users?
No. I have no interest in Java whatsoever, so I wouldn't know if such a forum existed.
double minmax(int player, int column,double a,double b) { double value=0,v=0; if(columnHeight[column]>=HEIGHT) return 0; recurDepth++; grid[column][columnHeight[column]]=player; columnHeight[column]++; if(fourInARow()>0) { if(player==2) value=MAX_RECURDEPTH+1-recurDepth; else value=-MAX_RECURDEPTH-1+recurDepth; } if(recurDepth<MAX_RECURDEPTH && value==0) { value=MAX_RECURDEPTH+1; for(int x=0; x<WIDTH; x++) { if(columnHeight[x]>=HEIGHT) continue; v=-minmax(3-player, x,-b,-a); if(value==(MAX_RECURDEPTH+1)) value=v; else if(player==2) { if(value>v) value=v; } else if (v>value) value=v; if(v>a) { a=v; } else if(a>=b) break; } } recurDepth--; columnHeight[column]--; grid[column][columnHeight[column]]=0; return value; }
i did this but now it simply ignore win for other player.
Now you are mixing negamax code like
with non-negamax code like
Your "if - else if" logic is wrong as well.
At this point I will stop providing help. Learn how to use a debugger and try to figure things out yourself. You'll learn a ton more that way, and when you finally get it to work it will feel like a much more personal victory than if I sit here trying to patch your mistakes.
v=-minmax(3-player, x,-b,-a);
with non-negamax code like
else if(player==2) { if(value>v) value=v; } else if (v>value) value=v;
Your "if - else if" logic is wrong as well.
At this point I will stop providing help. Learn how to use a debugger and try to figure things out yourself. You'll learn a ton more that way, and when you finally get it to work it will feel like a much more personal victory than if I sit here trying to patch your mistakes.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement