TI-BASIC:Mine Field

From Learn @ Cemetech
Jump to navigationJump to search

Like the classic game minesweeper, the goal of Mine Field is to avoid hitting the mines. A new twist has been added, however, and you must maneuver the field around the mines to get to the star (the asterisk) on the other side. The game uses a simple 8x16 matrix to store the field, although you could use a list or string as well. You can play this game indefinitely, since all of the mines are randomly placed.

The Code

:DelVar [B]{8,16→dim([B]
:Repeat [B](Y,X
:Repeat Ans
:Output(Y,X,"  // 1 space
:X-(G=24 and X>1)+(G=26 and X<16→X
:Y-(G=25 and Y>1)+(G=34 and Y<8→Y
:"YOU "+sub("WIN!!LOSE!",[B](Y,X),5

The Download

In case you want to try the program on your calculator, you can download the program in .8xp format.