We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UCI Chess Engine
#1
After finding out how to access the UCI interface with the help of an introductory video, it is now possible to write a chess engine with Small Basic that can be integrated into chess programs.
The C# videos and further information can be found in the following thread: https://litdev.uk/mybb/showthread.php?tid=74

But there is still a long way to go to the first usable engine.
The 4 episodes of the C# video tutorial must be implemented in Small Basic and in C# programs.


Episode 1: Hello World

Code:
'Position Textwindow
TextWindow.Left = Desktop.Width/2+1
TextWindow.Top    = Desktop.Height/2+200
'Movelist for black
Move[1] = "bestmove e7e5"
Move[2] = "bestmove a7a6"
Move[3] = "bestmove b7b5"
Move[4] = "bestmove g8f6"
Move[5] = "bestmove g7g6"
Move[6] = "bestmove h7h5"
Move[7] = "bestmove f8g7"
Move[8] = "bestmove b8c6"
Movecount = 1
'LDTextWindow.Hide()
LDTextWindow.UpdateShowHide = "False"
LDTextWindow.Minimise()
While ("True")
  'TextWindow.PauseIfVisible()
  commandline = TextWindow.Read()
  command = LDText.Split(commandline," ")
  if(command[1] = "uci") Then
    TextWindow.WriteLine("uciok")
  ElseIf(command[1] = "isready") Then
    TextWindow.WriteLine("readyok")
  ElseIf(command[1] = "position") Then
    'Board Update
  elseif(command[1] = "go") Then
    'TextWindow.WriteLine("bestmove e7e5")
    TextWindow.WriteLine(Move[Movecount])
    Movecount = Movecount + 1
  Else
    TextWindow.WriteLine("info string "+ commandline)
  endif
  Program.Delay(7)  
EndWhile

Integrating the exe file as an engine into a chess program is described in the C# thread and in the videos.

   

What is also annoying is that the text window cannot be hidden and it has no content.
But since it can be moved to the side, it is still acceptable.

Update: 
With the features LDTextWindow.UpdateShowHide = "False" and LDTextWindow.Minimise() the text window can be minimized to the taskbar.
This requires the Litdev extension 1.2.28.0 or higher. Alternatively, the two lines can be commented out and the text window will appear on the screen.

Note:
If the SB_UCI.exe engine is distributed or copied to another directory, the DLLs Litdev.dll and SmallBasicLibrary.dll must also be included!
[-] The following 2 users Like Scout's post:
  • AbsoluteBeginner, litdev
Reply


Messages In This Thread
UCI Chess Engine - by Scout - 05-22-2024, 09:44 PM
RE: UCI Chess Engine - by litdev - 05-23-2024, 05:21 PM
RE: UCI Chess Engine - by Scout - 05-23-2024, 06:38 PM
RE: UCI Chess Engine - by litdev - 05-23-2024, 07:48 PM
RE: UCI Chess Engine - by litdev - 05-24-2024, 08:36 PM
RE: UCI Chess Engine - by Scout - 05-24-2024, 09:46 PM
RE: UCI Chess Engine - by litdev - 06-03-2024, 10:23 PM
RE: UCI Chess Engine - by AbsoluteBeginner - 06-04-2024, 08:42 AM
RE: UCI Chess Engine - by litdev - 06-04-2024, 02:02 PM
RE: UCI Chess Engine - by AbsoluteBeginner - 06-04-2024, 04:06 PM
RE: UCI Chess Engine - by WhTurner - 06-04-2024, 05:42 PM

Forum Jump:


Users browsing this thread: 10 Guest(s)