Re: AlphaBeta Implementation Programming Software Development by Labdabeta …is what I have in a header file called AlphaBeta.h: [CODE]#include <vector.h>…define INT_MAXVAL template <unsigned int ply> MoveScore AlphaBeta(GameState current, GamePlayer us, GamePlayer them, GameMove nullMove…i++) { current.execute(moves[i]); MoveScore tmp=AlphaBeta<ply-1>(current,them,us,nullMove,-high… AlphaBeta Implementation Programming Software Development by Labdabeta … been teaching myself algorithms and I am stuck with the AlphaBeta AI algorithm. I want to test my knowledge of it… Re: AlphaBeta Implementation Programming Software Development by tkud (1) Are you asking for advice concerning the AlphaBeta algorithm or (2)have you written code and you need help to progress further? If (2), post the code you have written so far(using code tags, of course).. If (1), get a good C++ book. Null being returned? Programming Software Development by Labdabeta I have this code for AlphaBeta implementation and have created versions of…<GameMove> getMoves(IGameState&)=0; }; MoveScore AlphaBeta(IGameState &current, IGamePlayer &us, IGamePlayer &… i++) { current.execute(moves[i]); MoveScore tmp=AlphaBeta(current,them,us,ply-1,-high,-low); current.undo… Re: Null being returned? Programming Software Development by Labdabeta …false; while (!board.gameOver()) { GameMove gm=AlphaBeta(board,(isX?x:o),(isX?o:x),9,r…lt;GameMove> getMoves(IGameState&)=0; }; MoveScore AlphaBeta(IGameState &current, IGamePlayer &us, IGamePlayer &…i++) { current.execute(moves[i]); MoveScore tmp=AlphaBeta(current,them,us,ply-1,r,-high,-low);… TicTacToe Evaluation function Programming Software Development by Labdabeta … abstract class: [CODE]class IAlphaBetaPlayer:public IGamePlayer { private: MoveScore AlphaBeta(IGameState &current, int ply, bool us, double alpha, …} } return best; } public: GameMove getMove(IGameState &g){ return AlphaBeta(g,ply(),true,-101.0,101.0).move; } virtual double… Re: TicTacToe Evaluation function Programming Software Development by Labdabeta …my code: [CODE]class IAlphaBetaPlayer:public IGamePlayer { protected: MoveScore AlphaBeta(IGameState &current, int ply, bool us, double alpha…return best; } public: virtual GameMove getMove(IGameState &g){ return AlphaBeta(*(g.clone()),ply(),true,-DBL_MAX,DBL_MAX).move; } virtual double evaluate… Re: Null being returned? Programming Software Development by raptr_dflo … there's no local version of it at all in AlphaBeta(). Assuming that's not the problem, have you at least… one of the structure memebers? E.g., [CODE] ... MoveScore ms = AlphaBeta(board, (isX?x:o), (isX?o:x), 9); GameMove gm… Re: TicTacToe Evaluation function Programming Software Development by Labdabeta Also I have tried analysing the score part of the AlphaBeta function in my debugger and it always seems to return either 0, -0, or 100, but no values in between (this is in the getMove() function) I have not fully stepped through AlphaBeta itself because the iterative recursion makes it take for ever! Re: Null being returned? Programming Software Development by daviddoria I suggest simplying your entire code to about the same length as you have posted. You don't show us any non-virtual classes, and you don't show how AlphaBeta is constructed. Re: Null being returned? Programming Software Development by Labdabeta …); bool isX=true; while (!board.gameOver()) { board.output(); GameMove gm=AlphaBeta(board,(isX?x:o),(isX?o:x),9).move; board… Re: Null being returned? Programming Software Development by Labdabeta I have tried that and I have tried saving the return value into a local variable before accessing any members. I have even tried converting the code to Java (which has a simpler inheritance structure) but no matter what AlphaBeta returns 'real' values up until the final 'unwind' at which point it returns null. I cannot figure this out! Re: Null being returned? Programming Software Development by raptr_dflo Hmmmm. In your call to AlphaBeta() from main(), in the while (!board.gameOver()) {} loop, do you … Re: Null being returned? Programming Software Development by Labdabeta … than 0 in my outer (first-non-recursive) call of alphabeta. I just cannot figure out a way to debug that… Re: Null being returned? Programming Software Development by raptr_dflo Try filling 8 of the 9 spaces on the board, in such a way that neither player has won already, and then call AlphaBeta() with ply=1? Re: TicTacToe Evaluation function Programming Software Development by Labdabeta I have implemented another evaluator, but I am having the trouble that AlphaBeta is returning a score of zero consistently until the final move. I cannot figure out why?! Re: TicTacToe Evaluation function Programming Software Development by Labdabeta I really cannot see what is wrong... the evaluator seems functional but I tried looking at the alphabeta algorithm and it seems to be working incorrectly. I really need this program to work. Problem with 2-d Character Array Programming Software Development by anu07 …;choice[1]; getch(); }[/CODE] But this is what comes: [ICODE]alphabeta beta[/ICODE] Can anyone tell me what I did wrong… Re: Inheritance Problems Programming Software Development by Labdabeta … }; template <unsigned int ply> MoveScore AlphaBeta(GameState &current, GamePlayer &us, GamePlayer &…++) { current.execute(moves[i]); MoveScore tmp=AlphaBeta<ply-1>(current,them,us,-high,-…lt;board.output(); if (isX) board.execute(AlphaBeta(board,x,o).move);//here an error else… Re: NetBeans GUI Java Tic Tac Toe Programming Software Development by adams161 … looks like, [url]http://www.ocf.berkeley.edu/~yosenl/extras/alphabeta/alphabeta.html[/url] you will just need the min max part… Re: Alpha Beta Pruning Search Algorithm Programming Computer Science by philmetz cool, i also found this so incase anyone was as confused as me, check this out: [url]http://www.cs.ucla.edu/~rosen/161/notes/alphabeta.html[/url] Re: Inheritance Problems Programming Software Development by Labdabeta I figured it out. Facepalm kind of situation. AlphaBeta is a template function. I never specified the ply! Re: Null being returned? Programming Software Development by Labdabeta This doesnt make sense. I have debugged this program countless times, as far as I can tell the value of best is always legit until the function returns! What is wrong?! Re: Null being returned? Programming Software Development by Labdabeta I figured it out! I made the mistake of creating my code from pseudo-code. When I initialize best I should set it's score to -infinity, not to 0. Re: TicTacToe Evaluation function Programming Software Development by WaltP [QUOTE=Labdabeta;]I have an alpha beta interface and have implemented a tic tac toe class from it. For some reason my AI tends to occasionally make stupid moves (such as making a fork rather than blocking a 2 in a row) I was wondering if anybody can see where I went wrong: ... I really cannot see why it is that my TicTacToe AI that usually … Re: TicTacToe Evaluation function Programming Software Development by Labdabeta Sorry about my ambiguity. I think (but I am not sure) that the problem is in the evaluation function or in the implementation of my alpha beta algorithm. Here is an example of a game I played against it (I am 'O'): X-- --- --- Perfect 1st move for Tic Tac Toe! X-- -O- --- A fair counter-attack that can ensure a tie X-- -O- --X Excellent … Re: TicTacToe Evaluation function Programming Software Development by nezachem [QUOTE] X-- --- --- Perfect 1st move for Tic Tac Toe![/QUOTE] To begin with, I wouldn't call it perfect. Now, if you are sure that the alpha-beta works correctly (I didn't bother to check), then the problem must be in a statical evaluation. And it is there indeed. Hint: pay attention to the compiler warnings. Re: TicTacToe Evaluation function Programming Software Development by Labdabeta Ok, I improved it a bit (noticed a few other problems too, along with your suggestion) here is the resulting class: [CODE]class StaticTicTacToe:public IAlphaBetaPlayer { private: bool isX; LABRandom r; public: StaticTicTacToe(bool isX):isX(isX),r(){} virtual double evaluate(IGameState &gs) { if (gs.ID()!=… Re: TicTacToe Evaluation function Programming Software Development by nezachem [QUOTE]What is my program thinking?[/QUOTE] I have no idea. You need to debug. For that, I'd recommend to provide an ability to call evaluate() directly with any given position. Call it with [QUOTE]XXO -O- -X-[/QUOTE] and [QUOTE]XXO -O- X--[/QUOTE] See which one gets better score. If the first one scores better, the error is in evaluate(). … Re: TicTacToe Evaluation function Programming Software Development by Labdabeta I tried your suggestion and it does seem like some of the bad moves are getting better scores. I just can't think of a better evaluator, do you have any ideas? Also why is the code that is commented out not working (its causing a sigseg)?