Small games written in X_eTaL, a typed array language: each one
is written around one array idea and happens to be playable.
Start here
What you are looking at. Small games written in X_eTaL, each running in your browser. A game's
page plays it in a terminal (type and press Enter), runs its scripted program as a notebook, and shows
its source: everything on the page is X_eTaL's own output. Every game also runs at the command line
(the README says how).
Why an array language. These games are about whole boards, all the pieces or every possible
move at once, and X_eTaL says them that way, with no loop over squares or pieces:
p +r̲oll!5r̲eshape3Every horse moves at once: one roll per horse, added to the vector of positions (horse race).('+r̲/₁₂-101o̲-₁₂ p) − pEvery square's count of neighboring mines at once: the board rotated by every offset and summed, less itself (minesweeper).(r̲ange9) '+'×i̲nner222222222e̲ncodeo̲ffsets512Every set of tiles at once: the 512 subsets of 1 to 9 as bits, and all their sums by one inner product (shut the box).
Try one. Pick a game below; the table says which array idea each one is written around.
A title links to the game's history.
Read the code.The cross-reference, written by xetal doc:
every program and library of every game and the shared libraries, each definition with its type,
its documentation and examples (run by the gate), its source, and every place it is used.
One array idea per game
Different games, the same few array ideas: each game is written around one.
The array idiom
Game
a vector of racers moved by one expression; the leaders by a fork
a vector of racers moved by one expression; the leaders by a fork
Five horses race to 15, each running 1, 2 or 3 a round, all at once. The field is one vector of positions and a round is one expression; the track is a character matrix drawn by a table. Bet on a horse at the terminal.
every candidate against every guess by one table; all games played at once
The smallest COR24 BASIC game, at a terminal: higher or lower until you have it. Its scripted game checks every candidate from 1 to 100 against every guess at once, and plays all 100 games in lockstep.
a coordinate matrix moving at once; collisions as an inner product
Twelve robots chase you across a 16 by 16 board and you make them crash. Every robot steps at once: the robots are one 2 by 12 matrix and a turn adds the sign of the difference; crashes are found by a table of every robot against every other.
matricessign by comparisonst_abler_eplicatereduce on rank 4g_radelibraries
text as a table of rows picked by masks; refusals as data
Star Trek: Decaying Orbit, a text adventure: restore the Enterprise's engines before its orbit decays, past a locked armory and Klingon boarders. No branching code for the story: every line is a row of a table with a key and a condition, a room is one mask, a turn updates the state vector.
a galaxy of planes; paths as tables of steps; windows by selection
The classic: destroy every Klingon in an 8 by 8 galaxy of 8 by 8 sectors before the stardate runs out, with warp, impulse, phasers, torpedoes and shields. The galaxy is three planes made at once, a course is a whole path at once, and phasers hit every Klingon in one subtraction.
8 by 8 planest_able pathsw_here first hitwindows by indexg_rade permutationsr_avel_2libraries
lines by indexing; ratings as one inner product; minimax as negamax
Three in a row against the computer. The eight lines are a table of square numbers: used as indices into the board it gives every line at once, and a reduce gives every line's sum. The computer rates every empty square at once; a minimax player searches by recursion.
index tablesreducem_ember?t_ablerecursione_achlibraries
masks over all 512 subsets at once; sums by one inner product
Roll the dice and shut tiles adding up to the roll; shut all nine to win. All 512 subsets of the tiles are one 9 by 512 matrix of bits, their sums one inner product, and the legal moves are the columns that fit the open tiles and add up to the roll.
neighborhoods by rotate and reduce; flood fill to a fixed point
Open a 9 by 9 field without touching its 10 mines. Every square's count of neighboring mines is computed at once, as Life counts neighbors, and opening an empty square floods: the opened region grows ring by ring until it stops.
compress, merge, compress as a train; turning by powers of 0 or 1
Slide the tiles of a 4 by 4 board; equal tiles merge; make 2048. A move left slides and merges every row at once: compress by running counts and a table, merge by each tile's place in its run, found by a max-scan; the other moves turn the board with reverse and transpose.
a candidate tensor; every single at once by sums over units; rounds to a fixed point
Fill the 9 by 9 grid so every row, column and box holds 1 to 9. X_eTaL keeps every cell's candidates as one 81 by 9 array, finds every single at once by summing over the 27 units, repeats until nothing changes, and searches only when that stalls: Arto Inkala's "hardest" puzzle in under a second.
t_ables_elect with a tabler_/_2one-hotfixed pointsearchlibraries
every distance at once, nearest by grade; a map drawn as SVG text; clicks as events; data from TOML
A map you click: each red dot is a national capital inside its unlabeled country; click it, then its name among four nearby cities; choose a region or the whole world. X_eTaL reads the countries, capitals and cities from TOML, finds the nearest cities by computing every distance at once, and draws the map, its menus and the score as SVG; the page passes your clicks to the program as events.
brightness bands as a table; every star placed at once; the sky drawn as SVG text; clicks as events; data from TOML
A sky you click: five named stars ringed, mixed bright, middling and faint; click one, then its name among four (one star from each brightness band besides it); choose a part of the sky or all of it. X_eTaL reads the Bright Star Catalog and the IAU's star names from TOML, draws the whole sky as SVG, and the page passes your clicks to the program as events.