luataxx, an Ataxx engine written in Lua

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

Moderators: hgm, Rebel, chrisw

JohnWoe
Posts: 491
Joined: Sat Mar 02, 2013 11:31 pm

luataxx, an Ataxx engine written in Lua

Post by JohnWoe »

I have been working on my implementation of Ataxx engine for some time.
I started with 0 Lua (programming language) knowledge so it took me while to get things rolling.
Lua is definitely good language and not even slow. luataxx is generating moves 400knps on my slow CPU. Pretty good and only getting faster as I improve the code.

Source code: https://github.com/SamuraiDangyo/luataxx
Initial release: https://github.com/SamuraiDangyo/luatax ... /tag/v1.01

Some information of luataxx.
- First Lua Ataxx engine?!
- luataxx generates real moves not boards like Sapeli. Ataxx is 100x easier game for mgen than Chess960.
- luataxx supports uai - protocol
- luataxx supports boards 5x5 -> 20x20
- luataxx can be used without GUI. luataxx has very pretty and clear command line board.
- luataxx can solve simple tactics 100% and beats "Random Mover" almost 100% score.
- to enter uai mode luataxx needs -uai handle at start

Thanks to Ronald Chastain's(Luciolette) Lua uci implementation and python-ataxx for Unicodes. Saved some time for me!

Human vs luataxx on 5x5 board:

Code: Select all

./luataxx.lua -think 3000 -width 5 -height 5 -play 2
   a b c d e 
  ╔═╦═╦═╦═╦═╗
5 ║X║ ║ ║ ║X║ 5  ( white: 7 )
  ╠═╬═╬═╬═╬═╣
4 ║X║X║ ║ ║ ║ 4  ( black: 0 )
  ╠═╬═╬═╬═╬═╣
3 ║#║ ║ ║ ║ ║ 3  ( turn: O )
  ╠═╬═╬═╬═╬═╣
2 ║ ║ ║ ║ ║ ║ 2  ( rule50: 0 )
  ╠═╬═╬═╬═╬═╣
1 ║X║X║X║ ║ ║ 1 
  ╚═╩═╩═╩═╩═╝
   a b c d e 
[pgn][Event "Computer Ataxx game"] [Site "luataxx.lua"] [White "AI"] [Black "Human"] [BoardWidth "5"] [BoardHeight "5"] [Fen "o3x/5/-4/5/x3o x"] [Date "2019.11.04"] [TimeControl "3s/move"] [Result "1-0"] a1b2 e1c1 a1b1 a5a4 b2b4 {luataxx adjudication: black has no pieces left ( White wins by 7 points )} 1-0[/pgn]

luataxx vs luataxx on 9x9 board

Code: Select all

./luataxx.lua -think 10000 -width 9 -height 9 -play 3
   a b c d e f g h i 
  ╔═╦═╦═╦═╦═╦═╦═╦═╦═╗
9 ║O║X║X║X║O║O║X║X║X║ 9  ( white: 66 )
  ╠═╬═╬═╬═╬═╬═╬═╬═╬═╣
8 ║O║O║X║X║O║O║X║X║X║ 8  ( black: 14 )
  ╠═╬═╬═╬═╬═╬═╬═╬═╬═╣
7 ║O║O║X║X║X║X║X║X║X║ 7  ( turn: O )
  ╠═╬═╬═╬═╬═╬═╬═╬═╬═╣
6 ║O║O║O║X║X║X║X║X║O║ 6  ( rule50: 3 )
  ╠═╬═╬═╬═╬═╬═╬═╬═╬═╣
5 ║X║X║X║X║X║X║X║X║O║ 5 
  ╠═╬═╬═╬═╬═╬═╬═╬═╬═╣
4 ║X║X║X║X║X║X║X║X║X║ 4 
  ╠═╬═╬═╬═╬═╬═╬═╬═╬═╣
3 ║X║#║X║X║X║X║X║X║X║ 3 
  ╠═╬═╬═╬═╬═╬═╬═╬═╬═╣
2 ║X║X║X║X║X║X║X║X║X║ 2 
  ╠═╬═╬═╬═╬═╬═╬═╬═╬═╣
1 ║X║X║X║X║X║X║X║X║X║ 1 
  ╚═╩═╩═╩═╩═╩═╩═╩═╩═╝
   a b c d e f g h i 
