esolang

Tic Tac Toe

Brainfuck, played out as games of noughts and crosses.

JWinslow23, 2013 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: IBM

The idea

JWinslow23 made Tic Tac Toe in 2013. A program is the record of one or more games. Eight of the nine squares stand for a brainfuck command and the middle one does nothing. The moves of the side the program plays are run in order. The other side's moves are only there to keep the game legal.

Read the story

The rules of the game get in the way. A square can be used once per game, so a second + needs a new game. A move that wins does nothing, and a game that is won takes no more moves. Writing a program means planning games that say what you want without winning too early.

The machine

The board, and the command on each square.

123
a+->
b<nothing[
c],.

A program starts with I will play as X. or I will play as O., then Game 1: and moves like X went on c2. X always starts, the sides take turns, and games are numbered from 1 in order. A taken square, a move out of turn or a move after a win is an error. Bytes wrap between 0 and 255, and , stores 0 at the end of the input.

Example

X plays c2, b3, a1 and c3 in the first game and c2 and c1 in the second, which is ,[+.,].

X plays c2, b3, a1 and c3 in the first game and c2 and c1 in the second, which is ,[+.,]. Each letter read comes out one higher.

The cat is ,[.,] over two games. X's last move in each game wins, at a3 and at c3, so it does nothing.

Expected: meow

Patterns it teaches

Further

Tic Tac Toe builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from Tic Tac Toe

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: tic-tac-toe.

Command line

shib run tic-tac-toe -e 'I will play as X.

Game 1:
X went on c2.
O went on a1.
X went on b3.
O went on b2.
X went on c3.
O went on c1.
X went on a3.

Game 2:
X went on c2.
O went on b2.
X went on c1.
O went on b3.
X went on c3.' --input 'Hello, tic-tac-toe!'
shib manual tic-tac-toe

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/tic-tac-toe.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org