AI contest: Connect four

This is a discussion on AI contest: Connect four within the Contests Board forums, part of the Community Boards category; Yeah, I think the biggest problem with having each AI play each other a thousand times is unless you specifically ...

  1. #16
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    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

  2. #17
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    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.)

  3. #18
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    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;
    }

  4. #19
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    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;
    }

  5. #20
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    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

  6. #21
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    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

  7. #22
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    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]
    Attached Files Attached Files
    Last edited by LuckY; 10-08-2004 at 03:20 PM.

  8. #23
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    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.

  9. #24
    Registered User
    Join Date
    Oct 2004
    Posts
    1
    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!

  10. #25
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    and can our code determine whether we're playing as "player 1" or "player 2"?
    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.

    BTW, how are you all doing?
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  11. #26
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    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 07:22 AM.

  12. #27
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    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.

  13. #28
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by vasanth
    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
    After the function has executed 500 milliseconds, a time penalty will be issued, depending on the amount of overtime.
    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.
    Quote Originally Posted by vasanth
    and the driver code has to check for invalid moves... since a rouge function can place its coin anywhere in the array and cheat..
    Yes, an invalid move will result in a lost game.
    Quote Originally Posted by PJYelton
    Ok, so no guarantee that 'X' moves first?
    No.
    Quote Originally Posted by PJYelton
    Also, can we assume that the players are always 'X' and 'O'?
    Yes.
    Quote Originally Posted by PJYelton
    My AI is more or less done, just in the process of tweaking the eval function a little bit to get the best results.
    Yes, the eval function is the crucial part.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  14. #29
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    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

  15. #30
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    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

Page 2 of 5 FirstFirst 12345 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Action Game - AI Contest
    By Queatrix in forum Contests Board
    Replies: 4
    Last Post: 01-18-2007, 06:55 PM
  2. New AI contest: sign up
    By Sang-drax in forum Contests Board
    Replies: 20
    Last Post: 07-27-2005, 06:54 PM
  3. chess ai contest
    By Raven Arkadon in forum Contests Board
    Replies: 7
    Last Post: 07-09-2005, 07:38 AM
  4. AI Contest Proposal
    By MadCow257 in forum Contests Board
    Replies: 4
    Last Post: 03-13-2005, 03:27 PM
  5. Game Design Topic #1 - AI Behavior
    By TechWins in forum Game Programming
    Replies: 13
    Last Post: 10-11-2002, 11:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21