You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
358B

  1. #!/usr/bin/gawk -f
  2. function abs(x){return ( x >= 0 ) ? x : -x }
  3. /bet\?/ {
  4. print "1";
  5. fflush();
  6. }
  7. /insurance\?/ {
  8. print "no";
  9. fflush();
  10. }
  11. /play\?/ {
  12. # mimic the dealer: hit until 17 (hit soft 17)
  13. if (abs($2) < 17 || $2 == -17) { # soft hands are negative
  14. print "hit";
  15. } else {
  16. print "stand";
  17. }
  18. fflush();
  19. }
  20. /bye/ {
  21. exit;
  22. }