optimal11.ash

Dractyl

New member
optimal11.ash - Automatically and optimally play Crimbo11

Optimal11 by dractyl (#1889124)
Inspiring thread: http://forums.kingdomofloathing.com:8080/vb/showthread.php?t=178758

I basically wanted to have script that would automate the desperate scramble for crimbux using the good information developed in the above mentioned thread.

This is my first ash script, so I'm sure I've done a ton wrong. That said, I've been programming a long time, so you should find it well commented and easy to follow. It's based on a lookup table, so the main routines are very clean.


Sample output:

Visiting the Crimbo Cartel in Crimbo Town
Round 1 of 3

[3304] Crimbo 11 Table
You bet 11 Crimbux
Opponent has 2 (2). You have 42 (6).
Doubling down...
You bet an additional 11 Crimbux
You acquire Crimbuck (44)
Opponent has 3225 (12). You have 423 (9).
You won! :D
You have won 22 delicious crimbux over 1 rounds (22.0 per adv.)

Round 2 of 3

[3305] Crimbo 11 Table
You bet 11 Crimbux
Opponent has 3 (3). You have k4 (9).
Standing...
Opponent has 33k (11). You have k4 (9).
You lost. :(
You have won 11 delicious crimbux over 2 rounds (5.5 per adv.)

Round 3 of 3

[3306] Crimbo 11 Table
You bet 11 Crimbux
You acquire Crimbuck (55)
Opponent has 2 (2). You have ka (11).
You won! :D
You have won 55 delicious crimbux over 3 rounds (18.33 per adv.)

--- Final statistics ---
Rounds: 3

Rounds Won: 2 (66.67%)
- by natural 11: 1 (33.33%)
- by double down: 1 (33.33%)

Rounds Lost: 1 (33.33%)
- by double down: 0 (0.0%)

Rounds Drawn: 0 (0.0%)
- by double down: 0 (0.0%)

Starting Crimbux: 7660
Crimbux won: 55
Crimbux/adv: 18.33
Ending Crimbux: 7715

Script completed.


Note:
- Auxiliary routines (basically 6 lines) stolen from Alhifar (#1189456) and RoyalTonberry (#1161513)
- If there is an issue there, I will happily rewrite them
- Strategy unabashedly lifted from "empty inferences" spading


Enjoy!

--

The current version is 4.1

Change log

New in 2.0:
- Corrected a cosmetic problem where doubledown was falsely declared
- Added improved statistics
- Corrected bug where the program would fail if the user did not specify the number of rounds
- Cleaned up code
- Cleaned up output
- Added detection for insufficient crimbux at the start and during each round


New in 3.0 - contribution by mysyzygy
- Re-ordered entries in the actions map so they're in the same order as the optimal play table in the wiki and are easier to proofread
- Added missing 1334 entry when dealer has Ace
- Added missing 1113 entry when dealer has Ace


New in 4.0
- Minor code refactoring
- Added crimbux/adv to final output
- Detects insufficient funds when doubling down
- Added Bale-style round syntax (-40 means "use all but 40 rounds")
- Counts card totals

4.1 was released under the same name as v4, correcting a bug where totals were incorrectly calculated under some conditions. Hand totals are only used for display purposes so this is strictly a cosmetic bug. Six people downloaded the affected version.
 

Attachments

  • optimal11.ash
    16.5 KB · Views: 108
  • optimal11v2.ash
    20.8 KB · Views: 51
  • optimal11v3.ash
    21.5 KB · Views: 52
  • optimal11v4.ash
    23.7 KB · Views: 464
Last edited:

Bale

Minion
Good work.

This is my first ash script, so I'm sure I've done a ton wrong. Shouganai, ne.
You may learn something about alternate solutions to your scripting issues if you check out this thread. Several other people have posted their own variants of this script there.
 

Dractyl

New member
optimal11v2.ash - Version 2 of my Cimbo 11 player

I've made an update to my script. It's had a few more days of testing. It works fine in terms of the actual gameplay and acquisition of Crimbux, but there were some cosmetic issues and some corner cases that have been fixed up.

New since 1.0:
- Corrected a cosmetic problem where doubledown was falsely declared
- Added improved statistics
- Corrected bug where the program would fail if the user did not specify the number of rounds
- Cleaned up code
- Cleaned up output
- Added detection for insufficient crimbux at the start and during each round


Todo:
- Add Bale-style round specification (-40 to mean "all but 40 turns")
- Count up the card totals or extract from page
- Add crimbux/adv to final stats (printed for each hand, but not at the end)
- Check if there are enough crimbux to double the bet and if not, hit instead


Here is an example of new final stats:
Rounds: 127

Rounds Won: 53 (41.73%)
- by natural 11: 15 (11.81%)
- by double down: 3 (2.36%)

Rounds Lost: 46 (36.22%)
- by double down: 1 (0.79%)

Rounds Drawn: 28 (22.05%)
- by double down: 0 (0.0%)

Starting Crimbux: 6253
Crimbux won: 594
Ending Crimbux: 6847

Dractyl
 

Attachments

  • optimal11v2.ash
    20.8 KB · Views: 177
Last edited:

fewyn

Administrator
Staff member
You have won 990 delicious crimbux over 233 rounds (4.25 per adv.)
--- Final statistics ---
Rounds: 233

Rounds Won: 107 (45.92%)
- by natural 11: 24 (10.3%)
- by double down: 9 (3.86%)

Rounds Lost: 95 (40.77%)
- by double down: 3 (1.29%)

Rounds Drawn: 31 (13.3%)
- by double down: 1 (0.43%)

Starting Crimbux: 7945
Crimbux won: 990
Ending Crimbux: 8935

Hot stuff :) Thanks
 

mysyzygy

New member
This is my favorite script 11 tables script because its by far the easiest to verify the code. I'm uploading a new version where I re-ordered entries
in the actions map so they're in the same order as the optimal play table in the wiki which makes the script easier to proofread.
http://kol.coldfront.net/thekolwiki/index.php/The_Crimbo_11_Table

I found two differences with the wiki although I don't think either of them are mistakes.

1) The following line was missing for the condition where the dealer has an ace and the player has A334. Since A334 is an 11 I don't think this entry needs to be there but the code lists lots of other soft elevens so I added it anyway.
actions [ '1' , '1334' ] = 1;

2) Another difference: When the dealer has 5 and the player has A224, the wiki says to stand and the script says to hit. Since the other 3 similar cases say to hit, I think the wiki is wrong.
actions [ '5' , '1224' ] = 2;

