SunFish Chess bot - Script Writing - CHDK Forum  

SunFish Chess bot

  • 5 Replies
  • 964 Views
SunFish Chess bot
« on: 22 / July / 2022, 15:02:45 »
Advertisements
i was wondering if there was any way of getting the Sunfish chess bot working on the camera.
https://github.com/soumith/sunfish.lua
i have tried replacing all ¨math¨ to imath and getting input with textbox, it shows no errors but nothing happens. is this even possible to do?

*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: SunFish Chess bot
« Reply #1 on: 22 / July / 2022, 16:05:15 »
Code: [Select]
local function printboard(board)
https://chdk.fandom.com/wiki/Script_commands#set_console_layout
There´s also need to reorganize the output, with "cls" & print(),...  ???
All lifetime is a loan from eternity.

Re: SunFish Chess bot
« Reply #2 on: 23 / July / 2022, 05:41:51 »
i think i have managed to fix these things, but now i am getting an error because there is nothing in the imath library for imath.abs, i will try to make a function to do this.

Re: SunFish Chess bot
« Reply #3 on: 23 / July / 2022, 08:04:39 »
i just had to replace all instances of imath.abs to math.abs, now it seems to be doing something but i cant see anything.


*

Offline reyalp

  • ******
  • 14084
Re: SunFish Chess bot
« Reply #4 on: 23 / July / 2022, 16:45:51 »
i just had to replace all instances of imath.abs to math.abs, now it seems to be doing something but i cant see anything.
I wouldn't assume you can just drop in imath as a replacement for math, you'll need to verify that the logic still makes sense. Note in CHDK 1.6, you can use fmath instead, which is closer since it lets you use floating point, but will still need some adaptation since fmath is based on userdata rather than native numbers.

As far as the script "doing nothing", do you mean that you run the script by selecting and then pressing the shutter in alt mode, and the script starts, but produces no output and doesn't end until you press the shutter again? Or something else?

My approach generally would be start putting in print statements to understand what parts of the code are actually executing.

One other thing I didn't see immediately on github page is what Lua version the script is written for. CHDK Lua is 5.1, so code written for other versions may need to be adjusted.
Don't forget what the H stands for.

Re: SunFish Chess bot
« Reply #5 on: 24 / July / 2022, 03:01:37 »
yes, i shall look into what version it is running on, the script does start and the textbox comes and takes my input, but when correct input is given it just closes the textbox, but dosent end the script, i assume it might just be very slow, i shall make each function print something when its run so i can see what it is working on.