Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with Turing Tic Tac Toe?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MrSir




PostPosted: Fri Jun 03, 2011 6:23 pm   Post subject: Help with Turing Tic Tac Toe?

Im trying to build a Turing Tic Tac Toe game with Turing using simple language. I cant seem to figure out how to make it so that you can't click on or choose a space that's already occupied. Also Im not too sure on how to recognize a winner.

You dont need to write a code for me, I just want to know how to do this.

Thanks

Also, Im new to Turing so I only know simple language. Ive seen some codes online with stuff like procedure or array and stuff like that and I dont really know those.
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Fri Jun 03, 2011 7:51 pm   Post subject: RE:Help with Turing Tic Tac Toe?

You don't need to prevent players from clicking on occupied spaces. You need to determine when a click falls into an occupied space, and if it does you just don't "play" the move it would have been; you wait for the player to make a valid move.

It looks something like this:

code:

loop
    % check mouse details
   
    if player clicked then
        if click position has NOT been used then
            mark the board at (click position) with the player's mark
            exit loop    % important!
        end if
    end if
end loop


So you can see that, as soon as the player clicks in a valid position, we mark the board and exit the loop (presumably, another loop outside this one controls which player is in control, etc). If the player clicks in a "taken" position, or hasn't clicked yet, we keep looping.
MrSir




PostPosted: Fri Jun 03, 2011 9:55 pm   Post subject: RE:Help with Turing Tic Tac Toe?

Ive figured out what to do for the same space thing, but I still dont know how to detect the winner
Tony




PostPosted: Fri Jun 03, 2011 10:10 pm   Post subject: RE:Help with Turing Tic Tac Toe?

How would you decide if someone has won, if you were to play this game on paper? Describe the specific steps, and when you would take them.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
MrSir




PostPosted: Fri Jun 03, 2011 10:20 pm   Post subject: RE:Help with Turing Tic Tac Toe?

I'm guessing you're saying that for me to think about it myself. You win when you get 3 in a row.

I tried doing on the Computer by setting a numerical value to a certain box and calculate the "winning" values when added. But I've realized that it would almost be impossible to do this, because there's simply too many possibilities.

Any hints?
MrSir




PostPosted: Fri Jun 03, 2011 10:29 pm   Post subject: RE:Help with Turing Tic Tac Toe?

I've thought about it again and another solution is to give each row and horizontal a value.

So, it might be like
1 1 1
2 2 2
3 3 3

And when move 1, move 2 and move 3 are both 1's you win, etc.

Of course you would need to do this with vertical as well. Is this right or is there an easier way?
Tony




PostPosted: Fri Jun 03, 2011 10:52 pm   Post subject: Re: RE:Help with Turing Tic Tac Toe?

Arrays make things easier, in a way that you can generalize things. You'd just need to write code to check one line; then you can put it in a loop, and the loop would go over all the lines. Done! But then you'd need to learn about arrays first, so that's a trade-off.

MrSir @ Fri Jun 03, 2011 10:20 pm wrote:
by setting a numerical value to a certain box and calculate the "winning" values when added. But I've realized that it would almost be impossible to do this, because there's simply too many possibilities.

Any hints?

This is actually a rather novel approach, so I've got two hints for you:
- you'll have a lot more luck if all the values are primes, and you are multiplying them, instead of adding. There's a particular property in integer (prime) factorization that will be very useful to you.
- there are not "too many" ways to win on a standard 3x3 board. In fact, there are very few -- 8 for each player.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
MrSir




PostPosted: Fri Jun 03, 2011 11:00 pm   Post subject: RE:Help with Turing Tic Tac Toe?

I havent learned array and I cant seem to understand when reading the reference.

Thanks though
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Jun 03, 2011 11:11 pm   Post subject: RE:Help with Turing Tic Tac Toe?

Tutorials in The Turing Walkthrough are probably a better starting point than the help-file specs.

Or you could see if you can figure out the math for this other approach discussed.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
MrSir




PostPosted: Fri Jun 03, 2011 11:21 pm   Post subject: RE:Help with Turing Tic Tac Toe?

Well Im already 3/4 finished and I doubt Ill be taking a computer course again so learning it would be pretty useless at this point.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: