Page 1 of 1
HELP
Posted: Fri Sep 29, 2006 3:16 pm
by jd100293
I cant Reach my post Tic tac toe i need help but i could use some help with the base cod i have the ai players down thankyou.
Re: HELP
Posted: Thu Oct 05, 2006 6:30 am
by deleted-71552
jd100293 wrote:I cant Reach my post Tic tac toe i need help but i could use some help with the base cod i have the ai players down thankyou.
Hi, jd100293!
What is your question? We'd like to help.
Thanks.
thank you
Posted: Fri Oct 06, 2006 5:51 am
by jd100293
I have a new question i can't get the square clicked functoin to work when i type in this code fragmet as listed in the instructions
if(xTurn)
{
numMoves++;
square.value = 'X';
xTurn = false;
status.innerHTML = 'O\'s turn';
}
else
{
numMoves++;
square.value = 'O';
xTurn = true;
status.innerHTML = 'X\'s turn';
}
please help my project is due 10-16-06
Re: thank you
Posted: Fri Oct 06, 2006 8:03 am
by deleted-71552
jd100293 wrote:I have a new question i can't get the square clicked functoin to work when i type in this code fragmet as listed in the instructions
if(xTurn)
{
numMoves++;
square.value = 'X';
xTurn = false;
status.innerHTML = 'O\'s turn';
}
else
{
numMoves++;
square.value = 'O';
xTurn = true;
status.innerHTML = 'X\'s turn';
}
please help my project is due 10-16-06
Could you please describe the failure that you see? What happens? Does it fail to compile? Does it fail to run? Does the program fail to operate the way you expect? What are the steps required to cause the problem to occur?
Posted: Sat Oct 07, 2006 5:03 am
by jd100293
When i put in that peice it stops putting in an x or an o when i click the box
Posted: Mon Oct 09, 2006 8:05 am
by deleted-71552
jd100293 wrote:When i put in that peice it stops putting in an x or an o when i click the box
Hi, jd100293!
One technique I have used successfully to debug this kind of problem is to have a pint-out of the code and "step" through the code manually myself. I like using a print out so that I can write down intermediate values and so on.
A second technique that I have used many times is to insert print statements between every line of code. For example, in the code snippet that you provided, I might do something like this:
if(xTurn)
{
<print a message that xTurn was true>
numMoves++;
<print a message that displays the new value of numMoves>
square.value = 'X';
<print a message that says square.value set to 'X'>
xTurn = false;
<print a message that says xTurn is now false>
status.innerHTML = 'O\'s turn';
<print a message that says it's O's turn next>
}
I don't see any problems in the code you have provided, so the place where the code is stopping is probably outside of this if-then-else block. You may need to examine the code around this one and insert print statements there.
thank you
Posted: Mon Oct 09, 2006 3:09 pm
by jd100293
The program still won't work. I know this sounds bad but could i maby have a source code for the base program

.
Re: thank you
Posted: Tue Oct 10, 2006 5:22 am
by deleted-71552
jd100293 wrote:The program still won't work. I know this sounds bad but could i maby have a source code for the base program

.
Hello, jd100293!
Don't give up! One of the best ways to improve as a software developer is to learn by doing. What steps have you taken to try to debug your program? Did you step through using a print out? If there are logic errors, stepping through with a print out will probably expose them. My guess is that there is at least one such error that is preventing your program from moving forward.
ScienceBuddies is here to help, but we aren't here to provide the base code. I am confident that you can fix this on your own with just a little help from us.
Posted: Wed Oct 11, 2006 3:17 pm
by jd100293
Thankyou!Thankyou!Thankyou!Thankyou!Thankyou!Thankyou!!!!
I used your debugging trick on the base code and it worked! Now all I need to do is get the AI players up! I have this in the square clicked function:
computerTurn = !computerTurn
if(computerTurn)
{
makeComputerMove();
}
But it's not working any hints?
Sorry I didn't reply yesterday, I was debugging.
Posted: Thu Oct 12, 2006 6:57 am
by deleted-71552
jd100293 wrote:Thankyou!Thankyou!Thankyou!Thankyou!Thankyou!Thankyou!!!!
I used your debugging trick on the base code and it worked! Now all I need to do is get the AI players up! I have this in the square clicked function:
computerTurn = !computerTurn
if(computerTurn)
{
makeComputerMove();
}
But it's not working any hints?
Sorry I didn't reply yesterday, I was debugging.
Hello, jd100293!
I am happy to learn that you have successfully debugged a part of your program! Bravo! You are well on your way to becoming a stellar software engineer!
As for this new problem, the same exact principles apply. For us to help you, we need more information than "It's not working." What is it doing or not doing? How do you see the failure? Is anything working at all? You haven't given us enough information on this new problem to help.
But the best outcome here would be for you to apply the new debugging techniques you've learned to this new problem. You can probably solve this on your own faster than we can help you. Use your newly-acquired debugging skills. (Use the Force, Luke! Ha!)
Posted: Thu Oct 12, 2006 7:35 am
by pgordon
jd100293 wrote:I used your debugging trick on the base code and it worked! Now all I need to do is get the AI players up! I have this in the square clicked function:
computerTurn = !computerTurn
if(computerTurn)
{
makeComputerMove();
}
But it's not working any hints?
I would first use your print statement trick to make sure the makeComputerMove() function is being called. Have you written the code yet that goes through the process of figuring out where the AI computer should play? If not I can post some introduction to AI links that will give you a general introduction to game theory and how you would program a rules scoring system. Good Luck.
Posted: Sat Oct 14, 2006 6:05 am
by jd100293
Where should
computerTurn = !computerTurn
//and
if(computerTurn)
{
makeComputerMove();
}
go? and could i have some help with ai stratigy?
also i need to get a recursive player up this weekend, my project is due 10/16!!!!!!!!

Posted: Sat Oct 14, 2006 6:10 am
by jd100293
how do i get logic gates up?

Posted: Sat Oct 14, 2006 7:58 pm
by deleted-71552
jd100293 wrote:Where should
computerTurn = !computerTurn
//and
if(computerTurn)
{
makeComputerMove();
}
go? and could i have some help with ai stratigy?
also i need to get a recursive player up this weekend, my project is due 10/16!!!!!!!!

Hello, jd100293!
I see that you are running short on time. It seems like computer programs are never ready ahead of time. It almost always takes last-minute hard work to finish! First rule: Don't panic. You've got to be able to think to get this done.
I don't know how your program has been designed, so I can't comment on how to change it. I assume that makeComputerMove() is the routine that selects a square for the computer to take. That's probably where the AI comes in, right? Here's a link to a page that talks about game theory and actually shows a bit of a break down of tic-tac-toe moves:
http://members.cox.net/mathmistakes/game_theory.htm
Your program must somehow keep track of what's been done so far and the AI code must choose the best next move. If you are building something for a human to play against, you must also provide a way for the human to input his or her move. Hopefully, these are parts you have already built.