diff --git a/2004/burley/README.md b/2004/burley/README.md index 09494816f..88ee57588 100644 --- a/2004/burley/README.md +++ b/2004/burley/README.md @@ -4,7 +4,7 @@ make ``` -NOTE: We FORCE the use of -O0 even if someone overrides it because this entry +**NOTE**: We FORCE the use of `-O0` even if someone overrides it because this entry will not work with it enabled. @@ -14,7 +14,7 @@ will not work with it enabled. ./burley ``` -NOTE: you need to input a number first. See judges' remarks below for +**NOTE**: you need to input a number first. See judges' remarks below for information on how to play. @@ -22,32 +22,57 @@ information on how to play. This is a [draw poker](https://en.wikipedia.org/wiki/Draw_poker) program. You start with $100. Input alternates between your bet and which cards to keep. -Example: -``` - 5 <== you enter a bet of $5 (defaults to $1) - J Q J 9 5 <== your hand is Jack of Clubs, Queen of Hearts, - C H D S C Jack of Diamonds, 9 of Spades, 5 of Clubs - 123 <== you enter which cards you want to keep - (enter 0 to 5 digits between 1 and 5) - J Q J J Q <== your new hand is Jack of Clubs, Queen of Hearts, - C H D S C Jack of Diamonds, Jack of Spaces, Queen of clubs - $145 (45) <== Your new balance is now $145. You had a Full House - so your payoff is 9 times your bet == 45 -``` +### Example: + +Here is an example. + +First, enter your bet (say `5`) (for $5, defaults to $1). You might then see +something like: + +> J Q J 9 5
+> C H D S C + +That indicates your hand is Jack of Clubs, Queen of Hearts, Jack of Diamonds, 9 +of Spades and 5 of Clubs. + +Now enter what cards you want to keep (enter 0 to 5 digits between 1 and 5). +Let's say you want to keep 1, 2 and 3 so you enter `123`. You should see +something like the following after you hit enter: + +> J Q J J Q
+> C H D S C + +which tells you that your new hand is Jack of Clubs, Queen of Hearts, Jack of +Diamonds, Jack of Spaces and Queen of clubs. You might now see something like: + +> $145 (45) + +which tells you that your new balance is now $145. You had a Full House so your +payoff is 9 times your bet == 45. + +#### Payout: The payout is according to "Vegas rules": -``` - Straight Flush 50 times your bet - Four of a Kind 25 times your bet - Full House 9 times your bet - Flush 6 times your bet - Straight 4 times your bet - 3 of a Kind 3 times your bet - 2 Pair 2 times your bet - Jacks or Better 1 times your bet -``` +- **Straight Flush** + * 50 times your bet +- **Four of a Kind** + * 25 times your bet +- **Full House** + * 9 times your bet +- **Flush** + * 6 times your bet +- **Straight** + * 4 times your bet +- **3 of a Kind** + * 3 times your bet) +- **2 Pair** + * 2 times your bet +- **Jacks or Better** + * 1 times your bet + +### Other things: The program allows you to go into debt. However I'm sure you would never control-C to kill the program just because you got behind, right? On the other @@ -60,9 +85,10 @@ the program so this "strategy" no longer works? Notice the clever use of `setjmp(3)` and `longjmp(3)` calls. Can you keep track of what state is being saved and restored? -NOTE: the author talks about how it is a single statement. This might not be +**NOTE**: the author talks about how it is a single statement. This might not be strictly true in 2023 for the fixes for it to work so you can look at the -original file [burley.orig.c](%%REPO_URL%%/2004/burley/burley.orig.c) to see what is meant. +original file [burley.orig.c](%%REPO_URL%%/2004/burley/burley.orig.c) to see +what is meant. ## Author's remarks: diff --git a/2004/burley/burley.c b/2004/burley/burley.c index 9d4e44fe4..dc46effca 100644 --- a/2004/burley/burley.c +++ b/2004/burley/burley.c @@ -1,8 +1,9 @@ char a[80]; int e[4],g[5],c=100,h,i,j,k,b,f,s,t; jmp_buf p[4]; -int pain(char *d){ -return pain((char*)((srand(time((time_t*)&h)), +int main(int argc,char**D){ +char*d=(char*)D; +return main(argc,(char*)((srand(time((time_t*)&h)), setjmp(p[2]), (k=atoi((fgets(a,sizeof a, stdin), a+strspn(a," -")))) @@ -89,5 +90,3 @@ i+=i+1, longjmp(p[0],0)),0), longjmp(p[2],3)),0)); } -int main(int argc,char**d){ -return pain((char*)d);} diff --git a/2004/burley/index.html b/2004/burley/index.html index 2dd2fad45..a6d950342 100644 --- a/2004/burley/index.html +++ b/2004/burley/index.html @@ -409,34 +409,76 @@ Location: US - United States of America

To build:

    make
-

NOTE: We FORCE the use of -O0 even if someone overrides it because this entry +

NOTE: We FORCE the use of -O0 even if someone overrides it because this entry will not work with it enabled.

To use:

    ./burley
-

NOTE: you need to input a number first. See judges’ remarks below for +

NOTE: you need to input a number first. See judges’ remarks below for information on how to play.

Judges’ remarks:

This is a draw poker program. You -start with $100. Input alternates between your bet and which cards to keep. -Example:

-
    5           <== you enter a bet of $5 (defaults to $1)
-    J Q J 9 5   <== your hand is Jack of Clubs, Queen of Hearts,
-    C H D S C       Jack of Diamonds, 9 of Spades, 5 of Clubs
-    123         <== you enter which cards you want to keep
-                    (enter 0 to 5 digits between 1 and 5)
-    J Q J J Q   <== your new hand is Jack of Clubs, Queen of Hearts,
-    C H D S C       Jack of Diamonds, Jack of Spaces, Queen of clubs
-    $145 (45)   <== Your new balance is now $145.  You had a Full House
-                    so your payoff is 9 times your bet == 45
+start with $100. Input alternates between your bet and which cards to keep.

+

Example:

+

Here is an example.

+

First, enter your bet (say 5) (for $5, defaults to $1). You might then see +something like:

+
+

J Q J 9 5
+C H D S C

+
+

That indicates your hand is Jack of Clubs, Queen of Hearts, Jack of Diamonds, 9 +of Spades and 5 of Clubs.

+

Now enter what cards you want to keep (enter 0 to 5 digits between 1 and 5). +Let’s say you want to keep 1, 2 and 3 so you enter 123. You should see +something like the following after you hit enter:

+
+

J Q J J Q
+C H D S C

+
+

which tells you that your new hand is Jack of Clubs, Queen of Hearts, Jack of +Diamonds, Jack of Spaces and Queen of clubs. You might now see something like:

+
+

$145 (45)

+
+

which tells you that your new balance is now $145. You had a Full House so your +payoff is 9 times your bet == 45.

+

Payout:

The payout is according to “Vegas rules”:

-
    Straight Flush     50 times your bet
-    Four of a Kind     25 times your bet
-    Full House          9 times your bet
-    Flush               6 times your bet
-    Straight            4 times your bet
-    3 of a Kind         3 times your bet
-    2 Pair              2 times your bet
-    Jacks or Better     1 times your bet
+ +

Other things:

The program allows you to go into debt. However I’m sure you would never control-C to kill the program just because you got behind, right? On the other hand the program never willingly exits, so you have to leave even when you are @@ -445,9 +487,10 @@ ahead. :-)

