C Board  

Go Back   C Board > Community Boards > Contests Board

Reply
 
LinkBack Thread Tools Display Modes
Old 10-04-2004, 01:30 PM   #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
PJYelton is offline   Reply With Quote
Old 10-06-2004, 09:14 PM   #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.)
Jeremy G is offline   Reply With Quote
Old 10-06-2004, 11:04 PM   #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;
}
PJYelton is offline   Reply With Quote
Old 10-08-2004, 11:25 AM   #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;
}
LuckY is offline   Reply With Quote
Old 10-08-2004, 11:46 AM   #20
C++ Developer
 
XSquared's Avatar
 
Join Date: Jun 2002
Location: UWaterloo
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
XSquared is offline   Reply With Quote
Old 10-08-2004, 12:05 PM   #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
PJYelton is offline   Reply With Quote
Old 10-08-2004, 01:24 PM   #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
File Type: zip C4-Lucky.zip (31.2 KB, 44 views)

Last edited by LuckY; 10-08-2004 at 02:20 PM.
LuckY is offline   Reply With Quote
Old 10-08-2004, 09:12 PM   #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.
okinrus is offline   Reply With Quote
Old 10-14-2004, 04:24 AM   #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!
goodvelo is offline   Reply With Quote
Old 10-14-2004, 04:57 AM   #25
and the hat of marbles
 
Sang-drax's Avatar
 
Join Date: May 2002
Location: Lund, Sweden
Posts: 2,041
Quote:
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
Sang-drax is offline   Reply With Quote
Old 10-14-2004, 06:14 AM   #26
Its not rocket science
 
vasanth's Avatar
 
Join Date: Jan 2002
Posts: 1,686
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..
__________________
http://www.geekpursuit.com

Last edited by vasanth; 10-14-2004 at 06:22 AM.
vasanth is offline   Reply With Quote
Old 10-14-2004, 11:33 AM   #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.
PJYelton is offline   Reply With Quote
Old 10-14-2004, 04:16 PM   #28
and the hat of marbles
 
Sang-drax's Avatar
 
Join Date: May 2002
Location: Lund, Sweden
Posts: 2,041
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
Sang-drax is offline   Reply With Quote
Old 10-14-2004, 04:19 PM   #29
and the hat of marbles
 
Sang-drax's Avatar
 
Join Date: May 2002
Location: Lund, Sweden
Posts: 2,041
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
Sang-drax is offline   Reply With Quote
Old 10-16-2004, 08:12 PM   #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
PJYelton is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Action Game - AI Contest Queatrix Contests Board 4 01-18-2007 06:55 PM
New AI contest: sign up Sang-drax Contests Board 20 07-27-2005 05:54 PM
chess ai contest Raven Arkadon Contests Board 7 07-09-2005 06:38 AM
AI Contest Proposal MadCow257 Contests Board 4 03-13-2005 03:27 PM
Game Design Topic #1 - AI Behavior TechWins Game Programming 13 10-11-2002 10:35 AM


All times are GMT -6. The time now is 09:46 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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