-
Notifications
You must be signed in to change notification settings - Fork 2
serwir(rocket) #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
serwir(rocket) #28
Conversation
3865364 to
1b8be6d
Compare
|
https://app.semanticdiff.com/gh/jarjk/blackjackpp/pull/28/changes might be worth a look |
guess I'll have to write some primitive tests |
|
otherwise should be nearly there, make sure to check out my |
according to the hard totals of this strategy chart and a terrible implementation of them in here's the implementation of #!/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 |
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>
|
bankruptcy shall be handled properly:
|
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 ;)