Case 007
MVP proof: a real, recognizable program ported to EML
tic_tac_toe.eml is a "does EML actually work for something real" test — not a new-language-feature regression fixture like the other examples/phaseN-* directories, but a demonstration that a genuine, independently-authored small program can be expressed end to end in EML: transpiled to Python, executed, and verified against real Python via the interpreter equivalence gate.
ok: true — round-trip fixpoint reached (python1 == python2)updated 2026-07-18
EML
eml# Ported from Python-World/python-mini-projects (projects/Tic_tac_toe,
# MIT-licensed) as a "real, recognizable program" MVP proof for EML —
# not a new language-feature test, but a demonstration that a genuine
# small program can be expressed end to end. The original is interactive
# (input()); this port replaces that with a fixed, scripted move sequence
# (including one deliberately invalid move) so the whole program is
# deterministic and verifiable against real Python (see tic_tac_toe.trace.jsonl,
# generated by `eml trace --run`).
class TicTacToe:
def __init__(self):
[" ", " ", " ", " ", " ", " ", " ", " ", " "] => self.squares
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]] => self.win_lines
"X" => self.current
def play_move(self, position):
if self.squares[position] != " ":
raise ValueError("square already taken")
self.current => self.squares[position]
def has_won(self):
for line in self.win_lines:
{self.squares[line[0]], self.squares[line[1]], self.squares[line[2]]} == {self.current} ? 1 : 0 => hit
if hit == 1:
return 1
return 0
def next_turn(self):
self.current == "X" ? "O" : "X" => self.current
TicTacToe() => game
moves^+[0, 4, 1, 5, 0, 2]
winner^+""
for move in moves:
try:
game.play_move(move)
except ValueError:
continue
game.has_won() => won
if won == 1:
game.current => winner
break
game.next_turn()
game.squares => final_board
final_board^0
winner^0Python (deterministic transpilation)
pythonclass TicTacToe:
def __init__(self):
self.squares = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
self.win_lines = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
self.current = "X"
def play_move(self, position):
if self.squares[position] != " ":
raise ValueError("square already taken")
self.squares[position] = self.current
def has_won(self):
for line in self.win_lines:
hit = 1 if {self.squares[line[0]], self.squares[line[1]], self.squares[line[2]]} == {self.current} else 0
if hit == 1:
return 1
return 0
def next_turn(self):
self.current = "O" if self.current == "X" else "X"
game = TicTacToe()
moves = [0, 4, 1, 5, 0, 2]
winner = ""
for move in moves:
try:
game.play_move(move)
except ValueError:
continue
won = game.has_won()
if won == 1:
winner = game.current
break
game.next_turn()
final_board = game.squares
print(final_board)
print(winner)stdout (executed)
text['X', 'X', 'X', ' ', 'O', 'O', ' ', ' ', ' ']
XTrace event types
eml:run:starteml:classdefeml:calleml:assigneml:returneml:outputeml:run:done