Rem Knightsbridge, a Tim Hartnell game ported to BASIC Anywhere Machine by johnno56
Dim H(99), Z(8)
Screen 7: Width 40:
title$ = "KNIGHTSBRIDGE"
GoSub Initialise

MainLoop:
	GoSub PrintBoard
	If HU = 5 Or CO = 5 Then GoTo GameOver
	GoSub ComputerMove
	GoSub PrintBoard
	If HU = 5 Or CO = 5 Then GoTo GameOver
	GoSub HumanMove
GoTo MainLoop

HumanMove:
Q = 0

label130:
M = Int(Rnd * 66) + 11
Q = Q + 1
If Q = 500 Then GoTo GameOver
If H(M) <> 72 Then GoTo label130
color 11: Print "You must move the piece on "; M

label180:
Input N
If N = 99 Then Q = 500: GoTo GameOver
Rem *** Check if move legal ***
P = 0
CT = 1

label230:
If M + Z(CT) = N Then P = 1
If CT < 8 Then CT = CT + 1: GoTo label230
If P = 0 Then color 13: Print "Illegal move": GoTo label180
If H(N) = 67 Then HU = HU + 1: color 14: Print "Well played!": _delay 3
H(M) = 46: H(N) = 72
Return

ComputerMove:
Q1 = 0

label320:
Q1 = Q1 + 1
K = Int(Rnd * 66) + 11
If Q1 = 500 Then GoTo GameOver
If H(K) <> 67 Then GoTo label320
color 12: Print "I have to move the piece on "; K: _delay 4
W = 1

label380:
If K + Z(W) < 11 Or K + Z(W) > 77 Then GoTo label400
If H(K + Z(W)) = 72 Then color 14: Print "Gotcha!!": CO = CO + 1: _delay 3: GoTo label450

label400:
If W < 8 Then W = W + 1: GoTo label380
W = 1

label420:
If (K + Z(W) < 11 Or K + Z(W) > 77) And W < 8 Then W = W + 1: GoTo label420

label430:
If H(K + Z(W)) <> 46 And W < 8 Then W = W + 1: GoTo label430
If W = 8 And H(K + Z(W)) <> 46 Then Q1 = 500: GoTo GameOver

label450:
X = K: Y = K + Z(W)
H(X) = 46: H(Y) = 67
Return

PrintBoard:
Cls: color 14: Print: Print "        "; title$: Print: Print
locate ,8: color 2: Print "  My score: ";: color 12: Print CO
locate ,8: color 2: Print "Your score: ";: color 11: Print HU
Print
locate ,8: color 7: Print "1 2 3 4 5 6 7"
locate ,8: color 7: Print "- - - - - - -"
For M = 70 To 10 Step -10
	locate ,6: color 7: Print M / 10;" ";
	For N = 1 To 7
		If Chr$(H(M + n)) = "H" Then
			color 11
			Print CHR$(human);" ";
		end if
		If Chr$(H(M + n)) = "C" Then
			color 12
			Print CHR$(comp);" ";
		end if
		If Chr$(H(M + n)) = "." Then
			color 2
			Print Chr$(H(M + N)); " ";
		end if
	Next N
	color 7: Print M / 10
Next M
locate ,8: Print "- - - - - - -"
locate ,8: Print "1 2 3 4 5 6 7"
Print

'	Colour test only...
'for col = 1 to 20
'	color col
'	locate col, 35: Print col
'next col
'color 7

Return

GameOver:
GoSub PrintBoard
If HU = 5 Then color 12: Print "Beaten by a mere human...": Print "The shame. The shame of it all..."
If CO = 5 Then color 12: Print "This victory is the first": Print "step in our plan to take": Print "over the entire earth!"
If Q = 500 Then color 12: Print "I accept your wish to concede"
If Q1 = 500 Then color 12: Print "I concede to a Master"
End

Initialise:
'
'		Define the characters - New function!
'
comp = 0
human = 1
_LETCHR$(0, _
	"....X..." + _
	"..XXXX.." + _
	".XXXXXX." + _
	"XXXX..XX" + _
	"XXXXX..." + _
	".XXXXX.." + _
	"..XXXX.." + _
	"XXXXXXXX")
	
_LETCHR$(1, _
	"...X...." + _
	"..XXXX.." + _
	".XXXXXX." + _
	"XX..XXXX" + _
	"...XXXXX" + _
	"..XXXXX." + _
	"..XXXX.." + _
	"XXXXXXXX")

CLS: color 14:Print: locate ,20-len(title$)/2: Print title$
locate 7, 7: color 2: Print "Please stand by ... ";
_delay 2: color 10: Print "human": _delay 3

Cls: Print: locate ,20-len(title$)/2: color 14: Print title$

Print: Print: color 10
Print "In this game we will play on a 7x7 board";
Print "using seven Chess set Knights each. We"
Print "will take turns by trying to remove each";
Print "other's pieces by landing on them."
Print: color 18
Print "All pieces MUST move in the same manner"
Print "as real chess knights. The first player"
Print "to reach 5 points will be the winner."
Print: Print: color 14
Print "     Press ";: color 10: Print"ENTER ";: color 14: Print "when you are ready."
Do while inkey$ <> chr$(13)
_delay 0.01
loop
Cls
Rem
X = 0: Q1 = O: Q = 0
Randomize Timer
HU = O: CO = O: Rem Scores
For A = 1 To 99
If A > 77 Or A = 70 Or A = 60 Or A = 68 Or A = 69 Or A = 50 Or A = 59 Or A = 40 Or A = 48 Or A = 49 Then GoTo label880
If A = 30 Or A = 38 Or A = 39 Or A = 20 Or A = 28 Or A = 29 Or A = 18 Or A = 19 Or A < 11 Then GoTo label880
H(A) = 46
If A > 70 And A < 78 Then H(A) = 67
If A > 10 And A < 18 Then H(A) = 72

label880:
Next A
For A = 1 To 8: Read Z(A): Next A
Data -8,-21,-12,-19,19,12,21,8
Return