-module(gchess). -compile([no_auto_import, nowarn_unused_vars]). -export([main/0]). -spec main() -> nil. main() -> Game_actor = game_server:from_fen( <<"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"/utf8>> ), game_server:print_board(Game_actor), _pipe = game_server:all_legal_moves(Game_actor), _pipe@1 = gleam@list:map(_pipe, fun move:to_string/1), gleam@list:each(_pipe@1, fun gleam@io:println/1), game_server:apply_move_uci(Game_actor, <<"e2e4"/utf8>>), game_server:print_board(Game_actor). -spec perft(gleam@erlang@process:subject(game_server:message()), integer()) -> integer(). perft(Game_actor, Depth) -> case Depth of 0 -> 1; _ -> Moves = game_server:all_legal_moves(Game_actor), Nodes@2 = gleam@list:fold( Moves, 0, fun(Nodes, Move) -> gleam@io:println(move:to_string(Move)), game_server:apply_move(Game_actor, Move), Nodes@1 = Nodes + perft(Game_actor, Depth - 1), game_server:undo_move(Game_actor), Nodes@1 end ), Nodes@2 end.