Luciole (UCI engine written in Lua)

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Luciole (UCI engine written in Lua)

Post 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.
Qui trop embrasse mal étreint.
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Luciole (UCI engine written in Lua)

Post 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.
Qui trop embrasse mal étreint.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Luciole (UCI engine written in Lua)

Post 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
Martin Sedlak
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Luciole (UCI engine written in Lua)

Post 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.
Qui trop embrasse mal étreint.
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Lua script to run Cute Chess CLI under Windows

Post 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)
Qui trop embrasse mal étreint.
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Luciole (UCI engine written in Lua)

Post 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:
Qui trop embrasse mal étreint.
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Luciole (UCI engine written in Lua)

Post 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)
Qui trop embrasse mal étreint.
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Luciole 0.0.5

Post 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.)
Qui trop embrasse mal étreint.
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Luciole (UCI engine written in Lua)

Post by Roland Chastain »

In xboard it works perfectly. 8-)

Image

Image
Qui trop embrasse mal étreint.
tmokonen
Posts: 1296
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: Luciole (UCI engine written in Lua)

Post by tmokonen »

It works fine in Arena as well, with an Arena GUI book.