Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QBJS - Chess API
#7
(02-08-2026, 06:09 PM)TempodiBasic Wrote: IMHO  you can use Stockfish or any other  chess engines with UCI protocol,(chess engine that uses UCI protocol UCI  protocol for communicating with other programs)
True, but for my purposes, I liked the simplicity of this API.  There is no complicated protocol to negotiate and there are really only a few methods that are needed.

First just use the QBJS Import statement to include the library:
Code: (Select All)
Import Chess From "https://boxgaming.github.io/qbjs-lib/chess/js-chess-engine.bas"

This will load the API and we can use the following methods to interact with the engine:

Move
Move the piece at a given board location to the specified new location
Code: (Select All)
If Chess.Move("C2", "C3") Then
    ' The move was successful
Else
    ' An error occurred, probably an invalid move
    Print Chess.LastErrorMessage
End If

AIMove
Let the engine make the next move using the specified difficulty level
Code: (Select All)
Chess.AIMove 3

Moves
Returns the list of available moves for the piece at the specified board location
Code: (Select All)
ReDim results(0) As String
results = Chess.Moves("C3")
For i = 1 To UBound(results)
    Print results(i)
Next i

BoardPieces
Returns a map containing the board locations with pieces present.
Code: (Select All)
Dim pieces() As String
pieces = Chess.BoardPieces
Print "B1: "; pieces("B1")
Print "E8: "; pieces("E8")
Print "G5: "; pieces("G5")
In the standard beginning positions the above would output:
Code: (Select All)
B1: N
E8: k
G5: 

The only other methods are NewGame, to reset the board for a new game and a few additional functions that return current game state information (IsCheck, IsCheckMate, IsFinished).
Reply


Messages In This Thread
QBJS - Chess API - by dbox - 02-08-2026, 02:17 AM
RE: QBJS - Chess API - by bplus - 02-08-2026, 03:32 PM
RE: QBJS - Chess API - by dbox - 02-08-2026, 06:10 PM
RE: QBJS - Chess API - by TempodiBasic - 02-08-2026, 06:09 PM
RE: QBJS - Chess API - by dbox - 02-08-2026, 08:32 PM
RE: QBJS - Chess API - by bplus - 02-08-2026, 07:04 PM
RE: QBJS - Chess API - by SMcNeill - 02-08-2026, 07:14 PM
RE: QBJS - Chess API - by dbox - 02-08-2026, 08:42 PM
RE: QBJS - Chess API - by TempodiBasic - 02-09-2026, 12:13 AM
RE: QBJS - Chess API - by bplus - 02-09-2026, 12:37 AM
RE: QBJS - Chess API - by TempodiBasic - 02-09-2026, 01:17 AM
RE: QBJS - Chess API - by dbox - 02-09-2026, 04:50 PM
RE: QBJS - Chess API - by TempodiBasic - 02-09-2026, 01:27 AM
RE: QBJS - Chess API - by dbox - 02-10-2026, 05:01 PM
RE: QBJS - Chess API - by bplus - 02-10-2026, 05:53 PM
RE: QBJS - Chess API - by dbox - 02-10-2026, 10:26 PM
RE: QBJS - Chess API - by bplus - 02-10-2026, 11:14 PM
RE: QBJS - Chess API - by dbox - 02-11-2026, 12:58 AM
RE: QBJS - Chess API - by bplus - 02-11-2026, 01:50 AM
RE: QBJS - Chess API - by bplus - 02-12-2026, 07:05 PM
RE: QBJS - Chess API - by dbox - 02-12-2026, 09:45 PM
RE: QBJS - Chess API - by TempodiBasic - 02-12-2026, 07:25 PM
RE: QBJS - Chess API - by bplus - 02-12-2026, 10:15 PM
RE: QBJS - Chess API - by bplus - 02-12-2026, 10:55 PM
RE: QBJS - Chess API - by dbox - 02-13-2026, 01:07 AM
RE: QBJS - Chess API - by TempodiBasic - 02-13-2026, 09:39 AM
RE: QBJS - Chess API - by dbox - 02-13-2026, 05:15 PM
RE: QBJS - Chess API - by bplus - 02-13-2026, 02:30 PM
RE: QBJS - Chess API - by dbox - 02-13-2026, 05:22 PM
RE: QBJS - Chess API - by bplus - 02-13-2026, 06:53 PM
RE: QBJS - Chess API - by TempodiBasic - 02-15-2026, 07:02 PM
RE: QBJS - Chess API - by dbox - 02-15-2026, 08:06 PM
RE: QBJS - Chess API - by bplus - 02-15-2026, 09:08 PM
RE: QBJS - Chess API - by dbox - 02-15-2026, 09:58 PM
RE: QBJS - Chess API - by bplus - 02-15-2026, 10:12 PM
RE: QBJS - Chess API - by TempodiBasic - 02-16-2026, 01:54 AM
RE: QBJS - Chess API - by dbox - 02-16-2026, 02:48 AM
RE: QBJS - Chess API - by TempodiBasic - 02-16-2026, 04:36 PM
RE: QBJS - Chess API - by TempodiBasic - 02-24-2026, 10:49 AM
RE: QBJS - Chess API - by dbox - 02-24-2026, 03:35 PM
RE: QBJS - Chess API - by TempodiBasic - 02-24-2026, 10:23 PM
RE: QBJS - Chess API - by dbox - 02-25-2026, 12:24 PM
RE: QBJS - Chess API - by TempodiBasic - 02-25-2026, 11:11 PM
RE: QBJS - Chess API - by TempodiBasic - 03-01-2026, 07:02 PM
RE: QBJS - Chess API - by dbox - 03-01-2026, 08:20 PM
RE: QBJS - Chess API - by TempodiBasic - 03-02-2026, 09:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Amazing Grace to test out Web Audio API CharlieJV 0 443 11-30-2022, 03:09 AM
Last Post: CharlieJV

Forum Jump:


Users browsing this thread: 1 Guest(s)