Microsoft Small Basic

Program Listing: LGB100
intro()

Sub space
TextWindow.WriteLine(" ")
EndSub

Sub intro
For i = 1 To 2
lol[i] = 1
EndFor
lol[i] = 1
x = 0
comguess = 10
TextWindow.WriteLine("Guessing Game")
space()
space()
TextWindow.WriteLine("1. Start")
TextWindow.WriteLine("2. Exit")
space()
intro = TextWindow.Readkey()
If intro = 1 Then
TextWindow.Clear()
instructions()
elseif intro = 2 then
Program.End()
else
TextWindow.Clear()
intro()
EndIf
EndSub

Sub instructions
TextWindow.WriteLine("Computer: You are to guess a number between 1 and 20.")
space()
TextWindow.Pause()
TextWindow.Clear()
game()
EndSub

Sub game
TextWindow.WriteLine(" Computer Guess: " + x)
space()
space()
TextWindow.WriteLine("Computer: I guess number " + comguess + ".")
guess()
EndSub

sub guess
space()
TextWindow.WriteLine("Computer: Is it your number?")
space()
TextWindow.WriteLine("1. Yes")
TextWindow.WriteLine("2. No")
space()
guess = TextWindow.Readkey()
If guess = 1 Then
TextWindow.Clear()
intro()
ElseIf guess = 2 then
highlow()
Else
TextWindow.Clear()
game()
EndIf
EndSub

Sub highlow
space()
x = x + 1
TextWindow.WriteLine("1. Computer: Is the number " + comguess +" too high?")
TextWindow.WriteLine("2. Computer: Is the number " + comguess + " too low?")
space()
highlow = TextWindow.Readkey()
If highlow = 1 Then
dontlie()
high()
ElseIf highlow = 2 then
dontlie()
low()
Else
TextWindow.Clear()
highlow()
EndIf
TextWindow.Clear()
game()
EndSub

Sub high
If comguess = 10 Then
comguess = 5
elseIf comguess = 5 then
comguess = 3
elseif comguess = 3 then
comguess = 1
elseif comguess = 7 then
comguess = 6
elseif comguess = 9 then
comguess = 8
elseIf comguess = 13 then
comguess = 11
elseif comguess = 15 then
comguess = 13
elseif comguess = 17 then
comguess = 16
elseif comguess = 19 then
comguess = 18
EndIf
EndSub

sub low
If comguess = 10 Then
comguess = 15
elseIf comguess = 11 then
comguess = 12
elseIf comguess = 15 then
comguess = 17
elseif comguess = 19 then
comguess = 20
elseif comguess = 1 then
comguess = 2
elseif comguess = 3 then
comguess = 4
elseif comguess = 5 then
comguess = 7
elseif comguess = 7 then
comguess = 9
elseif comguess = 13 then
comguess = 14
elseif comguess = 17 then
comguess = 19
EndIf
EndSub

Sub dontlie
space()
If comguess = 2 or comguess = 4 or comguess = 6 or comguess = 8 or comguess = 12 or comguess = 14 or comguess = 16 or comguess = 18 or comguess = 20 Then
TextWindow.WriteLine("Computer: I know I guessed your number... you just made a human error!")
space()
TextWindow.Pause()
TextWindow.Clear()
intro()
EndIf
EndSub