Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

5 роки тому
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. define(case_title, No-bust strategy)
  2. ---
  3. title: case_title
  4. ...
  5. # case_title
  6. > Difficulty: case_difficulty/100
  7. This directory shows how to play a “no-bust” strategy, i.e. not hitting any hand higher or equal to hard twelve with Libre Blackjack. The communication between the player and the back end is through standard input and output. The player reads from its standard input Libre Blackjack's commands and writes to its standard output the playing commands. In order to do this a FIFO (a.k.a. named pipe) is needed. So first, we create it (if it is not already created):
  8. ```terminal
  9. mkfifo fifo
  10. ```
  11. Then we execute `blackjack`, piping its output to the player (say `no-bust.pl`) and reading the standard input from `fifo`, whilst at the same time we redirect the player's standard output to `fifo`:
  12. ```terminal
  13. include(run.sh)dnl
  14. ```
  15. As this time the player is coded in an interpreted langauge, it is far smarter than the previous `yes`-based player. So the player can handle bets and insurances, and there is not need to pass the options `--flat_bet` nor `--no_insurance` (though they can be passed anyway). Let us take a look at the Perl implementation:
  16. ```perl
  17. include(no-bust.pl)dnl
  18. ```
  19. The very same player may be implemented as a shell script:
  20. ```bash
  21. include(no-bust.sh)dnl
  22. ```
  23. To check these two players give the same results, make them play against Libre Blackjack with the same seed (say one) and send the YAML report to two different files:
  24. ```terminal
  25. include(diff.sh)
  26. esyscmd(diff perl.yml shell.yml)dnl
  27. ```
  28. As expected, the reports are the same. They just differ in the speed because the shell script is orders of magnitude slower than its Perl-based counterpart.
  29. > **Exercise:** modify the players so they always insure aces and see if it improves or degrades the result.
  30. case_nav