Yeah, I think the biggest problem with having each AI play each other a thousand times is unless you specifically code it to learn you'd just end up with hundreds of identical games
Yeah, I think the biggest problem with having each AI play each other a thousand times is unless you specifically code it to learn you'd just end up with hundreds of identical games
I dunno, but the gamefiles seem to be missing the actual main function that handles the running of the game... Can we get the working game in full? It would help me out a bit.
c++->visualc++->directx->opengl->c++;
(it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)
I just made a stupid little driver to test out the boards functionality, you're welcome to use it.
Code:int main() { Board myBoard; printBoard(myBoard); int z; while (1) { do { cin>>z; }while (!myBoard.canMove(z)); myBoard.move(z, 'X'); printBoard(myBoard); if (myBoard.checkWin()!=' ') break; do { cin>>z; }while (!myBoard.canMove(z)); myBoard.move(z, 'O'); printBoard(myBoard); if (myBoard.checkWin()!=' ') break; } cout<<"Winner!"<<endl; cout<<"Testing at function. The character at spot 4,1 is a \'"<<myBoard.at(4, 1)<<"\'"<<endl; return 0; }
Here's mine. No manual entry except an enter between moves so I can see how good the AI is at defeating itself.
Code:static const char PLAYER1 = 'X'; static const char PLAYER2 = 'O'; int main() { srand(time(0)); Board board; char turn = PLAYER1; while (true) { int move = <<your namespace here>>::getMove(board, turn); if (!board.canMove(move)) { std::cout << "* OUT OF COLUMNS *\n"; break; } board.move(move, turn); printBoard(board); std::cout << turn << " went in column " << move << std::endl; if (board.checkWin() != ' ') { std::cout << turn << " WON THE GAME!\n"; break; } std::cin.get(); turn = turn == PLAYER1 ? PLAYER2 : PLAYER1; } return 0; }
The only problem is that Connect 4 has been solved. So basically, the second player can always induce at least a draw in every game.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
Actually thats not true. It HAS been solved but it has been proven to be a win for player 1, not a draw. But coding your AI to implement all of the ideas necessary to win every time as player 1 is a completely different thing and my hats off to anyone here who can do it
I was just thinking about it and a nice Win32 app would be a lot nicer to look at than that ugly console program, so I threw together a quick, dirty Connect4 game. The source is attached. Just go into the file YOURDATA.h and replace the defines (they specify your getMove() function and your header file). Then stick your header in the project directory and compile. You can make each move yourself by clicking on the column or click the "Let AI Move" button to let your AI do its job.
Tell me what you think and do what you want with the code. If you make any changes I'd love to see them.
[edit]
I just change the code a tad to allow you to define two different getMove() functions for player 1 and player 2.
[/edit]
Last edited by LuckY; 10-08-2004 at 02:20 PM.
Victor Allis solved connect four for white. But I suspect that for me to understand his thesis and search techniques will take more than a month.
Hi All,
My C++ is very rusty, but I hope to submit an entry. FYI, I'm a C.S. grad., LabVIEW programmer, and also using [pirated] MSVC 6.0.
Regarding previous post:
> Victor Allis solved connect four for white
does "player 1" = "white"?
and can our code determine whether we're playing as "player 1" or "player 2"?
Cheers!
You only know what the board look like and what player you are. By counting the number of pieces on the board it's possible to determine whether you started the game or not, whatever you need that information for.and can our code determine whether we're playing as "player 1" or "player 2"?
BTW, how are you all doing?
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
ok count me in....... sounds intresting..
And wahst the maximum time my function can take to make a move... So that I can limit the depth of search trees.... thanx in advance
and the driver code has to check for invalid moves... since a rouge function can place its coin anywhere in the array and cheat..
Last edited by vasanth; 10-14-2004 at 06:22 AM.
Ok, so no guarantee that 'X' moves first? Also, can we assume that the players are always 'X' and 'O'?
My AI is more or less done, just in the process of tweaking the eval function a little bit to get the best results.
After the function has executed 500 milliseconds, a time penalty will be issued, depending on the amount of overtime.Originally Posted by vasanth
My current computer is 450 MHz, but I will hopefully have a new laptop when the judging begins.
You could make the depth easily changable, so I can decrease it if the function takes too long.
Yes, an invalid move will result in a lost game.Originally Posted by vasanth
No.Originally Posted by PJYelton
Yes.Originally Posted by PJYelton
Yes, the eval function is the crucial part.Originally Posted by PJYelton
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
I will begin working on the judging program next week, when I have some more time. It won't be anything that advanced.
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
Just out of curiosity, is there a particular reason we can't just assume 'X' is going first? Seems like a pointless addition of time to our algorithm to have to figure out who moved first especially when you consider we are being graded on time.
No biggee though, just wondering if there was a reason