-1
gleam.toml
-1
gleam.toml
-1
manifest.toml
-1
manifest.toml
+6
-3
src/starfish.gleam
+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
+9
src/starfish_ffi.erl