OT: Tic Tac Toe

JOLTRON

Lifetime Supporting Member
Join Date
Aug 2006
Location
MI
Posts
692
So the community college I went to is trying to get people to notice there Automation/IT department a little more. They decided they want to build a station where either 2 people or 1 person can play tic tac toe VS. a robot. I've been researching Tic Tac Toe quite a bit and I know there are alot of different out comes. I know it's kinda out there but was wondering if anyone has a program for Tic Tac Toe for any AB micrologix or SLC's or even siemens and I could do some translating. On this forum I have found the one for the tele, and all over the net you can find them for C, C+, Basic. But anyways it would save me some time. If not no worries I'll start from scratch. Idealy I would like for the robot to never lose when in hard mode. :)

Thanks,
 
basically whoever plays first has only three possible choices ... move to a corner ... move to the center of an edge ... or move to the middle ...

if I remember correctly (yes, it's been awhile) the corner is the square you want ... that way you're guaranteed either a win - or at least a draw ...

I set one of these up years ago when I worked as a lab technician at a tech school ... the signal to "GO" was to place a sucker stick into a little receptacle - where it tripped a microswitch ... the blocks were metal and shorted electrical contacts in the board ... when the robot won (or drew) it would pick up the sucker - and drop it back into a little plastic bucket nearby ...

we could switch it into "easy" mode - which would give the sucker to the player when they played to a tie ...

kids loved it ...

I'll give you the code if someone hasn't posted it before I can dig it out of my archives ...

PS Edit ... make sure you provide a "stop" signal when some clown tries to cheat ... people will move the blocks around - which can crash the robot if it tries to move to an occupied square ...
 
Haven't you seen the movie WARGAMES? Programming a computer to "never lose" at tic-tac-toe is a very bad idea! (and will ultimately lead to thermo nuclear war)
 
Haven't you seen the movie WARGAMES? Programming a computer to "never lose" at tic-tac-toe is a very bad idea! (and will ultimately lead to thermo nuclear war)

No no no! That's what saved the planet. It realized when playing tic-tac-toe against itself that there was no way to win. It extrapolated this bit of information and put it into the context of a thermonuclear war and realized the only way to win was to not play. Tic-tac-toe = good.

Brian
 
WOW...Haven't seen that in a long time. I think they even made a crappy sequel or remake of that movie.

As far as a stop signal for people trying to cheat.... The entier thing will be enclosed so we will just have to worry about someone thinking they are playing pinball and using the BUMP/TILT!!! feature :)
 
Too many people know Tic Tac Toe -- NIM would be better

http://en.wikipedia.org/wiki/Nim

We used to play that at summer camp for hours since it only required a pile of rocks on a pick nick table. I knew the trick and was unbeatable for the first few days. Then someone figured out the right combinations without figuring out the trick. I made things more difficult by adding more rocks to the three piles and eventually added a fourth pile to make things more difficult so I could win again. I just started to add a few rocks at a time. It kept the rest of the campers busy for hours playing each other. Most were clueless.

Nim should be easy to program but it may take a little I/O unless you are using an HMI.
 
if I remember correctly (yes, it's been awhile) the corner is the square you want ... that way you're guaranteed either a win - or at least a draw ...



Not really. You can start on any square and force a draw.
Your opponent can start on any square and you can still force a draw.

Tic-Tac-Toe cannot be won, nor lost. Not when played among equals. (yes, there are exceptions......... 🤾 )


And Nim is an awesome game. Never knew the name, but played it quite a bit.
 
Not really. You can start on any square and force a draw.
Your opponent can start on any square and you can still force a draw.

Tic-Tac-Toe cannot be won, nor lost. Not when played among equals.
Might be wrong but I think if you start on any corner and the opponent doesnt put in the middle on the next go you win every time,
at least thats the way I remember play in the school bus window condensation!
 
Tic-Tac-Toe always results in a draw when properly played

That is why it is so boring.
NIM results in a win for the first player unless the starting combination of stones is wrong. When it is the other persons turn to go first you set up the stones so that the combination of stones is wrong so the other person can't win on the first move.

If you ask who goes first and the computer can pick the combinations of stones, the computer should always win.

If you want to play fair the combination of stones should be set up so that the human can always win if he has the first move given he makes the right move. If the computer has the first move then it should start with a bad combination of stones so that the human has a chance given he makes the right move.
 
sorry ... obviously I wasn't clear enough ... the "kids" that this thing was intended for were in the elementary school range ... the objective wasn't to provide a stimulating mental challenge - just something to make the robot move around ...

for those (precious few) who expressed an interest, we had the ability to display the program as it ran ... it was intentionally set up in a very simple IF-THEN-ELSE construction that could be easily explained even to someone with ZERO programming knowledge ...

the objective wasn't to "teach" - only to generate an interest ... it served its purpose ...

be prepared for the inevitable observation: "who wants to play tic-tac-toe with a stupid robot - when I've got 'real' video games built into my cell phone?" ...
 
OK
Has anybody provided the games like tic-tac-toe, Nim etc on HMI for the operators to play??

I think I need to know the trick for winning Nim. I lost all the games when playing Nim over here.
 
Last edited:
I will have to look into the nim game. But they will end up sticking with tic tac toe I'm pretty sure. Only 4 months to program and build the entire working cell. I've just been helping along with the programming end of it. So far I have close to a working program but so far it is very predictable as in if PLC goes 1st then choose upper left corner, then player move, then if plc second move and lower right open pick that spot otherwise pick lower left. In the long run I would like something a little more adaptive.

Didn't read too much on NIM but sounds kinda similar to mancala.
 

Similar Topics

I've spend this weekend writing a demo for a touch screen interface. I've implemented a tic tac toe game using as a starting point a very nice...
Replies
9
Views
6,635
Hi, is there a way to change the time and date in the plc so they appear right in the diagnostic buffer. Also am I right in thinking the error is...
Replies
1
Views
32
HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
63
Hi, The hardware is: Click Plc model # CO-O1DD1-O HMI model # S3ML-R magnetic-inductive flow meter model # FMM100-1001. I will set the flow meter...
Replies
4
Views
117
Hello, I need to create an automatic transfer panel that connects to the generator when the mains power is cut. I can draw up to 60kW and draw up...
Replies
0
Views
78
Back
Top Bottom