[pgn][Event "Computer Ataxx game"] [Site "luataxx.lua"] [White "AI"] [Black "AI"] [BoardWidth "9"] [BoardHeight "9"] [Fen "o7x/9/9/9/9/9/1-7/9/x7o x"] [Date "2019.11.04"] [TimeControl "10s/move"] [Result "1-0"] i9i8 a9b8 i8g8 i1g3 i9h8 g3e3 g8g9 a9a8 a1b2 a8c6 h8f6 b8b6 g8f9 b6d8 g8f7 e3f5 f7e7 c6e6 i9i8 e7g7 d8f8 f6h8 f9h9 g7h7 f8g6 e6d7 a1b1 d7f8 b1d2 a9b8 h7f9 f7h7 d2f4 h7i6 b2a4 i6i7 f4g3 i7h5 f5e5 h5h6 f4g4 b8c8 a1c3 h8f6 h5i4 g6f7 g9h8 f8e9 h5i7 e5d5 c3a3 f6h5 f4f6 f9d9 g8f9 b8c9 g3h3 i6i5 g3g2 c8a8 a4b4 h5h4 e9d8 h4f4 g2g1 h5h4 g2f3 a8b7 g1i1 d5e3 g4g5 b8a7 g3h2 b7c6 i1i3 e5d7 a3c4 c6c7 h2i1 d7e8 h2g1 f7e7 h3i2 c7c8 a4a6 a8b6 g3e2 a6c5 i3h1 e6d6 g1i3 b4d5 i2g1 c7b9 e3g3 b8c7 e2c1 c8a8 g2f2 c7a6 h2i2 d9c8 c1c3 c6b5 c3a2 c4b4 a2c1 a7c7 g2e3 b6d4 h3g2 b4a4 g2f1 c4b6 c1c2 d4d2 f4e4 c6a5 e4e5 b6c6 g2e1 b6d4 g3g2 b4a2 e1e2 c1d1 e3d3 c8b6 e6c8 a6a7 d7e6 a4c3 d5c4 a2a4 c3b4 c1a1 b4a3 a1c1 c3b2 d1b1 e2d1 b1a1 a3a2 0000 0000 {luataxx adjudication: 2 passes in row ( White wins by 52 points )} 1-0[/pgn]
User avatar
flok
Posts: 481
Joined: Tue Jul 03, 2018 10:19 am
Full name: Folkert van Heusden

Re: luataxx, an Ataxx engine written in Lua

Post by flok »

JohnWoe wrote: Mon Nov 04, 2019 1:28 pm I have been working on my implementation of Ataxx engine for some time.
I started with 0 Lua (programming language) knowledge so it took me while to get things rolling.
Lua is definitely good language and not even slow. luataxx is generating moves 400knps on my slow CPU. Pretty good and only getting faster as I improve the code.

Source code: https://github.com/SamuraiDangyo/luataxx
Initial release: https://github.com/SamuraiDangyo/luatax ... /tag/v1.01

Some information of luataxx.
- First Lua Ataxx engine?!
- luataxx generates real moves not boards like Sapeli. Ataxx is 100x easier game for mgen that Chess960.
- luataxx supports uai - protocol
- luataxx supports boards 5x5 -> 20x20
- luataxx can be used without GUI. luataxx has very pretty and clear command line board.
- luataxx can solve simple tactics 100% and beats "Random Mover" almost 100% score.
- to enter uai mode luataxx needs -uai handle at start
Very cool!
Will you let it run on server.ataxx.org?
User avatar
flok
Posts: 481
Joined: Tue Jul 03, 2018 10:19 am
Full name: Folkert van Heusden

Re: luataxx, an Ataxx engine written in Lua

Post by flok »

flok wrote: Mon Nov 04, 2019 1:33 pm
JohnWoe wrote: Mon Nov 04, 2019 1:28 pm I have been working on my implementation of Ataxx engine for some time.
I started with 0 Lua (programming language) knowledge so it took me while to get things rolling.
Lua is definitely good language and not even slow. luataxx is generating moves 400knps on my slow CPU. Pretty good and only getting faster as I improve the code.

Source code: https://github.com/SamuraiDangyo/luataxx
Initial release: https://github.com/SamuraiDangyo/luatax ... /tag/v1.01

