TLAC · Think Like A Computer
Games in TLACJuegos en TLACTLACのゲーム
Seven games, one instruction at a time. Read the rules, follow the game loop, and explore the complete programs.Siete juegos, una instrucción a la vez. Lee las reglas, sigue el bucle del juego y explora los programas completos.7つのゲームを、1つずつ命令を追って学びましょう。ルールを読み、ゲームの繰り返しを追い、プログラム全体を確認できます。
Positions and list items start at 0. “Yes” and “no” are stored conditions. Parentheses group calculations or coordinate pairs; braces inside a message insert the current value. Short names such as x, y, nx, and ny are named storage spaces. Quoted display messages and symbols keep the game’s original wording.Las posiciones y los elementos de las listas empiezan en 0. «Sí» y «no» son condiciones guardadas. Los paréntesis agrupan cálculos o coordenadas; las llaves dentro de un mensaje insertan el valor actual. Nombres cortos como x, y, nx y ny son espacios de almacenamiento. Los mensajes y símbolos entre comillas conservan el texto original del juego.位置とリストの番号は0から始まります。「はい」と「いいえ」は保存する条件の値です。丸括弧は計算や座標の組をまとめ、メッセージ内の波括弧には現在の値を入れます。x、y、nx、nyなどの短い名前は値を保存する場所です。引用符内のメッセージや記号はゲームの原文を使っています。
01 · SnakeSnakeスネーク
Grow a snake by collecting food. Keep its head away from walls and its own body.Haz crecer una serpiente recogiendo comida. Evita las paredes y su propio cuerpo.エサを食べてヘビを伸ばします。壁や自分の体に頭がぶつからないように進みます。
15 × 15
Lists · coordinates · collision checksListas · coordenadas · colisionesリスト · 座標 · 衝突判定
W / A / S / D: choose direction · Q: quit. Press Enter after each command.W / A / S / D: dirección · Q: salir. Pulsa Enter después de cada orden.W / A / S / D:方向を選ぶ · Q:終了。入力後にEnterを押します。
The game at a glanceEl juego de un vistazoゲームの流れ
- Load the board, create a four-segment snake, set the score to zero, and place food outside its body.Cargar el tablero, crear una serpiente de cuatro segmentos, poner la puntuación a cero y colocar comida fuera del cuerpo.盤面を読み込み、長さ4のヘビを作り、得点を0にして、体と重ならない場所にエサを置きます。
- Draw the snake and food, then read a direction. Prevent a direct reversal into the body.Dibujar la serpiente y la comida; leer una dirección. Impedir que gire directamente hacia su cuerpo.ヘビとエサを表示して方向を入力します。体に向かって180度反転することはできません。
- Calculate the next head position. End the game if it hits a wall or the checked body segments.Calcular la siguiente posición de la cabeza. Terminar si choca con una pared o con los segmentos comprobados.頭の次の位置を計算します。壁や判定対象の体にぶつかったら終了します。
- Insert the new head at the front of the list. If it eats food, add 10 points and place new food; otherwise remove the tail.Insertar la cabeza al inicio de la lista. Si come, sumar 10 puntos y colocar comida nueva; si no, quitar la cola.リストの先頭に新しい頭を追加します。エサを食べたら10点を加えて新しいエサを置き、食べなければ末尾を取り除きます。
- Repeat until a collision or Q ends the game, then print the final score.Repetir hasta una colisión o hasta pulsar Q; mostrar la puntuación final.衝突するかQを入力するまで繰り返し、最後に得点を表示します。
Starting boardTablero inicial初期盤面
[#][#][#][#][#][#][#][#][#][#][#][#][#][#][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][^][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][#] [#][#][#][#][#][#][#][#][#][#][#][#][#][#][#]
Full TLAC instruction cardsTodas las tarjetas de instrucciones TLACTLAC命令カード全文
02 · Pac-ManPac-Manパックマン
Collect eggs and diamonds while sharing a maze with two ghosts. Diamonds give temporary power.Recoge huevos y diamantes en un laberinto con dos fantasmas. Los diamantes dan poder temporal.2匹のゴーストがいる迷路で卵とダイヤを集めます。ダイヤを取ると一時的にパワーアップします。
19 × 14
Game state · timers · lists · conditionsEstado del juego · temporizadores · listas · condicionesゲームの状態 · タイマー · リスト · 条件分岐
W / A / S / D, then Enter: move. Ctrl+C: stop the program.W / A / S / D y Enter: moverse. Ctrl+C: detener el programa.W / A / S / Dを入力してEnter:移動。Ctrl+C:プログラムを停止。
The game at a glanceEl juego de un vistazoゲームの流れ
- Load the maze, place the player and two ghosts, and start with three lives and zero points.Cargar el laberinto, colocar al jugador y dos fantasmas; empezar con tres vidas y cero puntos.迷路を読み込み、プレイヤーと2匹のゴーストを配置し、残り3ライフ・0点で始めます。
- While collectibles remain and lives are above zero, read a move until the player can enter the chosen square.Mientras queden objetos y vidas, leer un movimiento hasta que el jugador pueda entrar en la casilla elegida.集める物とライフが残っている間、進める方向が入力されるまで移動指示を受け付けます。
- Check for a ghost collision. Without power, lose a life and return to the start; with power, earn 200 points and reset that ghost.Comprobar colisiones con fantasmas. Sin poder, perder una vida y volver al inicio; con poder, ganar 200 puntos y reiniciar ese fantasma.ゴーストとの衝突を確認します。通常時はライフを1つ失って開始位置へ戻り、パワー中は200点を得てそのゴーストを戻します。
- Collect an egg for 10 points or a diamond for 50 points. A diamond sets the power counter to 10.Recoger un huevo por 10 puntos o un diamante por 50. Un diamante pone el contador de poder en 10.卵を取ると10点、ダイヤを取ると50点です。ダイヤはパワーのカウンターを10にします。
- Decrease the power counter and move the ghosts. Powered ghosts choose a move away from the player; otherwise this source chooses random valid moves. Check collisions again.Reducir el contador y mover los fantasmas. Con poder activo se alejan del jugador; en otro caso, este código elige movimientos válidos al azar. Comprobar colisiones de nuevo.パワーのカウンターを減らしてゴーストを動かします。パワー中はプレイヤーから離れる移動を選び、通常時はこのソースでは進める方向をランダムに選びます。もう一度衝突を確認します。
- Repeat until all collectibles are gone or no lives remain, then print the final score.Repetir hasta recoger todos los objetos o perder todas las vidas; mostrar la puntuación final.全て集めるかライフがなくなるまで繰り返し、得点を表示します。
Starting boardTablero inicial初期盤面
[#][#][#][#][#][#][#][#][#][#][#][#][#][#][#][#][#][#][#] [#][^][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][X][#] [#][o][#][#][#][#][#][#][#][o][#][#][#][#][#][#][#][o][#] [#][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][#] [#][o][#][o][#][#][#][#][#][o][#][#][#][#][#][o][#][o][#] [#][o][#][o][#][#][o][o][o][o][o][o][o][#][#][o][#][o][#] [#][o][#][o][#][#][o][#][#][#][#][#][o][#][#][o][#][o][#] [#][o][#][o][#][#][o][#][#][#][#][#][o][#][#][o][#][o][#] [#][o][#][o][#][#][o][o][o][o][o][o][o][#][#][o][#][o][#] [#][o][#][o][#][#][#][#][#][#][#][#][#][#][#][o][#][o][#] [#][M][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][#] [#][o][#][#][#][#][#][#][#][#][#][#][#][#][#][#][#][o][#] [#][W][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][X][#] [#][#][#][#][#][#][#][#][#][#][#][#][#][#][#][#][#][#][#]
Full TLAC instruction cardsTodas las tarjetas de instrucciones TLACTLAC命令カード全文
03 · SokobanSokoban倉庫番
Push every box onto a goal. A box can move only if the square behind it is clear.Empuja cada caja hasta una meta. Solo se puede mover si la casilla detrás está libre.全ての箱をゴールへ押します。箱の奥のマスが空いているときだけ押せます。
8 × 8
Lists · level layouts · conditionsListas · diseño de niveles · condicionesリスト · ステージの配置 · 条件分岐
W / A / S / D: move or push · Q: quit. Press Enter after each command.W / A / S / D: moverse o empujar · Q: salir. Pulsa Enter tras cada orden.W / A / S / D:移動・箱を押す · Q:終了。入力後にEnterを押します。
The game at a glanceEl juego de un vistazoゲームの流れ
- Read the level stored in the program. Place walls, goals, boxes, and the player.Leer el nivel guardado en el programa. Colocar paredes, metas, cajas y jugador.プログラム内のステージを読み、壁・ゴール・箱・プレイヤーを配置します。
- Draw the board and check whether every box is on a goal. If so, show the move count and finish.Dibujar el tablero y comprobar si cada caja está en una meta. Si es así, mostrar los movimientos y terminar.盤面を表示し、全ての箱がゴール上にあるか確認します。揃ったら移動回数を表示して終了します。
- Read a direction. Reject movement into a wall.Leer una dirección. Rechazar movimientos hacia una pared.方向を入力します。壁に向かう移動はできません。
- If there is a box ahead, check the square beyond it. Push only when neither a wall nor another box blocks that square.Si hay una caja delante, comprobar la casilla siguiente. Empujar solo si no hay una pared ni otra caja.前に箱がある場合は、さらに奥のマスを確認します。壁も別の箱もない場合だけ押します。
- Move the player, add one to the move count, and repeat.Mover al jugador, sumar un movimiento y repetir.プレイヤーを移動し、移動回数を1増やして繰り返します。
Full TLAC instruction cardsTodas las tarjetas de instrucciones TLACTLAC命令カード全文
04 · MinesweeperBuscaminasマインスイーパー
Reveal every safe cell on a board with 12 hidden mines. Numbers count mines in the eight neighboring cells.Descubre todas las casillas seguras en un tablero con 12 minas ocultas. Los números cuentan las minas en las ocho casillas vecinas.12個の地雷を避けて安全なマスを全て開きます。数字は周囲8マスの地雷の数です。
10 × 10
Recursion · neighbor counting · cell stateRecursión · vecinos · estado de las casillas再帰 · 周囲の数え上げ · マスの状態
W / A / S / D: cursor · R: reveal · F: toggle flag · Q: quit. Confirm with Enter.W / A / S / D: cursor · R: descubrir · F: poner o quitar bandera · Q: salir. Confirmar con Enter.W / A / S / D:カーソル · R:開く · F:旗を切り替える · Q:終了。Enterで確定します。
The game at a glanceEl juego de un vistazoゲームの流れ
- Place 12 mines at distinct random positions and count adjacent mines for every safe cell.Colocar 12 minas en posiciones aleatorias distintas y contar las minas vecinas de cada casilla segura.異なるランダムな位置に地雷を12個置き、安全な各マスの周囲の地雷数を数えます。
- Draw covered cells, flags, revealed numbers, and the cursor. Read one command.Dibujar casillas cubiertas, banderas, números descubiertos y cursor. Leer una orden.未開封のマス、旗、開いた数字、カーソルを表示して指示を入力します。
- Move the cursor, toggle a flag on a covered cell, or reveal an unflagged cell.Mover el cursor, alternar una bandera en una casilla cubierta o descubrir una casilla sin bandera.カーソルを動かす、未開封のマスの旗を切り替える、または旗のないマスを開きます。
- When a revealed cell has no neighboring mines, recursively reveal its neighbors. Already revealed or flagged cells stop that recursive branch.Si una casilla descubierta no tiene minas vecinas, descubrir sus vecinas mediante recursión. Las casillas ya descubiertas o con bandera detienen esa rama.周囲に地雷がなければ再帰で隣のマスも開きます。既に開いたマスや旗のあるマスでは、その再帰を止めます。
- Lose if a mine is revealed. Win when every non-mine cell is revealed; flags alone do not win the game.Perder al descubrir una mina. Ganar al descubrir todas las casillas sin minas; las banderas por sí solas no bastan.地雷を開くと負けです。地雷以外を全て開くと勝ちです。旗を立てるだけではクリアになりません。
Full TLAC instruction cardsTodas las tarjetas de instrucciones TLACTLAC命令カード全文
05 · FroggerFroggerフロッガー
Cross moving traffic and reach the top row. You start with three lives.Cruza el tráfico y llega a la fila superior. Empiezas con tres vidas.動く車を避けて最上段を目指します。最初のライフは3つです。
15 × 11
Lists of dictionaries · wrapping · collision checksListas de diccionarios · bordes cíclicos · colisiones辞書のリスト · 端での折り返し · 衝突判定
W / A / S / D: move · Enter alone: wait · Q: quit. Confirm commands with Enter.W / A / S / D: moverse · Enter solo: esperar · Q: salir. Confirmar con Enter.W / A / S / D:移動 · Enterのみ:待つ · Q:終了。指示はEnterで確定します。
The game at a glanceEl juego de un vistazoゲームの流れ
- Mark the top row as the goal, place traffic in its lanes, and start the player at the bottom.Marcar la fila superior como meta, colocar el tráfico en sus carriles y al jugador abajo.最上段をゴールにし、車を各車線に配置して、プレイヤーを下端に置きます。
- Draw the traffic and lives, then move the player or wait.Dibujar el tráfico y las vidas; mover al jugador o esperar.車と残りライフを表示し、プレイヤーを動かすか待機します。
- Check collisions. On a hit, remove one life, reset the player, and begin the next turn.Comprobar colisiones. Si hay un choque, quitar una vida, reiniciar al jugador y comenzar el siguiente turno.衝突を確認します。当たったらライフを1つ減らし、開始位置に戻して次のターンへ進みます。
- Advance each vehicle by its speed and wrap it around the board edge. Check collisions again, including a fast truck passing over the player.Avanzar cada vehículo según su velocidad y hacerlo reaparecer por el otro borde. Comprobar colisiones, incluidos camiones rápidos que pasan sobre el jugador.車を速度に応じて進め、端を越えた車は反対側へ回します。速いトラックがプレイヤーを飛び越える場合も含めて、再び衝突を確認します。
- Win upon reaching the top row after the collision checks. Otherwise repeat while lives remain.Ganar al llegar arriba tras comprobar las colisiones. Si no, repetir mientras queden vidas.衝突判定後に最上段にいれば勝ちです。それ以外はライフが残っている間繰り返します。
Full TLAC instruction cardsTodas las tarjetas de instrucciones TLACTLAC命令カード全文
06 · BombermanBombermanボンバーマン
Place timed bombs to destroy crates and three roaming enemies. Stay clear of the cross-shaped blast.Coloca bombas con temporizador para destruir cajas y tres enemigos. Evita la explosión en forma de cruz.時限爆弾で木箱と動く3体の敵を倒します。十字型の爆風を避けましょう。
11 × 11
Timers · dictionaries · list updatesTemporizadores · diccionarios · cambios en listasタイマー · 辞書 · リストの更新
W / A / S / D: move · B: bomb · Enter alone: wait · Q: quit. Confirm with Enter.W / A / S / D: moverse · B: bomba · Enter solo: esperar · Q: salir. Confirmar con Enter.W / A / S / D:移動 · B:爆弾 · Enterのみ:待つ · Q:終了。Enterで確定します。
The game at a glanceEl juego de un vistazoゲームの流れ
- Build border walls and pillars, scatter crates, and place the player and three enemies.Crear paredes y pilares, distribuir cajas y colocar al jugador y tres enemigos.外壁と柱を作り、木箱を散らして、プレイヤーと3体の敵を配置します。
- Draw the arena. If no enemies remain, announce a win; otherwise read a move, bomb, or wait command.Dibujar la arena. Si no quedan enemigos, anunciar la victoria; si no, leer una orden de movimiento, bomba o espera.盤面を表示します。敵がいなければ勝ちです。そうでなければ移動・爆弾・待機を入力します。
- Reject movement into walls, crates, or bombs. A new bomb starts at 4 and immediately ticks down to 3 on this turn.Impedir movimientos hacia paredes, cajas o bombas. Una bomba nueva empieza en 4 y baja inmediatamente a 3 en este turno.壁・木箱・爆弾のある場所には進めません。新しい爆弾は4から始まり、そのターンですぐに3になります。
- Decrease bomb timers. At zero, affect the bomb cell and its four direct neighbors, skipping walls. Remove hit crates and enemies; a blast hitting the player ends play.Reducir temporizadores. Al llegar a cero, afectar la casilla de la bomba y sus cuatro vecinas directas, excepto paredes. Quitar cajas y enemigos alcanzados; si alcanza al jugador, terminar.タイマーを減らし、0になったら中心と上下左右1マスに爆風を発生させます。壁は除きます。当たった木箱や敵を取り除き、プレイヤーに当たれば終了します。
- Move enemies into randomly chosen clear neighboring squares. End on a player collision; otherwise repeat.Mover enemigos a casillas vecinas libres elegidas al azar. Terminar si chocan con el jugador; si no, repetir.敵をランダムに選んだ隣の空きマスへ動かします。プレイヤーにぶつかったら終了し、それ以外は繰り返します。
Full TLAC instruction cardsTodas las tarjetas de instrucciones TLACTLAC命令カード全文
07 · Conway’s Game of LifeJuego de la vida de Conwayコンウェイのライフゲーム
Watch a population of cells evolve. Each generation follows the same four rules, with no player movement.Observa cómo evoluciona una población de células. Cada generación sigue las mismas cuatro reglas, sin mover un jugador.細胞の集団が変化する様子を観察します。プレイヤーを動かさず、毎世代同じ4つのルールを適用します。
15 × 15
Nested loops · neighbor counting · simultaneous updatesBucles anidados · vecinos · actualización simultánea入れ子の繰り返し · 周囲の数え上げ · 同時更新
Enter: next generation · A then Enter: auto-play · Ctrl+C: stop auto-play · Q then Enter: quit.Enter: siguiente generación · A y Enter: automático · Ctrl+C: detener automático · Q y Enter: salir.Enter:次の世代 · AとEnter:自動再生 · Ctrl+C:自動再生を停止 · QとEnter:終了。
The game at a glanceEl juego de un vistazoゲームの流れ
- Seed the board randomly: each cell has a 25% chance of starting alive. Display generation zero.Inicializar al azar: cada célula tiene un 25 % de probabilidad de estar viva. Mostrar la generación cero.各細胞が25%の確率で生きた状態になるよう初期化し、第0世代を表示します。
- For every cell, count live neighbors among the eight surrounding positions that lie inside the board.Para cada célula, contar vecinas vivas entre las ocho posiciones circundantes dentro del tablero.各細胞について、盤面内にある周囲8マスの生きた細胞を数えます。
- A live cell dies with fewer than two neighbors or more than three. It survives with two or three.Una célula viva muere con menos de dos vecinas o más de tres. Sobrevive con dos o tres.生きた細胞は隣が2個未満または3個より多いと死に、2個か3個なら生き残ります。
- A dead cell becomes alive with exactly three live neighbors. Otherwise it stays dead.Una célula muerta nace con exactamente tres vecinas vivas. En otro caso sigue muerta.死んだ細胞は隣の生きた細胞がちょうど3個なら誕生し、それ以外は死んだままです。
- Store all next states before replacing the current generation. Increment the generation number and display the board.Guardar todos los estados siguientes antes de sustituir la generación actual. Incrementar el número de generación y mostrar el tablero.全ての次の状態を計算してから現在の世代を置き換えます。世代番号を増やして盤面を表示します。
- Continue one generation per Enter, or automatically every 0.3 seconds until auto-play is interrupted.Continuar una generación por Enter, o automáticamente cada 0,3 segundos hasta interrumpir la reproducción.Enterごとに1世代進めるか、自動再生を止めるまで0.3秒ごとに進めます。