04-08-2026, 04:51 AM (This post was last modified: 04-08-2026, 04:52 AM by johnno56.)
Knightbridge is a simple board game between a player and the computer. Each player has a set of Chess Knights. Each player takes turn in moving one piece per turn. Each piece MUST move in the same manner as a Chess Knight. Two squares forward then one square left or right.
The object of the game is to "capture" your opponent by "landing" on it. The first player to capture Five pieces wins.
Run the game. Select the level of difficulty. Click on your Knight (it will then be highlighted) then click on the target square.
During the game, if you like, you can change the look of the board by pressing "A", "B", "C" or "D"
The original game was displayed using text only with a 7x7 board and a single row of Knights each.
(04-08-2026, 04:51 AM)johnno56 Wrote: Knightbridge is a simple board game between a player and the computer. Each player has a set of Chess Knights. Each player takes turn in moving one piece per turn. Each piece MUST move in the same manner as a Chess Knight. Two squares forward then one square left or right.
The object of the game is to "capture" your opponent by "landing" on it. The first player to capture Five pieces wins.
Run the game. Select the level of difficulty. Click on your Knight (it will then be highlighted) then click on the target square.
During the game, if you like, you can change the look of the board by pressing "A", "B", "C" or "D"
The original game was displayed using text only with a 7x7 board and a single row of Knights each.
04-08-2026, 06:15 PM (This post was last modified: 04-08-2026, 06:16 PM by johnno56.)
Play time is quite short... but, back in the early days (pre 1985), CPU's and memory were not like they are today. This was OH SO much slower back then... in text none the less!
This is how the original looked... I still have the listing... Line numbers and all... lol
function init_board()
for r = 0 to BOARD_SIZE - 1
for c = 0 to BOARD_SIZE - 1
board[r][c] = 0
next
next
' AI knights (top two rows, staggered)
for c = 0 to BOARD_SIZE - 1 step 2
board[0][c] = AI_PLAYER
next
for c = 1 to BOARD_SIZE - 1 step 2
board[1][c] = AI_PLAYER
next
' Human knights (bottom two rows, staggered)
for c = 1 to BOARD_SIZE - 1 step 2
board[2][c] = HUMAN
next
for c = 0 to BOARD_SIZE - 1 step 2
board[3][c] = HUMAN
next
captures[1] = 0
captures[2] = 0
endfunc
function is_valid_knight_move(sr, sc, tr, tc, player)
dr = abs(tr - sr)
dc = abs(tc - sc)
'Verify Knight's L-Shape move
if (dr = 1 and dc = 2) or (dr = 2 and dc = 1) then
if tr >= 0 and tr < BOARD_SIZE and tc >= 0 and tc < BOARD_SIZE then
if board[tr][tc] = 0 or board[tr][tc] <> player then
return true
endif
endif
endif
return false
endfunc
function do_move(sr, sc, tr, tc)
'whose piece is moving, 1=human, 2=computer
mover = board[sr][sc]
'read what's currently on the destination square (tr,tc)
'0=empty, 1=human, 2=computer
captured = board[tr][tc]
'place the piece on destination
board[tr][tc] = mover
board[sr][sc] = 0
'check if a capture occured
if captured <> 0 then
captures[mover] = captures[mover] + 1
if captures[mover] >= 3 then 'victory condition
game_over = true
winner = mover
endif
endif
endfunc
function draw_board()
set color 0, 0, 0; cls
for r = 0 to BOARD_SIZE - 1
for c = 0 to BOARD_SIZE - 1
if (r + c) % 2 = 0 then
set color 200, 220, 200
else
set color 100, 140, 100
endif
draw rect BOARD_X + c * SQUARE_SIZE, BOARD_Y + r * SQUARE_SIZE,
SQUARE_SIZE, SQUARE_SIZE, true
next
next
for r = 0 to BOARD_SIZE - 1
for c = 0 to BOARD_SIZE - 1
if board[r][c] > 0 then
x = BOARD_X + c * SQUARE_SIZE + 5
y = BOARD_Y + r * SQUARE_SIZE
if board[r][c] = HUMAN then
draw image white, x, y
else
draw image black, x, y
endif
endif
next
next
' Highlight AI's last move FROM
if last_ai_fr >= 0 then
x = BOARD_X + last_ai_fc * SQUARE_SIZE
y = BOARD_Y + last_ai_fr * SQUARE_SIZE
set color 255, 0, 0
draw rect x, y, SQUARE_SIZE, SQUARE_SIZE, false
draw rect x+2, y+2, SQUARE_SIZE-4, SQUARE_SIZE-4, false
endif
' Highlight AI's last move TO
if last_ai_tr >= 0 then
x = BOARD_X + last_ai_tc * SQUARE_SIZE
y = BOARD_Y + last_ai_tr * SQUARE_SIZE
set color 255, 0, 0
draw rect x, y, SQUARE_SIZE, SQUARE_SIZE, false
draw rect x+2, y+2, SQUARE_SIZE-4, SQUARE_SIZE-4, false
endif
' Hightlight Human Knight
if selected_r >= 0 then
x = BOARD_X + selected_c * SQUARE_SIZE
y = BOARD_Y + selected_r * SQUARE_SIZE
set color 0, 255, 0
draw rect x, y, SQUARE_SIZE, SQUARE_SIZE, false
draw rect x+2, y+2, SQUARE_SIZE-4, SQUARE_SIZE-4, false
endif
if game_over then
set color 0, 0, 0
draw rect BOARD_X + 20, BOARD_Y + 50, 200, 110, true
set color 255, 255, 255
draw rect BOARD_X + 22, BOARD_Y + 52, 196, 106, false
if winner = HUMAN then
set color 0, 255, 0
set caret BOARD_X + 120, BOARD_Y + 80
center "YOU WIN!"
else
set color 255, 0, 0
set caret BOARD_X + 120, BOARD_Y + 80
center "AI WINS!"
endif
set color 255, 255, 255
set caret BOARD_X + 120, BOARD_Y + 105
center "Restart (Y/N)?"
endif
endfunc
'Step 2 : Scan the entire board
for r = 0 to BOARD_SIZE - 1
for c = 0 to BOARD_SIZE - 1
'Step 3 : find AI Knights
if board[r][c] = AI_PLAYER then
'Step 4 : Test all 8 moves
for k = 0 to 7
nr = r + knight_dy[k]
nc = c + knight_dx[k]
'Step 5 : validate the move
if is_valid_knight_move(r, c, nr, nc, AI_PLAYER) then
'Step 6 : prioritize to capture
if board[nr][nc] = HUMAN then
do_move(r, c, nr, nc)
last_ai_fr = r ; last_ai_fc = c
last_ai_tr = nr ; last_ai_tc = nc
current_turn = HUMAN
return
endif
'Step 7 : first valid non-capture move
if fr = -1 then
fr = r ; fc = c ; tr = nr ; tc = nc
endif
endif
next
endif
next
next
'Step 8 : if no capture was found
if fr <> -1 then
do_move(fr, fc, tr, tc)
last_ai_fr = fr ; last_ai_fc = fc
last_ai_tr = tr ; last_ai_tc = tc
endif
Thanks for posting these Johnno and Micha, great fun. I really enjoy puzzle games, and games like these, but struggle with the game logic, particularly when computer opponents are involved. I guess I need to try harder