Some information of luataxx.
- First Lua Ataxx engine?!
- luataxx generates real moves not boards like Sapeli. Ataxx is 100x easier game for mgen that Chess960.
- luataxx supports uai - protocol
- luataxx supports boards 5x5 -> 20x20
- luataxx can be used without GUI. luataxx has very pretty and clear command line board.
- luataxx can solve simple tactics 100% and beats "Random Mover" almost 100% score.
- to enter uai mode luataxx needs -uai handle at start
Very cool!
Will you let it run on server.ataxx.org?
Tried to run it on, but it says "Bad fen":

Code: Select all

root@freytus:~/data/Ataxx/luataxx/src# ./run.sh
position fen 4o2/1xxx3/2x4/7/7/7/o5x o 0 3
Bad fen
JohnWoe
Posts: 491
Joined: Sat Mar 02, 2013 11:31 pm

Re: luataxx, an Ataxx engine written in Lua

Post by JohnWoe »

flok wrote: Mon Nov 04, 2019 1:40 pm
flok wrote: Mon Nov 04, 2019 1:33 pm
JohnWoe wrote: Mon Nov 04, 2019 1:28 pm I have been working on my implementation of Ataxx engine for some time.
I started with 0 Lua (programming language) knowledge so it took me while to get things rolling.
Lua is definitely good language and not even slow. luataxx is generating moves 400knps on my slow CPU. Pretty good and only getting faster as I improve the code.

Source code: https://github.com/SamuraiDangyo/luataxx
Initial release: https://github.com/SamuraiDangyo/luatax ... /tag/v1.01

Some information of luataxx.
- First Lua Ataxx engine?!
- luataxx generates real moves not boards like Sapeli. Ataxx is 100x easier game for mgen that Chess960.
- luataxx supports uai - protocol
- luataxx supports boards 5x5 -> 20x20
- luataxx can be used without GUI. luataxx has very pretty and clear command line board.
- luataxx can solve simple tactics 100% and beats "Random Mover" almost 100% score.
- to enter uai mode luataxx needs -uai handle at start
Very cool!
Will you let it run on server.ataxx.org?
Tried to run it on, but it says "Bad fen":

Code: Select all

root@freytus:~/data/Ataxx/luataxx/src# ./run.sh
position fen 4o2/1xxx3/2x4/7/7/7/o5x o 0 3
Bad fen
Thanks for testing luataxx!

uai - protocol was not much tested so there was this bug. There isn't something like XBoard for Ataxx to test things in and out.
This was wrong. https://github.com/SamuraiDangyo/luatax ... en.lua#L57
I fixed it in dev branch: https://github.com/SamuraiDangyo/luataxx/tree/dev
User avatar
flok
Posts: 481
Joined: Tue Jul 03, 2018 10:19 am
Full name: Folkert van Heusden

Re: luataxx, an Ataxx engine written in Lua

Post by flok »

JohnWoe wrote: Mon Nov 04, 2019 1:52 pm Thanks for testing luataxx!

uai - protocol was not much tested so there was this bug. There isn't something like XBoard for Ataxx to test things in and out.
This was wrong. https://github.com/SamuraiDangyo/luatax ... en.lua#L57
I fixed it in dev branch: https://github.com/SamuraiDangyo/luataxx/tree/dev
It plays an invalid move in UAI mode:

Code: Select all

Mon Nov  4 14:05:50 2019 luataxx 1.02) 6o/2x4/3x3/7/2o4/1o3x1/o5x o 0 3 => g1f1 (0.037430)
Mon Nov  4 14:05:50 2019 luataxx 1.02) move is in invalid: ValueError g1f1
Mon Nov  4 14:05:50 2019 Illegal move by luataxx 1.02: g1f1
Mon Nov  4 14:05:50 2019 Randoxx(randoxx-rpi3b) versus luataxx 1.02(luataxx-rpi3b): * (Illegal move by white)
This might, i'm not entirely sure, because it is encoded in long format.
The parser of the server (which is using python-ataxx underneath) is rather picky about that.
User avatar
flok
Posts: 481
Joined: Tue Jul 03, 2018 10:19 am
Full name: Folkert van Heusden

Re: luataxx, an Ataxx engine written in Lua

Post by flok »

The latest version won't start:

Code: Select all

