HELP

Ask questions about projects relating to: computer science or pure mathematics (such as probability, statistics, geometry, etc...).
Locked
jd100293
Posts: 12
Joined: Sat Sep 02, 2006 7:03 am

HELP

Post 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.
OneBriiguy
Former Expert
Posts: 159
Joined: Fri Sep 30, 2005 6:31 am
Occupation: Engineer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Re: HELP

Post by OneBriiguy »

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.
Brian Castelli (OneBriiguy)
Engineering Specialist
jd100293
Posts: 12
Joined: Sat Sep 02, 2006 7:03 am

thank you

Post 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
OneBriiguy
Former Expert
Posts: 159
Joined: Fri Sep 30, 2005 6:31 am
Occupation: Engineer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Re: thank you

Post by OneBriiguy »

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?
Brian Castelli (OneBriiguy)
Engineering Specialist
jd100293
Posts: 12
Joined: Sat Sep 02, 2006 7:03 am

Post by jd100293 »

When i put in that peice it stops putting in an x or an o when i click the box
OneBriiguy
Former Expert
Posts: 159
Joined: Fri Sep 30, 2005 6:31 am
Occupation: Engineer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Post by OneBriiguy »

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.
Brian Castelli (OneBriiguy)
Engineering Specialist
jd100293
Posts: 12
Joined: Sat Sep 02, 2006 7:03 am

thank you

Post 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 :oops:.
OneBriiguy
Former Expert
Posts: 159
Joined: Fri Sep 30, 2005 6:31 am
Occupation: Engineer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Re: thank you

Post by OneBriiguy »

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 :oops:.
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.
Brian Castelli (OneBriiguy)
Engineering Specialist
jd100293
Posts: 12
Joined: Sat Sep 02, 2006 7:03 am

Post 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.
OneBriiguy
Former Expert
Posts: 159
Joined: Fri Sep 30, 2005 6:31 am
Occupation: Engineer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Post by OneBriiguy »

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!)
Brian Castelli (OneBriiguy)
Engineering Specialist
pgordon
Posts: 8
Joined: Tue Sep 26, 2006 6:28 pm

Post 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.
Paul Gordon
Software Engineer
Symantec
jd100293
Posts: 12
Joined: Sat Sep 02, 2006 7:03 am

Post 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!!!!!!!! :shock:
jd100293
Posts: 12
Joined: Sat Sep 02, 2006 7:03 am

Post by jd100293 »

how do i get logic gates up? :?:
OneBriiguy
Former Expert
Posts: 159
Joined: Fri Sep 30, 2005 6:31 am
Occupation: Engineer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Post by OneBriiguy »

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!!!!!!!! :shock:
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.
Brian Castelli (OneBriiguy)
Engineering Specialist
Locked

Return to “Math & Computer Science Sponsored by Hyperion Solutions Corp”