Tic-Tac-Toe Implemented In Single Call To Printf()

[Nicholas Carlini] programmed a C implementation of two-player Tic Tac Toe, and he did it in a single call to printf(). The arguments for that single function call get mind-bendingly complex, so it may come as no surprise that it was written for The International Obfuscated C Code Contest (IOCCC).

Most of us are aware that printf() is one of those functions that is considerably more complex under the hood, and capable of far more, than it may appear to be. But did you know that it is capable of Turing-complete computation?

[Nicholas] clearly steps through the theory, so give it a read. In short, a maze of arguments handles the logic of the game while an embedded scanf() reads user input, and printing the game board is always preceded by an escape code to clear the screen.

[Nicholas] is certainly no stranger to in-depth understandings; we’ve seen his work before in demonstrating how to fool speech recognition with hidden commands, including a powerful example showing how two virtually identical-sounding audio files transcribe entirely differently.

Tic Tac Arduintoe Moves The Game To 4×4

We know you’re out there spending a lot more time with your loved ones, and appreciate that you may be running out of ways to keep everyone entertained. [Mukesh] dropped us a tip because he has the antidote to boredom — a new twist on that old chestnut, Tic Tac Toe.

Instead of the usual 3×3 configuration, [Mukesh] made the grid 4×4 so the game would be more engaging. Game play is otherwise the same — this Tic Tac Toe still results in a lot of draws, but they take longer and you can’t see them coming a mile away. What’s even more engaging is that you get to push clicky buttons that light up, and don’t have to draw a grid before every game.

Under the hood is an Arduino Uno that controls 16 push buttons and their corresponding RGB LEDs. Whoever goes first is blue, and player two gets pink. If you win, your color floods the board for a brief victory animation. If the game is a tie, the board turns red. We really like the printed two-piece buttons that house the LEDs and actuate the push buttons while keeping the two separate. Toe your way past the break to check out the build video.

Intrigued by the 4×4 version, but need a build that takes more time? Try building your TTT in TTL.

Continue reading “Tic Tac Arduintoe Moves The Game To 4×4”

Tic-Tac-Toe, In TTL

We’ll all be familiar with Tic-Tac-Toe, or Noughts and Crosses, a childhood pencil-and-paper diversion which has formed the basis of many a coding exercise. It’s an easy enough task to implement in software, but how many of us have seen it done in hardware alone? That’s just what [Warren Toomey] has done using TTL chips, and his method makes for a surprisingly simple circuit.

At its heart is an 8 kB ROM that contains precomputed move sequences that are selected via an address composed of the game states for both player and machine. A series of flip-flops control and buttons to make the board, and a 555 provides a clock.

The technique of using a ROM to replace complex logic is a very powerful one that is facilitated by the low price of relatively large devices that would once have been unaffordable. We’ve seen the technique used elsewhere, including as an ALU in a TTL CPU, and even for an entire CPU in its own right.

You can see the result in operation in the video below the break, and should you wish to have a go for yourself all the relevant information can be found in a GitHub repository.

Continue reading “Tic-Tac-Toe, In TTL”

North Street Labs Try To Spice Up A Game Of Tic-Tac-Toe

tic-tac-toe-stomp-box

The team at North Street Labs really went all out with this Tic-Tack-Toe stomp box. At its most basic it’s a blinky version of the simple two-player game. But there’s always some added appeal when you make large manifestations of normally small items; the 10x Arduino is a good example of this.

The project is NSL’s qualifying entry for this year’s Red Bull Creation Contest (has it already been a year since the last contest?). A special Arduino shield was produced once again, this time it features hardware necessary to control LED strips… a lot of them. That led to the creation of this box, which houses a ton of strip sections inside to light the grid based on tapping one of the red buttons with your foot. We’d image the game would be seldom used at your hackerspace, but they take it to show off at the local children’s museum and it’s a huge hit with the kids!

CNC Tic Tac Toe

cnc-tic-tac-toe

This computer controlled physical Tic Tac Toe game is built from parts scavenged from common consumer goods. Specifically, the sled is made up of a combination of printer and DVD drive parts.

The build is delightful, and you can’t move on to the next feature until you watch it play a game in the clip after the break. The game board can move along two axes. It’s obvious from the image above that the printer ink cartridge sled has been reused to let the board move left and right. But the DVD lens sled hidden under the board lets it move forward and back. The piece of protoboard seen on the left is an IR reflectance scanner. The board moves systematically under this sensor. Whenever a black square (placed by the human player) is in play it prevents the IR beam from reflecting back. What you can’t see in this image is the yellow disc dispenser which is just out of the frame. It uses the DVD disc tray motor to place the computer’s pieces. We think this build is just begging to be turned into a Turing Machine demonstration.

If you liked this one we’re sure you’ll also appreciate CNC chess.

Continue reading “CNC Tic Tac Toe”

Two-player Tic-Tac-Toe From Logic Chips

Here’s another entry in the 7400 Logic contest. [Circuitchef] used gates and a few flip-flops to build a two-player electronic Tic-Tac-Toe game. The full details or shared in the PDF file he links to in his post. We’ve also linked to it after the break in case the Dropbox he is using becomes unavailable.

He provides a nice block diagram which helps to understand the game’s design. The board is arranged in a 3×3 matrix of momentary push buttons and bi-color LEDs. Each player takes turns pushing the button in the square they’d like to claim. The input circuitry uses flip-flops to establish which player’s turn it is, illuminating the appropriate color for that square. A set of 3-input AND gates monitor all possible combinations of winning patterns. The outputs of those gates are OR’d down to just one output which is used to light up the ‘Winner’ LED with the right color. If all boxes are lit up and none of those combinations is satisfied the game is declared a draw. This can all be seen in the demo embedded below the fold.

Continue reading “Two-player Tic-Tac-Toe From Logic Chips”

Computer Learns From Tic-tac-toe

menace-tic-tac-toe-computer

MENACE, the Matchbox Educable Noughts And Crosses Engine, is a fancy name for a machine that plays Tic-Tac-Toe. The concept is a product of Professor [Donald Mitchie]’s work in the 1960’s and was featured as an example in the “A New THEORY of AWESOMENESS and MIRACLES” talk given at this year’s UK games conference.

[James Bridle] built this fascinating example of how a computational system can learn from its successes and failures. Each box corresponds to one of 304 different board layouts. The operator uses an index sheet to locate the box that corresponds to the current state, shakes the box, then looks to see which bean has randomly fallen into a partition in the box. The color/type of bean corresponds to a space that the machine has “chosen” for that move. If MENACE won the game a bead matching the move that was played would be added to each box used. If MENACE lost, a bead would be removed from each box used. This way the machine cannot make the exact same mistakes twice, and is more likely to repeat successful solutions.

[James] notes that he couldn’t find any evidence of this machine actually being built before. It is possible that this was always a theoretical device but now we’ve seen an actual build. We consider this to be a computer because it is calculating moves based on probability of success but what do you think? If you’re thirsting for more pictures there’s plenty to see in the Flickr set he’s posted.

[via BoingBoing]