lua: ./myuai.lua:19: bad argument #2 to 'format' (string expected, got nil)
stack traceback:
        [C]: in function 'format'
        ./myuai.lua:19: in function 'command_uai'
        ./myuai.lua:92: in function 'uai'
        ./mycli.lua:132: in function 'go'
        luataxx.lua:11: in function 'main'
        luataxx.lua:14: in main chunk
        [C]: ?
JohnWoe
Posts: 491
Joined: Sat Mar 02, 2013 11:31 pm

Re: luataxx, an Ataxx engine written in Lua

Post by JohnWoe »

flok wrote: Mon Nov 04, 2019 8:26 pm The latest version won't start:

Code: Select all

lua: ./myuai.lua:19: bad argument #2 to 'format' (string expected, got nil)
stack traceback:
        [C]: in function 'format'
        ./myuai.lua:19: in function 'command_uai'
        ./myuai.lua:92: in function 'uai'
        ./mycli.lua:132: in function 'go'
        luataxx.lua:11: in function 'main'
        luataxx.lua:14: in main chunk
        [C]: ?
Thanks for the bug report! Lots of bugs have been fixed. I added myconsts module and forgot to change things.

I would like to add more tactics in luataxx tactical suite.
I think some tactical suite on 7x7 board for Ataxx engines would be great.

I played a game against luataxx on 5x5 board. And won! There is lots of weaknesses in his search. But you can play a game no problem.

Code: Select all

[Event "Computer Ataxx game"]
[Site "luataxx.lua"]
[White "AI"]
[Black "Human"]
[BoardWidth "5"]
[BoardHeight "5"]
[Fen "o3x/2-2/--3/5/x3o x"]
[Date "2019.11.05"]
[TimeControl "1s/move"]
[Result "0-1"]
e5e4 e1d1 e4e2 a5a4 e5c3 a4b4 e1c1 c3d2 a1b2 d2c2 a1a2 c2b1 {luataxx adjudication: white has no pieces left ( Black wins by 13 points )} 0-1

luataxx scores now 98% against random mover. No illegal moves.

Code: Select all

...{ game = 87, result = 1-0, reason = 2 passes in row }
{ game = 88, result = 1-0, reason = black has no pieces left }
{ game = 89, result = 1-0, reason = 2 passes in row }
{ game = 90, result = 1-0, reason = 2 passes in row }
{ game = 91, result = 1-0, reason = 2 passes in row }
{ game = 92, result = 1-0, reason = 2 passes in row }
{ game = 93, result = 1-0, reason = black has no pieces left }
{ game = 94, result = 1-0, reason = 2 passes in row }
{ game = 95, result = 1-0, reason = 2 passes in row }
{ game = 96, result = 1-0, reason = black has no pieces left }
{ game = 97, result = 1-0, reason = 2 passes in row }
{ game = 98, result = 1-0, reason = black has no pieces left }
{ game = 99, result = 1-0, reason = 2 passes in row }
{ game = 100, result = 1-0, reason = black has no pieces left }
{ game = 101, result = 1-0, reason = black has no pieces left }

{ # Results
  wins   = 97,
  losses = 0,
  draws  = 4,
  score  = 98.02
}
Made Reversi engine from luataxx as well. These 2 games are pretty similar. :P

Code: Select all

[Event "Computer Reversi game"]
[Site "MyReversi.lua"]
[White "AI"]
[Black "AI"]
[BoardWidth "8"]
[BoardHeight "8"]
[Fen "8/8/8/3ox3/3xo3/8/8/8 x"]
[Date "2019.11.05"]
[TimeControl "1s/move"]
[Result "1-0"]
e5e3 d5f5 e4g6 d5f3 d4d6 e4h7 d4f6 f5c5 d4f4 g6e6 d4g7 e6c6 f6b6 g6a6 g7g5 f6h4 e5c7 c5f2 e4e2 g5g8 e4b7 f2d2 b7b5 c5a7 e3g1 f3f1 e5c3 f3d3 e4e1 f3a8 e5h5 f1h1 c7a5 a6a4 d4d1 f3b3 e2g2 h4h6 g5e7 c6c8 b6d8 f1c1 f5d7 f3f7 b6b8 c6e8 f2f8 d1g4 f8h8 e2h2 h8h3 a6c4 e6a2 c3a3 b6b4 a3a1 b4b2 a4c2 f5b1 0000 d3g3 0000 0000 {MyReversi adjudication: 2 passes in row ( White wins by 8 points )} 1-0