Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Documentation

nb/docs.livemd

Documentation

Bitboard

use Bitwise
import Bitboard.Bit
board = Bitboard.standard()
IO.puts(board)
{:ok, board} = board |> Bitboard.put(~b"f5", :black)
IO.puts(board)
board |> Bitboard.moves_for(:white) |> Bitboard.spread() |> Enum.map(&to_str/1)
{:ok, board} = board |> Bitboard.put(~b"F4", :white)
{:ok, board} = board |> Bitboard.put(~b"E3", :black)
IO.puts(board)

GameState

play_seq = ~B(D3C5D6E3B4C3D2C4F4)
alias Acaster.GameState
alias Acaster.GameState.NotStartedState
alias Acaster.Game.TimeControl
alias Acaster.Game.NoClock

gs = %NotStartedState{
  board: Bitboard.standard(),
  tc: %TimeControl{black: %NoClock{}, white: %NoClock{}},
  first: :black
}

IO.puts(gs)

play_seq
|> Enum.scan(gs |> GameState.start(), &GameState.emplace(&2, &1))
|> Enum.each(&IO.puts/1)

Glicko

%Glicko.Match{o: Glicko.simple(1400.0, 30.0), r: :win}
r = Glicko.simple(1500.0, 200.0)

r =
  r
  |> Glicko.update([
    %Glicko.Match{o: Glicko.simple(1400.0, 30.0), r: :win},
    %Glicko.Match{o: Glicko.simple(1550.0, 100.0), r: :loss},
    %Glicko.Match{o: Glicko.simple(1700.0, 300.0), r: :loss}
  ])

IO.puts(Glicko.rating(r))
IO.puts(Glicko.stdev(r))
1..10 |> Enum.reduce(MapSet.new(), &MapSet.put(&2, &1))
alias Acaster.MatcherServer
{:ok, ms} = MatcherServer.start_link([])
ms |> MatcherServer.register(UUID.uuid4())
ms |> MatcherServer.list()
ms
|> MatcherServer.unregister(%Acaster.MatcherServer.Ticket{
  id: "d2e7c87c-c639-4a30-9db2-a5892c887386",
  player: "5b0db865-e2d9-40c9-b832-7c90fd5d5fa8"
})
ms |> MatcherServer.list()
ms |> MatcherServer.run_wave()
ms |> MatcherServer.list()