Page 1 of 2

Luciole (UCI engine written in Lua)

Posted: Mon May 13, 2019 11:56 pm
by Roland Chastain
Hello!

I would like to present a little engine I have made. It's a Lua script. I called it Luciole.

For now it has a very simple "best move" function, based on material balance after two hafmoves. To give you an idea of its level, here is the result of a quick tournament.

Code: Select all

Rank Name                          Elo     +/-   Games   Score   Draws
   1 Alouette 0.0.5                382     nan      10   90.0%   20.0%
   2 NEG 0.3                         0     144      10   50.0%   60.0%
   3 NEG 1.2                       -35     201      10   45.0%   30.0%
   4 Luciole 0.0.1                 -35     163      10   45.0%   50.0%
   5 Ram 2.0                       -70      92      10   40.0%   80.0%
   6 Iota 0.3                     -147     135      10   30.0%   60.0%
Finished match
To run Luciole, you need a Lua interpreter. The command is "lua luciole.lua".

Here is the source code repository and a package with Windows binaries.

When the UCI interface is finished, it could be used to transform into UCI engines some of the existing Lua chess programs.

Re: Luciole (UCI engine written in Lua)

Posted: Sat May 18, 2019 8:36 pm
by Roland Chastain
Hello! Version 0.0.2 is available. Luciole is now compatible with Linux and can play chess 960.

Luciole is still a very weak opponent but it seems to work correctly.

Code: Select all

Rank Name                          Elo     +/-   Games   Score   Draws
   0 Luciole 0.0.2                -338     nan      12   12.5%    8.3%
   1 Pulsar 2009 9a                inf     nan       4  100.0%    0.0%
   2 ArcBishop80 1.0               inf     nan       4  100.0%    0.0%
   3 Alouette 0.0.5                 89     nan       4   62.5%   25.0%
Finished match
Now I think I will add a perft function.

Re: Luciole (UCI engine written in Lua)

Posted: Sat May 18, 2019 10:01 pm
by mar
Very nice.