the program so this “strategy” no longer works?

Notice the clever use of setjmp(3) and longjmp(3) calls. Can you keep track of what state is being saved and restored?

-

NOTE: the author talks about how it is a single statement. This might not be +

NOTE: the author talks about how it is a single statement. This might not be strictly true in 2023 for the fixes for it to work so you can look at the -original file burley.orig.c to see what is meant.

+original file burley.orig.c to see +what is meant.

Author’s remarks:

This program plays draw poker. What is unusual about it is that it is written as a single statement – count the semicolons! (OK, there diff --git a/thanks-for-help.html b/thanks-for-help.html index 26c9b3ad0..c2d4c2106 100644 --- a/thanks-for-help.html +++ b/thanks-for-help.html @@ -3005,10 +3005,6 @@ expression with void or if it is for some other reason).

longjmp(3) was being called with one arg which was an element of an int[4][1000] which had to be changed to a jmp_buf p[4] (this due to the prototype being included).

-

main() also called itself but this was a problem so it now calls another -function poke() which calls itself instead (this is sometimes necessary -nowadays and other entries had to have this same kind of change, -2001/anonymous being a good example).

Finally the optimiser cannot be enabled so the compiler flags were changed for this, forcing -O0.

diff --git a/thanks-for-help.md b/thanks-for-help.md index 108a8a1d7..81e7b29b3 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3710,11 +3710,6 @@ expression with `void` or if it is for some other reason). of an `int[4][1000]` which had to be changed to a `jmp_buf p[4]` (this due to the prototype being included). -`main()` also called itself but this was a problem so it now calls another -function `poke()` which calls itself instead (this is sometimes necessary -nowadays and other entries had to have this same kind of change, -[2001/anonymous](2001/anonymous/index.html) being a good example). - Finally the optimiser cannot be enabled so the compiler flags were changed for this, forcing `-O0`.