STOP the game

Back in the good old days of DOS and Microsoft BASIC (MSBASIC), the BASIC written by Bill Gates himself, someone somewhere held a coding competition: who can write the ‘smallest playable game’. I still remember this game, although I do not remember if it won or not, but here it is, modified to be runnable with Visual Basic, under Visual Studio.

How to play?
All you have to do is run the code. On the console window, wait for the GO, then try typing the word STOP as fast as you can. You have 1 second. If you are able to type STOP in under 1 second, you win and your typing time is displayed, other wise you lose. But then, you can always run it again.

How to write the code?
Easy, in Visual Studio, or any VB, create a new project (File -> New Project) then select VB on the left pane finally select CONSOLE APPLICATION on the right, then OK. Now copy the whole code from below and paste as-is in the page MODULE1.VB. You won’t need to use any of the imports so paste replacing all. Finally, click the function key [F5] to run the code and wait for the GO signal. Start typing!

Minimal computer requirement: CPM, 8086 4 MHZ CPU running Microsoft DOS and 512K of RAM.


Compliment of Albert Zakhia.

The below code has been modified on April the 18th, 2017, adding more hints to the game.

Module Module1
Sub Main()
Dim s = ""
Dim t = New Stopwatch
Dim pos As Int16
Dim key As Char
While True
Console.WriteLine("Press [X] to exit or any key to start!")
key = Console.ReadKey().KeyChar
If Char.ToUpper(key) = "X" Then Exit While
pos = 1
Console.SetCursorPosition(11, Console.CursorTop)
While Not s.ToLower().Contains("stop") And t.ElapsedMilliseconds <= 1000
If Console.KeyAvailable Then s = s & Console.ReadKey().KeyChar
Console.SetCursorPosition(pos, Console.CursorTop)
pos = pos + 1
End While
If t.ElapsedMilliseconds > 1000 Then
Console.WriteLine("X - Timeout, you lose")
Console.WriteLine("{0}Great! You typed: {1} in {2} seconds", vbCrLf, s, t.ElapsedMilliseconds / 1000)
End If
While Console.KeyAvailable
End While
End While
End Sub
End Module

Leave a Reply