Skip to content

Conversation

@jarjk
Copy link
Owner

@jarjk jarjk commented Oct 22, 2025

fixes #24
fixes #27

progress on #8

so server rewrite in rust

trying to be sort-of backwards-compatible for now

expect several force pushes ;)

@jarjk jarjk force-pushed the serwir branch 2 times, most recently from 3865364 to 1b8be6d Compare October 23, 2025 22:28
@jarjk jarjk marked this pull request as ready for review October 26, 2025 18:49
@jarjk jarjk marked this pull request as draft October 26, 2025 18:51
@jarjk
Copy link
Owner Author

jarjk commented Oct 28, 2025

@jarjk
Copy link
Owner Author

jarjk commented Nov 22, 2025

I feel like the house edge is seriously low in this implementation, might not adhere to bj rules...

some more unit tests ensuring correctness should be written...

guess I'll have to write some primitive tests

@jarjk
Copy link
Owner Author

jarjk commented Nov 22, 2025

otherwise should be nearly there, make sure to check out my TODO: comments though!

@jarjk
Copy link
Owner Author

jarjk commented Nov 23, 2025

I feel like the house edge is seriously low in this implementation, might not adhere to bj rules...
some more unit tests ensuring correctness should be written...

guess I'll have to write some primitive tests

according to the hard totals of this strategy chart and a terrible implementation of them in fish, the house edge seems fine.

here's the implementation of auto-client.fish

#!/usr/bin/env fish

set addr "http://localhost:5225"
set uname bob

function handle_resp
    set resp "$argv[1]"
    if ! test "$resp" = ""
        echo "$resp" | jq -r
        or { echo "$resp" && exit 2 }
    else
        echo "can't reach server"
        exit 1
    end
end

function GET
    set resp (curl --silent "$addr/$argv[1]")
    handle_resp "$resp"
end

function POST
    set resp (curl --silent -XPOST "$addr/$argv[1]")
    handle_resp "$resp"
end

function get_from
    echo "$(echo "$argv[1]" | jq -r "$argv[2]")"; or exit 1
end

function meth
    test "$(echo "$argv[1]" | bc)" = 1
end

function auto_action
    set dealer_v "$argv[1]"
    set player_v "$argv[2]"
    if meth "$player_v >= 17" ||
            { meth "$player_v >= 13" && meth "$dealer_v <= 6" } ||
            { meth "$player_v == 12" && { meth "$dealer_v == 4" || meth "$dealer_v == 5" || meth "$dealer_v == 6" } }
        echo stand
    else
        echo hit
    end
end

for ix in (seq 0 $argv[1])
    printf "\n$ix. $(GET "join?username=$uname")\n"

    set resp "$(POST "bet/$uname?amount=1")"
    set winner (get_from $resp '.winner')
    if ! test "$winner" = f
        echo "$(get_from $resp '.state')"
        continue
    end

    while test "$(get_from $resp '.winner')" = f
        set dealer_v (get_from $resp '.dealer.value')
        set player_v (get_from $resp '.player.hand.value')
        echo "dealer_v: $dealer_v, player_v: $player_v"

        # read -P 'action: ' action
        # test "$action" = "" && exit 1
        # NOTE: comment following two lines if you wanna automate the process
        set action (auto_action $dealer_v $player_v)
        echo "action: $action"

        set resp "$(POST "move/$uname?action=$action")"
        # GET game_state/$uname | jq '.player.wealth'
    end
    set winner (get_from $resp '.winner')
    echo "winner: $winner, $(get_from $resp '.state')"
end

@jarjk jarjk requested a review from csboo November 23, 2025 16:48
jarjk and others added 2 commits November 23, 2025 17:51
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@jarjk jarjk marked this pull request as ready for review November 23, 2025 16:53
@jarjk jarjk marked this pull request as draft November 23, 2025 18:35
@jarjk jarjk marked this pull request as ready for review November 23, 2025 20:29
@jarjk
Copy link
Owner Author

jarjk commented Nov 24, 2025

bankruptcy shall be handled properly:

  • add a State::Bankrupt, but then it shall be refactored into eg State::Outcom(Win|Jack|...) and others or I dunno
  • just check int the join endpoint, whether user-wealth is 0

@jarjk jarjk marked this pull request as draft November 25, 2025 16:54
@jarjk
Copy link
Owner Author

jarjk commented Nov 25, 2025

check out #32 as well, as #29 doesn't really work as desired

@jarjk jarjk mentioned this pull request Nov 30, 2025
@jarjk jarjk changed the title serwir serwir(rocket) Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RWIR can't build on old-ass debian

3 participants