Luciole seems to play fixed depth + moves seem a bit random to me though (maybe I'm doing something wrong)

I've noticed you use math.mininteger/math.maxinteger from Lua 5.3, if you replace this with constants, Luciole can be run in LuaJIT http://luajit.org/luajit.html
which is an awesome JIT compiler compatible with Lua 5.1 - depending on what your Lua code does, the speedup can be up to 2 orders of magnitude
over the default interpreter

This could be interesting once Luciole gets more mature (once you implement search and time control), because it'd mean free elo for you

Re: Luciole (UCI engine written in Lua)

Posted: Sat May 18, 2019 11:06 pm
by Roland Chastain
mar wrote: Sat May 18, 2019 10:01 pm Very nice.

Luciole seems to play fixed depth + moves seem a bit random to me though (maybe I'm doing something wrong)
Thank you. No, you are not doing something wrong. There is just a material evaluation on two halfmoves, otherwise the program plays the first move generated.
mar wrote: Sat May 18, 2019 10:01 pm I've noticed you use math.mininteger/math.maxinteger from Lua 5.3, if you replace this with constants, Luciole can be run in LuaJIT http://luajit.org/luajit.html
which is an awesome JIT compiler compatible with Lua 5.1 - depending on what your Lua code does, the speedup can be up to 2 orders of magnitude
over the default interpreter

This could be interesting once Luciole gets more mature (once you implement search and time control), because it'd mean free elo for you
Thank you for the idea. I will give a look to LuaJIT.

Lua script to run Cute Chess CLI under Windows

Posted: Thu May 30, 2019 12:55 am
by Roland Chastain
Hello! Here is a Lua script for tournaments with Cute Chess CLI. Maybe someone will find it useful.

Until now I used to use CMD scripts, but it isn't as comfortable as Lua. :)

Code: Select all

-- tournoi.lua
-- Lua script to run Cute Chess CLI under Windows.
-- Usage:
--   lua tournoi.lua

local cutechess = 'C:\\Roland\\echecs\\outils\\cutechess\\cutechess-cli.exe'
local tee = '"C:\\Program Files (x86)\\Git\\usr\\bin\\tee.exe"'

local cmd = table.concat(
  {
    cutechess,
    '-rounds 4',
    '-variant fischerandom',
    '-engine conf="AICE 0.99.2"',
    '-engine conf="Alouette 0.0.5"',
    '-engine conf="ArcBishop80 1.0"',
    '-engine conf="Galjoen 0.39.2"',
    '-engine conf="Hamsters 0.0.6"',
    '-engine conf="Luciole 0.0.3"',
    '-engine conf="Pulsar 2009 9a"',
    '-engine conf="Roce 0.0390"',
    '-engine conf="Sapeli 1.16"',
    '-engine conf="SlowChess 2.96 UCI"',
    '-engine conf="SMIRF BC-180e"',
    '-pgnout tournoi.pgn',
    '-each tc=40/60',
    '-wait 500'
  },
  ' '
) .. '| ' .. tee .. ' tournoi.log' -- We use tee.exe to have the output in the console and also in a file on disk.

-- In the same directory we must have the file engines.json, taken from the Cute Chess directory and customized.

--print(cmd)
os.execute(cmd)

Re: Luciole (UCI engine written in Lua)

Posted: Thu May 30, 2019 3:29 am
by Roland Chastain
An important bug has been fixed, relative to castling in FRC. The modification suggested by Martin, for LuaJIT compatibility, has been made.

I updated the git repository. I also made a package based on LuaJIT, for all systems (that's why the file is a little big).

Luciole-0.0.3.zip

The speed difference between official Lua and LuaJIT is surprising! Thank you Martin. :wink:

Re: Luciole (UCI engine written in Lua)

Posted: Thu Jan 02, 2020 10:17 am
by Roland Chastain
Hello! I would like to share with you the 2020 version of the Lua script that I use to start CuteChess Cli. I am very glad of it. Sometimes you are glad for a little thing. :)

The difference with the first version is that the script reads engines.json and picks N random engines.

Another difference is that stderr from CuteChess is redirected to a file. I was bored to see "Illegal PV move from ..." As a consequence the error messages are no longer visible in the console.

To use the script, there is a Lua library to download and some little modifications to do, depending on your installation. Please see comments in the code.

Happy new year!

Code: Select all

--[[
  Reads the configuration file of CuteChess Cli (engines.json), picks n random engines and starts
  a tournament with these engines.
  Requires json.lua, cutechess-cli.exe and tee.exe.
  https://github.com/rxi/json.lua
--]]

json = require "json"

function RandomPick(t)
  local i = math.random(#t)
  local n = t[i]
  table.remove(t, i)
  return n
end

local LFile = assert(io.open("engines.json", "r")) -- path to engines.json /!\
local LEngines = json.decode(LFile:read("*all"))
LFile:close()

--for i = 1, #LEngines do print("'" .. LEngines[i].name .. "'") end
--os.exit()

local LIndices = {}
local LSelected = {}
math.randomseed(os.time())
for i = 1, #LEngines do table.insert(LIndices, i) end
for i = 1, 4 do table.insert(LSelected, RandomPick(LIndices)) end -- I need four engines

local cutechess = "C:\\Roland\\echecs\\outils\\cutechess\\cutechess-cli.exe" -- path to cutechess-cli /!\
local tee = "C:\\MinGW\\msys\\1.0\\bin\\tee.exe" -- path to tee.exe /!\

local cmd = table.concat(
  {
    cutechess,
    "-rounds 2",
    '-engine conf="Arminius 2017 RND"', -- I want that engine to be always in the tournament
    '-engine conf="' .. LEngines[LSelected[1]].name .. '"',
    '-engine conf="' .. LEngines[LSelected[2]].name .. '"',
    '-engine conf="' .. LEngines[LSelected[3]].name .. '"',
    '-engine conf="' .. LEngines[LSelected[4]].name .. '"',
    '-pgnout tournoi.pgn',
    '-each tc=40/60',
    '-wait 500 2>> error.log | ' .. tee .. ' tournoi.log' -- Errors will be visible only in the file error.log  /!\
  },
  ' '
)
--print(cmd)

os.execute(cmd)

Luciole 0.0.5

Posted: Tue Dec 28, 2021 11:33 pm
by Roland Chastain
I finally took the time to look for the error that caused Luciole to disconnect from time to time during a tournament. It was (again) an error in castling. Once the error fixed, I could run a gauntlet of 500 games without disconnection nor illegal move. So I release it as version 0.0.5.

The playing style is still very boring, with many repetitive moves. I will see what I can do to improve it a little.

For information, here is how I include Luciole in a tournament with cutechess-cli:

Code: Select all

-engine name="Luciole 0.0.5" cmd="lua" dir="luciole-005" arg="luciole.lua" proto=uci stderr="luciole-005.err"
It is possible to use luajit instead of lua. (For now it won't make the engine play better, but only faster.)

Re: Luciole (UCI engine written in Lua)

Posted: Wed Dec 29, 2021 12:28 am
by Roland Chastain
In xboard it works perfectly. 8-)

Image

Image

Re: Luciole (UCI engine written in Lua)

Posted: Wed Dec 29, 2021 12:46 am
by tmokonen
It works fine in Arena as well, with an Arena GUI book.