A tool for testing starfish
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement testing framework

gearsco.de d0908388

+466
+23
.github/workflows/test.yml
··· 1 + name: test 2 + 3 + on: 4 + push: 5 + branches: 6 + - master 7 + - main 8 + pull_request: 9 + 10 + jobs: 11 + test: 12 + runs-on: ubuntu-latest 13 + steps: 14 + - uses: actions/checkout@v4 15 + - uses: erlef/setup-beam@v1 16 + with: 17 + otp-version: "28" 18 + gleam-version: "1.12.0" 19 + rebar3-version: "3" 20 + # elixir-version: "1" 21 + - run: gleam deps download 22 + - run: gleam test 23 + - run: gleam format --check src test
+4
.gitignore
··· 1 + *.beam 2 + *.ez 3 + /build 4 + erl_crash.dump
+24
README.md
··· 1 + # starfish_testing 2 + 3 + [![Package Version](https://img.shields.io/hexpm/v/starfish_testing)](https://hex.pm/packages/starfish_testing) 4 + [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/starfish_testing/) 5 + 6 + ```sh 7 + gleam add starfish_testing@1 8 + ``` 9 + ```gleam 10 + import starfish_testing 11 + 12 + pub fn main() -> Nil { 13 + // TODO: An example of the project in use 14 + } 15 + ``` 16 + 17 + Further documentation can be found at <https://hexdocs.pm/starfish_testing>. 18 + 19 + ## Development 20 + 21 + ```sh 22 + gleam run # Run the project 23 + gleam test # Run the tests 24 + ```
+23
gleam.toml
··· 1 + name = "starfish_testing" 2 + version = "1.0.0" 3 + 4 + # Fill out these fields if you intend to generate HTML documentation or publish 5 + # your project to the Hex package manager. 6 + # 7 + # description = "" 8 + # licences = ["Apache-2.0"] 9 + # repository = { type = "github", user = "", repo = "" } 10 + # links = [{ title = "Website", href = "" }] 11 + # 12 + # For a full reference of all the available options, you can have a look at 13 + # https://gleam.run/writing-gleam/gleam-toml/. 14 + 15 + [dependencies] 16 + gleam_stdlib = ">= 0.44.0 and < 2.0.0" 17 + starfish = { path = "../starfish" } 18 + simplifile = ">= 2.3.0 and < 3.0.0" 19 + gleam_httpc = ">= 5.0.0 and < 6.0.0" 20 + gleam_http = ">= 4.1.1 and < 5.0.0" 21 + 22 + [dev-dependencies] 23 + gleeunit = ">= 1.0.0 and < 2.0.0"
+23
manifest.toml
··· 1 + # This file was generated by Gleam 2 + # You typically do not need to edit this file 3 + 4 + packages = [ 5 + { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" }, 6 + { name = "gleam_erlang", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "1124AD3AA21143E5AF0FC5CF3D9529F6DB8CA03E43A55711B60B6B7B3874375C" }, 7 + { name = "gleam_http", version = "4.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "DD0271B32C356FB684EC7E9F48B1E835D0480168848581F68983C0CC371405D4" }, 8 + { name = "gleam_httpc", version = "5.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "C545172618D07811494E97AAA4A0FB34DA6F6D0061FDC8041C2F8E3BE2B2E48F" }, 9 + { name = "gleam_stdlib", version = "0.62.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "0080706D3A5A9A36C40C68481D1D231D243AF602E6D2A2BE67BA8F8F4DFF45EC" }, 10 + { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" }, 11 + { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" }, 12 + { name = "iv", version = "1.3.2", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "iv", source = "hex", outer_checksum = "1FE22E047705BE69EA366E3A2E73C2E1310CBCB27DDE767DE17AE3FA86499947" }, 13 + { name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" }, 14 + { name = "starfish", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "iv"], source = "local", path = "../starfish" }, 15 + ] 16 + 17 + [requirements] 18 + gleam_http = { version = ">= 4.1.1 and < 5.0.0" } 19 + gleam_httpc = { version = ">= 5.0.0 and < 6.0.0" } 20 + gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } 21 + gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 22 + simplifile = { version = ">= 2.3.0 and < 3.0.0" } 23 + starfish = { path = "../starfish" }
+50
silversuite.fen
··· 1 + r1bq1rk1/pp2ppbp/2n2np1/2ppN3/5P2/1P2P3/PBPPB1PP/RN1Q1RK1 b - - 3 8 2 + rnbq1rk1/ppp1ppbp/3p1np1/8/4P3/3P1NP1/PPP2PBP/RNBQ1RK1 b - e3 0 6 3 + r1bqkb1r/pppp1ppp/2n2n2/4p3/2P5/2N2N2/PP1PPPPP/R1BQKB1R w KQkq - 4 4 4 + rn1qk2r/1b2bppp/pp1ppn2/8/2PQ4/2N2NP1/PP2PPBP/R1BR2K1 w kq - 0 10 5 + rn1qkb1r/3ppp1p/b4np1/2pP4/8/2N5/PP2PPPP/R1BQKBNR w KQkq - 0 7 6 + rnbqkb1r/pp3p1p/3p1np1/2pP4/4P3/2N5/PP3PPP/R1BQKBNR w KQkq - 0 7 7 + rnb1qrk1/ppp1p1bp/3p1np1/3P1p2/2P5/2N2NP1/PP2PPBP/R1BQ1RK1 b - - 0 8 8 + rnb1k2r/pp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p/2p1pn2/3p4/2PP4/2NBPN2/PP3PPP/R1BQK2R b KQkq - 2 6 40 + rnbq1rk1/p1p1bpp1/1p2pn1p/3p4/2PP3B/2N1PN2/PP3PPP/R2QKB1R w KQ - 0 8 41 + rnbq1rk1/ppp1ppbp/6p1/3n4/3P4/5NP1/PP2PPBP/RNBQ1RK1 b - - 1 7 42 + rnbqk2r/pp2ppbp/6p1/2p5/2BPP3/2P5/P3NPPP/R1BQK2R b KQkq - 1 8 43 + rnbq1rk1/ppp1bppp/4pn2/3p4/2PP4/5NP1/PP2PPBP/RNBQK2R w KQ - 3 6 44 + rnb1k2r/ppppqppp/4pn2/8/1bPP4/5NP1/PP1BPP1P/RN1QKB1R b KQkq - 0 5 45 + rnbqkb1r/p1pp1ppp/1p2pn2/8/2PP4/5NP1/PP2PP1P/RNBQKB1R b KQkq - 0 4 46 + rnbq1rk1/pppp1ppp/4pn2/8/2PP4/P1Q5/1P2PPPP/R1B1KBNR b KQ - 0 6 47 + rnbq1rk1/pp3ppp/4pn2/2pp4/1bPP4/2NBPN2/PP3PPP/R1BQ1RK1 b - - 1 7 48 + r1bq1rk1/pppn1pbp/3p1np1/4p3/2PPP3/2N2NP1/PP3PBP/R1BQ1RK1 b - e3 0 8 49 + rnbq1rk1/pp3pbp/2pp1np1/4p3/2PPP3/2N1BP2/PP2N1PP/R2QKB1R w KQ - 0 8 50 + r1bq1rk1/pppnn1bp/3p4/3Pp1p1/2P1Pp2/2N2P2/PP2BBPP/R2QNRK1 w - - 0 13
+107
src/starfish_testing.gleam
··· 1 + import gleam/http 2 + import gleam/http/request 3 + import gleam/httpc 4 + import gleam/int 5 + import gleam/io 6 + import gleam/list 7 + import gleam/result 8 + import gleam/string 9 + import simplifile as file 10 + import starfish 11 + import starfish/internal/board 12 + import starfish/internal/move.{type Legal, type Move} 13 + 14 + const fen_file = "silversuite.fen" 15 + 16 + pub fn main() -> Nil { 17 + let assert Ok(games) = 18 + fen_file 19 + |> file.read 20 + |> result.map(string.split(_, "\n")) 21 + as "Failed to read game file" 22 + 23 + let outcomes = 24 + list.index_map(games, fn(game, i) { 25 + let outcome = run_game(game) 26 + io.println( 27 + "Finished game " 28 + <> int.to_string(i) 29 + <> ", outcome " 30 + <> string.inspect(outcome), 31 + ) 32 + outcome 33 + }) 34 + 35 + let #(wins, draws, losses) = 36 + list.fold(outcomes, #(0, 0, 0), fn(tuple, outcome) { 37 + let #(wins, draws, losses) = tuple 38 + case outcome { 39 + White -> #(wins + 1, draws, losses) 40 + Draw -> #(wins, draws + 1, losses) 41 + Black -> #(wins, draws, losses + 1) 42 + } 43 + }) 44 + 45 + io.println( 46 + "Wins: " 47 + <> int.to_string(wins) 48 + <> "\nDraws: " 49 + <> int.to_string(draws) 50 + <> "\nLosses: " 51 + <> int.to_string(losses), 52 + ) 53 + 54 + Nil 55 + } 56 + 57 + type Outcome { 58 + White 59 + Black 60 + Draw 61 + } 62 + 63 + fn run_game(fen: String) -> Outcome { 64 + let assert Ok(game) = starfish.try_from_fen(fen) 65 + as "Failed to parse fen string" 66 + run_game_loop(game) 67 + } 68 + 69 + fn run_game_loop(game: starfish.Game) -> Outcome { 70 + case starfish.state(game) { 71 + starfish.BlackWin -> Black 72 + starfish.Draw(_) -> Draw 73 + starfish.WhiteWin -> White 74 + starfish.Continue -> { 75 + let best_move = get_best_move(game) 76 + 77 + run_game_loop(starfish.apply_move(game, best_move)) 78 + } 79 + } 80 + } 81 + 82 + fn get_best_move(game: starfish.Game) -> Move(Legal) { 83 + let url = case game.to_move { 84 + board.White -> "http://0.0.0.0:8000/move" 85 + board.Black -> "http://0.0.0.0:8001/move" 86 + } 87 + 88 + let assert Ok(request) = request.to(url) 89 + let request = 90 + request 91 + |> request.set_body(starfish.to_fen(game)) 92 + |> request.set_method(http.Post) 93 + let assert Ok(response) = httpc.send(request) 94 + 95 + let assert Ok(move) = starfish.parse_long_algebraic_notation(response.body) 96 + coerce_move(move) 97 + } 98 + 99 + fn coerce_move(move: Move(move.Valid)) -> Move(Legal) { 100 + case move { 101 + move.Capture(from:, to:) -> move.Capture(from:, to:) 102 + move.Castle(from:, to:) -> move.Castle(from:, to:) 103 + move.EnPassant(from:, to:) -> move.EnPassant(from:, to:) 104 + move.Move(from:, to:) -> move.Move(from:, to:) 105 + move.Promotion(from:, to:, piece:) -> move.Promotion(from:, to:, piece:) 106 + } 107 + }
+4
starfish_original/.gitignore
··· 1 + *.beam 2 + *.ez 3 + /build 4 + erl_crash.dump
+23
starfish_original/gleam.toml
··· 1 + name = "starfish_original" 2 + version = "1.0.0" 3 + 4 + # Fill out these fields if you intend to generate HTML documentation or publish 5 + # your project to the Hex package manager. 6 + # 7 + # description = "" 8 + # licences = ["Apache-2.0"] 9 + # repository = { type = "github", user = "", repo = "" } 10 + # links = [{ title = "Website", href = "" }] 11 + # 12 + # For a full reference of all the available options, you can have a look at 13 + # https://gleam.run/writing-gleam/gleam-toml/. 14 + 15 + [dependencies] 16 + gleam_stdlib = ">= 0.44.0 and < 2.0.0" 17 + wisp = ">= 1.8.0 and < 2.0.0" 18 + mist = ">= 5.0.3 and < 6.0.0" 19 + gleam_erlang = ">= 1.3.0 and < 2.0.0" 20 + starfish = { git = "https://github.com/GearsDatapacks/starfish", ref = "main" } 21 + 22 + [dev-dependencies] 23 + gleeunit = ">= 1.0.0 and < 2.0.0"
+38
starfish_original/manifest.toml
··· 1 + # This file was generated by Gleam 2 + # You typically do not need to edit this file 3 + 4 + packages = [ 5 + { name = "directories", version = "1.2.0", build_tools = ["gleam"], requirements = ["envoy", "gleam_stdlib", "platform", "simplifile"], otp_app = "directories", source = "hex", outer_checksum = "D13090CFCDF6759B87217E8DDD73A75903A700148A82C1D33799F333E249BF9E" }, 6 + { name = "envoy", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "95FD059345AA982E89A0B6E2A3BF1CF43E17A7048DCD85B5B65D3B9E4E39D359" }, 7 + { name = "exception", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "329D269D5C2A314F7364BD2711372B6F2C58FA6F39981572E5CA68624D291F8C" }, 8 + { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" }, 9 + { name = "gleam_crypto", version = "1.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_crypto", source = "hex", outer_checksum = "50774BAFFF1144E7872814C566C5D653D83A3EBF23ACC3156B757A1B6819086E" }, 10 + { name = "gleam_erlang", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "1124AD3AA21143E5AF0FC5CF3D9529F6DB8CA03E43A55711B60B6B7B3874375C" }, 11 + { name = "gleam_http", version = "4.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "DD0271B32C356FB684EC7E9F48B1E835D0480168848581F68983C0CC371405D4" }, 12 + { name = "gleam_json", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "874FA3C3BB6E22DD2BB111966BD40B3759E9094E05257899A7C08F5DE77EC049" }, 13 + { name = "gleam_otp", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "7987CBEBC8060B88F14575DEF546253F3116EBE2A5DA6FD82F38243FCE97C54B" }, 14 + { name = "gleam_stdlib", version = "0.62.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "0080706D3A5A9A36C40C68481D1D231D243AF602E6D2A2BE67BA8F8F4DFF45EC" }, 15 + { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" }, 16 + { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" }, 17 + { name = "glisten", version = "8.0.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "logging", "telemetry"], otp_app = "glisten", source = "hex", outer_checksum = "534BB27C71FB9E506345A767C0D76B17A9E9199934340C975DC003C710E3692D" }, 18 + { name = "gramps", version = "6.0.0", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "8B7195978FBFD30B43DF791A8A272041B81E45D245314D7A41FC57237AA882A0" }, 19 + { name = "houdini", version = "1.2.0", build_tools = ["gleam"], requirements = [], otp_app = "houdini", source = "hex", outer_checksum = "5DB1053F1AF828049C2B206D4403C18970ABEF5C18671CA3C2D2ED0DD64F6385" }, 20 + { name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" }, 21 + { name = "iv", version = "1.3.2", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "iv", source = "hex", outer_checksum = "1FE22E047705BE69EA366E3A2E73C2E1310CBCB27DDE767DE17AE3FA86499947" }, 22 + { name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" }, 23 + { name = "marceau", version = "1.3.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "2D1C27504BEF45005F5DFB18591F8610FB4BFA91744878210BDC464412EC44E9" }, 24 + { name = "mist", version = "5.0.3", build_tools = ["gleam"], requirements = ["exception", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gleam_yielder", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "7C4BE717A81305323C47C8A591E6B9BA4AC7F56354BF70B4D3DF08CC01192668" }, 25 + { name = "platform", version = "1.0.0", build_tools = ["gleam"], requirements = [], otp_app = "platform", source = "hex", outer_checksum = "8339420A95AD89AAC0F82F4C3DB8DD401041742D6C3F46132A8739F6AEB75391" }, 26 + { name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" }, 27 + { name = "starfish", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "iv"], source = "git", repo = "https://github.com/GearsDatapacks/starfish", commit = "75b810adb672c936ead92d464f73ae5f03345da3" }, 28 + { name = "telemetry", version = "1.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "telemetry", source = "hex", outer_checksum = "7015FC8919DBE63764F4B4B87A95B7C0996BD539E0D499BE6EC9D7F3875B79E6" }, 29 + { name = "wisp", version = "1.8.0", build_tools = ["gleam"], requirements = ["directories", "exception", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_json", "gleam_stdlib", "houdini", "logging", "marceau", "mist", "simplifile"], otp_app = "wisp", source = "hex", outer_checksum = "0FE9049AFFB7C8D5FC0B154EEE2704806F4D51B97F44925D69349B3F4F192957" }, 30 + ] 31 + 32 + [requirements] 33 + gleam_erlang = { version = ">= 1.3.0 and < 2.0.0" } 34 + gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } 35 + gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 36 + mist = { version = ">= 5.0.3 and < 6.0.0" } 37 + starfish = { git = "https://github.com/GearsDatapacks/starfish", ref = "main" } 38 + wisp = { version = ">= 1.8.0 and < 2.0.0" }
+40
starfish_original/src/starfish_original.gleam
··· 1 + import gleam/erlang/process 2 + import mist 3 + import starfish 4 + import wisp.{type Request, type Response} 5 + import wisp/wisp_mist 6 + 7 + pub fn main() { 8 + wisp.configure_logger() 9 + let secret_key_base = wisp.random_string(64) 10 + let assert Ok(_) = 11 + handle_request 12 + |> wisp_mist.handler(secret_key_base) 13 + |> mist.new 14 + |> mist.bind("0.0.0.0") 15 + |> mist.port(8001) 16 + |> mist.start 17 + process.sleep_forever() 18 + } 19 + 20 + fn handle_request(request: Request) -> Response { 21 + case wisp.path_segments(request) { 22 + ["move"] -> handle_move(request) 23 + _ -> wisp.ok() 24 + } 25 + } 26 + 27 + fn handle_move(request: Request) -> Response { 28 + use fen <- wisp.require_string_body(request) 29 + let game = starfish.from_fen(fen) 30 + let move_result = starfish.search(game, to_depth: 4) 31 + case move_result { 32 + Ok(move) -> 33 + wisp.ok() 34 + |> wisp.string_body(starfish.to_long_algebraic_notation(move)) 35 + |> wisp.set_header("Access-Control-Allow-Origin", "*") 36 + Error(Nil) -> 37 + wisp.internal_server_error() 38 + |> wisp.string_body("No moves found") 39 + } 40 + }
+4
starfish_updated/.gitignore
··· 1 + *.beam 2 + *.ez 3 + /build 4 + erl_crash.dump
+23
starfish_updated/gleam.toml
··· 1 + name = "starfish_updated" 2 + version = "1.0.0" 3 + 4 + # Fill out these fields if you intend to generate HTML documentation or publish 5 + # your project to the Hex package manager. 6 + # 7 + # description = "" 8 + # licences = ["Apache-2.0"] 9 + # repository = { type = "github", user = "", repo = "" } 10 + # links = [{ title = "Website", href = "" }] 11 + # 12 + # For a full reference of all the available options, you can have a look at 13 + # https://gleam.run/writing-gleam/gleam-toml/. 14 + 15 + [dependencies] 16 + gleam_stdlib = ">= 0.44.0 and < 2.0.0" 17 + starfish = { path = "../../starfish" } 18 + wisp = ">= 1.8.0 and < 2.0.0" 19 + gleam_erlang = ">= 1.3.0 and < 2.0.0" 20 + mist = ">= 5.0.3 and < 6.0.0" 21 + 22 + [dev-dependencies] 23 + gleeunit = ">= 1.0.0 and < 2.0.0"
+38
starfish_updated/manifest.toml
··· 1 + # This file was generated by Gleam 2 + # You typically do not need to edit this file 3 + 4 + packages = [ 5 + { name = "directories", version = "1.2.0", build_tools = ["gleam"], requirements = ["envoy", "gleam_stdlib", "platform", "simplifile"], otp_app = "directories", source = "hex", outer_checksum = "D13090CFCDF6759B87217E8DDD73A75903A700148A82C1D33799F333E249BF9E" }, 6 + { name = "envoy", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "95FD059345AA982E89A0B6E2A3BF1CF43E17A7048DCD85B5B65D3B9E4E39D359" }, 7 + { name = "exception", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "329D269D5C2A314F7364BD2711372B6F2C58FA6F39981572E5CA68624D291F8C" }, 8 + { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" }, 9 + { name = "gleam_crypto", version = "1.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_crypto", source = "hex", outer_checksum = "50774BAFFF1144E7872814C566C5D653D83A3EBF23ACC3156B757A1B6819086E" }, 10 + { name = "gleam_erlang", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "1124AD3AA21143E5AF0FC5CF3D9529F6DB8CA03E43A55711B60B6B7B3874375C" }, 11 + { name = "gleam_http", version = "4.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "DD0271B32C356FB684EC7E9F48B1E835D0480168848581F68983C0CC371405D4" }, 12 + { name = "gleam_json", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "874FA3C3BB6E22DD2BB111966BD40B3759E9094E05257899A7C08F5DE77EC049" }, 13 + { name = "gleam_otp", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "7987CBEBC8060B88F14575DEF546253F3116EBE2A5DA6FD82F38243FCE97C54B" }, 14 + { name = "gleam_stdlib", version = "0.62.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "0080706D3A5A9A36C40C68481D1D231D243AF602E6D2A2BE67BA8F8F4DFF45EC" }, 15 + { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" }, 16 + { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" }, 17 + { name = "glisten", version = "8.0.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "logging", "telemetry"], otp_app = "glisten", source = "hex", outer_checksum = "534BB27C71FB9E506345A767C0D76B17A9E9199934340C975DC003C710E3692D" }, 18 + { name = "gramps", version = "6.0.0", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "8B7195978FBFD30B43DF791A8A272041B81E45D245314D7A41FC57237AA882A0" }, 19 + { name = "houdini", version = "1.2.0", build_tools = ["gleam"], requirements = [], otp_app = "houdini", source = "hex", outer_checksum = "5DB1053F1AF828049C2B206D4403C18970ABEF5C18671CA3C2D2ED0DD64F6385" }, 20 + { name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" }, 21 + { name = "iv", version = "1.3.2", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "iv", source = "hex", outer_checksum = "1FE22E047705BE69EA366E3A2E73C2E1310CBCB27DDE767DE17AE3FA86499947" }, 22 + { name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" }, 23 + { name = "marceau", version = "1.3.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "2D1C27504BEF45005F5DFB18591F8610FB4BFA91744878210BDC464412EC44E9" }, 24 + { name = "mist", version = "5.0.3", build_tools = ["gleam"], requirements = ["exception", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gleam_yielder", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "7C4BE717A81305323C47C8A591E6B9BA4AC7F56354BF70B4D3DF08CC01192668" }, 25 + { name = "platform", version = "1.0.0", build_tools = ["gleam"], requirements = [], otp_app = "platform", source = "hex", outer_checksum = "8339420A95AD89AAC0F82F4C3DB8DD401041742D6C3F46132A8739F6AEB75391" }, 26 + { name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" }, 27 + { name = "starfish", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "iv"], source = "local", path = "../../starfish" }, 28 + { name = "telemetry", version = "1.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "telemetry", source = "hex", outer_checksum = "7015FC8919DBE63764F4B4B87A95B7C0996BD539E0D499BE6EC9D7F3875B79E6" }, 29 + { name = "wisp", version = "1.8.0", build_tools = ["gleam"], requirements = ["directories", "exception", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_json", "gleam_stdlib", "houdini", "logging", "marceau", "mist", "simplifile"], otp_app = "wisp", source = "hex", outer_checksum = "0FE9049AFFB7C8D5FC0B154EEE2704806F4D51B97F44925D69349B3F4F192957" }, 30 + ] 31 + 32 + [requirements] 33 + gleam_erlang = { version = ">= 1.3.0 and < 2.0.0" } 34 + gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } 35 + gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 36 + mist = { version = ">= 5.0.3 and < 6.0.0" } 37 + starfish = { path = "../../starfish" } 38 + wisp = { version = ">= 1.8.0 and < 2.0.0" }
+42
starfish_updated/src/starfish_updated.gleam
··· 1 + import gleam/erlang/process 2 + import mist 3 + import starfish 4 + import wisp.{type Request, type Response} 5 + import wisp/wisp_mist 6 + 7 + pub fn main() { 8 + wisp.configure_logger() 9 + let secret_key_base = wisp.random_string(64) 10 + 11 + let assert Ok(_) = 12 + handle_request 13 + |> wisp_mist.handler(secret_key_base) 14 + |> mist.new 15 + |> mist.bind("0.0.0.0") 16 + |> mist.port(8000) 17 + |> mist.start 18 + 19 + process.sleep_forever() 20 + } 21 + 22 + fn handle_request(request: Request) -> Response { 23 + case wisp.path_segments(request) { 24 + ["move"] -> handle_move(request) 25 + _ -> wisp.ok() 26 + } 27 + } 28 + 29 + fn handle_move(request: Request) -> Response { 30 + use fen <- wisp.require_string_body(request) 31 + let game = starfish.from_fen(fen) 32 + let move_result = starfish.search(game, to_depth: 4) 33 + case move_result { 34 + Ok(move) -> 35 + wisp.ok() 36 + |> wisp.string_body(starfish.to_long_algebraic_notation(move)) 37 + |> wisp.set_header("Access-Control-Allow-Origin", "*") 38 + Error(Nil) -> 39 + wisp.internal_server_error() 40 + |> wisp.string_body("No moves found") 41 + } 42 + }