My version of the script doesn't fix any problems or add new features, it just makes it easier to verify that the right logic is being used.

Unfortunately, now that I finally have a script that I'm confident is working correctly, I think I'll stop playing elevens and switch to slots. I think theoretically 11's should pay better but I've played hundreds of turns with 3 characters for a few days and I've pretty crappy averages. The first time I played I got over 6 bux per turn but since then I haven't had any sessions over 4/turn and most have been under 3.

Happy Crimbo!
 

Attachments

  • optimal11v3.ash
    21.5 KB · Views: 133
Re: optimal11.ash - my results

I ran optimal11v2.ash for 200 adventures. It took less than 10 minutes (maybe less than 5; I was in a hurry before rollover!) and gave this output:

Starting Crimbux: 4899
Crimbux won: 1089
Ending Crimbux: 5988

So that's a little more than 5 Crimbux per adventure. Did it bet 11 every time because that's what I had last bet? Maybe if I read it I'll see the answer within. Anyway, thank you very much for my first ASH script! I really needed to use those 200 turns!
 

morgad

Member
I got about 3 to 5 bux a turn using this :)
perfect to burn up turns after penguin farming

tnx
Dave
 
Last edited:

Ethelred

Member
I encountered aa3a while the dealer was showing a and the script when into a loop. Stopped the script and hit stand (because I saw it was 11) and the dealer also had 11, so it was a push. Only then did I realize I could have hit for a 5 card wind. :-( Oh, well, that's life. I didn't look at the tables, but maybe an entry is missing?
 

adeyke

Member
I have seen v2 stand on an 8 (a34), and v3 take a hit on a 9 (which made me bust). Is there anything I can do to help?

Standing on A34 is optimal if the dealer has 2 or 3, and hitting on a 9 is optimal in all soft hands and some hards hands. So the information you've given is consistent with optimal play and doesn't indicate a problem.
 
Last edited:

Dractyl

New member
Version 4 released

Hi everyone,

I've released version 4. Instead of placing the file here, I put it back in the original post (at the beginning of this thread) so new downloaders won't have to go searching for it. Please download from there.

Dractyl

--

New in 4.0
- Minor code refactoring
- Added crimbux/adv to final output
- Detects insufficient funds when doubling down
- Added Bale-style round syntax (-40 means "use all but 40 rounds")
- Counts card totals
 
Last edited:

Dractyl

New member
I encountered aa3a while the dealer was showing a and the script when into a loop. Stopped the script and hit stand (because I saw it was 11) and the dealer also had 11, so it was a push. Only then did I realize I could have hit for a 5 card wind. :-( Oh, well, that's life. I didn't look at the tables, but maybe an entry is missing?

There was an entry missing. mysyzygy caught it when he made version 3. Download the latest and you should be ok.


I have seen v2 stand on an 8 (a34), and v3 take a hit on a 9 (which made me bust). Is there anything I can do to help?

Please check your result against the table located here. If there is a discrepancy, let me know in this thread by posting the dealers hand, your hand and the result. Better yet, the output from the script of the round in question would be ideal.

Thank you to everyone for your feedback.

Dractyl
 

Dractyl

New member
Did it bet 11 every time because that's what I had last bet?

Hi Storella,

In version 1 it asks you what you'd like to bet each time you run the script.

In version 2 the bet is always 11 unless you set it to a different value at the top of the script. Just edit it near the top and you're set.

Dractyl
 

mysyzygy

New member
There was an entry missing. mysyzygy caught it when he made version 3. Download the latest and you should be ok.
Dractyl

That's what I thought too except the hand he looped on was aa3a and that's not the hand I added. Maybe he mis-remembered the hand?

Also, is it true that its a win any time you pull a fifth card? If so then shouldn't we always hit on all four card hands? This should be an instant win because you have 5 cards but if you stand then you might lose if the dealer draws a better hand.
 

mysyzygy

New member
Hi everyone,

I've released version 4. Instead of placing the file here, I put it back in the original post so new downloaders won't have to go searching for it. Please download from there.


In what original thread? I don't see it in "the11tablesASH ~I DID NOT MAKE THIS~ ".
 

adeyke

Member
That's what I thought too except the hand he looped on was aa3a and that's not the hand I added. Maybe he mis-remembered the hand?

Also, is it true that its a win any time you pull a fifth card? If so then shouldn't we always hit on all four card hands? This should be an instant win because you have 5 cards but if you stand then you might lose if the dealer draws a better hand.

It's a guaranteed win if you have five cards without a bust. If the fifth card brings you over 11, you've lost. In some cases, it's correct to hit on four cards, but in other cases, it's correct to stand.

In what original thread? I don't see it in "the11tablesASH ~I DID NOT MAKE THIS~ ".

Not original thread; original post (i.e. the first post in this thread).
 

Dractyl

New member
That's what I thought too except the hand he looped on was aa3a and that's not the hand I added. Maybe he mis-remembered the hand?

I checked v2 and there was no entry for '1','1113', but there was one in v3, so I'm assuming it's yours. Maybe the Crimbo elves are afoot... ;)

Dractyl
 
Last edited:
Top