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.