A chess library for Gleam

Remove birl dependency and use manual bindings

-1
gleam.toml
··· 15 15 [dependencies] 16 16 gleam_stdlib = ">= 0.44.0 and < 2.0.0" 17 17 iv = ">= 1.3.2 and < 2.0.0" 18 - birl = ">= 1.8.0 and < 2.0.0" 19 18 20 19 [dev-dependencies] 21 20 gleeunit = ">= 1.0.0 and < 2.0.0"
-1
manifest.toml
··· 17 17 ] 18 18 19 19 [requirements] 20 - birl = { version = ">= 1.8.0 and < 2.0.0" } 21 20 gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } 22 21 gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 23 22 iv = { version = ">= 1.3.2 and < 2.0.0" }
+6 -3
src/starfish.gleam
··· 1 - import birl 2 1 import gleam/bool 3 2 import gleam/list 4 3 import gleam/result ··· 153 152 let until = case cutoff { 154 153 Depth(depth:) -> fn(current_depth) { current_depth > depth } 155 154 Time(milliseconds:) -> { 156 - let end_time = birl.monotonic_now() + milliseconds * 1000 157 - fn(_) { birl.monotonic_now() >= end_time } 155 + let end_time = monotonic_time() + milliseconds 156 + fn(_) { monotonic_time() >= end_time } 158 157 } 159 158 } 160 159 161 160 result.map(search.best_move(game.game, until), Move) 162 161 } 162 + 163 + @external(erlang, "starfish_ffi", "monotonic_time") 164 + @external(javascript, "./starfish_ffi.mjs", "monotonic_time") 165 + fn monotonic_time() -> Int 163 166 164 167 pub fn apply_move(game: Game, move: Move) -> Game { 165 168 Game(move.apply(game.game, move.move))
+9
src/starfish_ffi.erl
··· 1 + -module(starfish_ffi). 2 + 3 + -export([monotonic_time/0]). 4 + 5 + monotonic_time() -> 6 + StartTime = erlang:system_info(start_time), 7 + CurrentTime = erlang:monotonic_time(), 8 + Difference = (CurrentTime - StartTime), 9 + erlang:convert_time_unit(Difference, native, millisecond).
+3
src/starfish_ffi.mjs
··· 1 + export function monotonic_time() { 2 + return performance.now(); 3 + }