Tic Tac Toe Artificial Intelligence

Ask questions about projects relating to: computer science or pure mathematics (such as probability, statistics, geometry, etc...).

Moderators: AmyCowen, kgudger, bfinio, MadelineB, Moderators

Locked
Jumendez
Posts: 1
Joined: Sun Mar 01, 2009 1:47 pm
Occupation: Student
Project Question: Tic Tac Toe Artificial Intelligence
Project Due Date: 3/2/09
Project Status: I am conducting my experiment

Tic Tac Toe Artificial Intelligence

Post by Jumendez »

At this point I'm skrewed.
When I started this project, I thought that the experiment was to just make the 2 player game, so when I saw all the codes were given I thought this was going to be easy.
Then two days ago, after I had that part of the project done for a week I noticed the Experimental Procedures section, and my life has been a mess since.
Something that hasn't helped was that I was so naive to not even do the recommended things before this, and wasn't even fluent in JavaScript. So I've been running through trial and error, and all I've gotton is error.
I'm unable to make the function makeComputerMove() make a button change its value to O, so could someone please help me.
amyc
Site Admin
Posts: 1130
Joined: Mon Dec 15, 2008 3:38 pm
Occupation: Science Buddies
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Re: Tic Tac Toe Artificial Intelligence

Post by amyc »

To assist experts who might address your questions, I'm posting a link here to the Science Buddies project idea:

https://www.sciencebuddies.org/science- ... p014.shtml

I'm sure experts will need to know what you've done so far (what your script looks like) for makeComputerMove();

If you can post the code you have written here, it will help with troubleshooting.

Amy
Science Buddies
Craig_Bridge
Former Expert
Posts: 1297
Joined: Mon Oct 16, 2006 11:47 am

Re: Tic Tac Toe Artificial Intelligence

Post by Craig_Bridge »

If you have a working two player game that uses "squareclicked(square)" to change a square's value, your makeComputerMove simply has to figure out the correct square and call squareclicked( <somebuttonobject> ) that looks like the project examples. I suspect that the button object needed <somebuttonobject> will be obtained something like "document.getElementById('2_0')" which you might look more like "document.getElementById(x + '_' + y)". If it is the computer's turn, then xTurn will be true if the computer is playing "X" or false if it is playing "O". If the computer wants to take square x,y it needs to call squareclicked(document.getElementById(x + '_' + y)). BEWARE: I'm not a javaScript expert so I might not have precisely the correct syntax; however, looking at what the project already gave you, it looks like what I gave you is close. The whole point of attempting to program something is figuring out how to try to accomplish something then trying to figure out how to tell the computer to do it and then figuring out how to tell if the computer is doing what you wanted it to do in all cases.
-Craig
Locked

Return to “Grades 6-8: Math and Computer Science”