Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Tue Mar 05, 2002 1:02 pm   

Advanced Trigger - Gambling System
 
Stuck on something here. I'm coding some settings to bot a BlackJack gambling system in my MUD by the most logical solution (hit on less than 17, stay on 17 or above)

I made triggers to recognize each card and its worth, including aces. Problem is that aces can be worth either 11 or 1. I reflected that by using 2 different worth variables -> gbj_worth (no aces present) and gbj_worth 2 (aces present) and subtracting 10 * number of aces from gbj_worth2.

Anyway, here's the problem part of the trigger in red:

#if {@gbj_bot = Y} {#if {@gbj_worth OR @gbj_worth2 >= 17} {stay} {#if {@gbj_worth < 17} {hit} {#if {@gbj_worth2 < 17} {hit} {stay}}}}

If I take out the OR @gbj_worth2, the system works just fine, hits on < 17, stays on > 17. But I need it to check BOTH variables and see if either is over 17. Probably doesn't make sense, but hopefully someone can help me out. Thanks for your time.

Fat Tony
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Mar 05, 2002 1:34 pm   
 
The way you are writing it it checks to see if @gbj_worth is true or @gbj_worth2 >= 17 is true. You need to change it to:
(@gbj_worth >= 17) OR (@gbj_worth2 >= 17)

Kjata
Reply with quote
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Tue Mar 05, 2002 10:15 pm   
 
That worked, thanks Kjata. But now that THAT works, I can't figure out how to make it hit if @gbj_worth is bust, but @gbj_worth2 is say 14. Basically if @gbj_worth is over 17 (like 24), @gbj_worth2 would be 14, a hittable number. But, because @gbj_worth is > 17, it won't hit. Any ideas?

Fat Tony
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Wed Mar 06, 2002 1:13 am   
 
Well then, what you need is not OR but AND, because you want to check if both are over 17 and then stay. So change the OR to an AND.

Kjata
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Mar 06, 2002 4:06 am   
 
Actually I think you might like the logic to be a little more complex. What you want is #IF ((@gbj_worth>17)&(@gbj_worth<=21)) {stay} {#IF (@gbj_worth2<=17) {hit} {stay}}
Basically when you have an ace and an eight you want to stay. That is covered by the first if. Two aces and an eight would get picked up by the second.

You should also change your calculation on worth2 to be total with aces as 11, while (worth2>21)&(subcount<acecount) -10. That way two aces would be 12 instead of 2, and you will stay if you get a nine.
Reply with quote
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Wed Mar 06, 2002 10:53 am   
 
I didn't even think about that possibility, thanks Vigilante. How should I code the (worth2>21)&(subcount<acecount) -10 part though? Confused me a little there. Right now I have it counting Aces as 11, but I have it flagging a variable to say that there is an ace present, and subtract 10 from the worth for each ace, which is what gbj_worth2 comes to. Probably sounds confusing, I'll post the entire trigger.

Pattern: is dealt to you. Your cards are now (%a)(%a) and (%a)(%a)
Value:
gbj_worth =
gbj_worth2 =
gbj_ace = N
#if {%1 = s} {gbj_1csuit = Spades}
#if {%1 = c} {gbj_1csuit = Clubs}
#if {%1 = h} {gbj_1csuit = Hearts}
#if {%1 = d} {gbj_1csuit = Diamonds}
#if {%2 != A} {
gbj_1c = %2
gbj_1cw = %2
}
#if {%2 != K} {
gbj_1c = %2
gbj_1cw = %2
}
#if {%2 != Q} {
gbj_1c = %2
gbj_1cw = %2
}
#if {%2 != J} {
gbj_1c = %2
gbj_1cw = %2
}
#if {%2 = K} {
gbj_1c = King
gbj_1cw = 10
}
#if {%2 = Q} {
gbj_1c = Queen
gbj_1cw = 10
}
#if {%2 = J} {
gbj_1c = Jack
gbj_1cw = 10
}
#if {%2 = A} {
gbj_1c = Ace
gbj_1cw = 11
gbj_ace = Y
}
#if {%2 = 0} {
gbj_1c = Ten
gbj_1cw = 10
}
#if {%3 = s} {gbj_2csuit = Spades}
#if {%3 = c} {gbj_2csuit = Clubs}
#if {%3 = h} {gbj_2csuit = Hearts}
#if {%3 = d} {gbj_2csuit = Diamonds}
#if {%4 != A} {
gbj_2c = %4
gbj_2cw = %4
}
#if {%4 != K} {
gbj_2c = %4
gbj_2cw = %4
}
#if {%4 != Q} {
gbj_2c = %4
gbj_2cw = %4
}
#if {%4 != J} {
gbj_2c = %4
gbj_2cw = %4
}
#if {%4 = K} {
gbj_2c = King
gbj_2cw = 10
}
#if {%4 = Q} {
gbj_2c = Queen
gbj_2cw = 10
}
#if {%4 = J} {
gbj_2c = Jack
gbj_2cw = 10
}
#if {%4 = A} {
gbj_2c = Ace
gbj_2cw = 11
gbj_ace = Y
}
#if {%4 = 0} {
gbj_2c = Ten
gbj_2cw = 10
}
gbj_worth = %eval( @gbj_1cw + @gbj_2cw)
#if {@gbj_1c = Ace} {@gbj_worth2 = %eval( @gbj_worth - 10)}
#if {@gbj_2c = Ace} {@gbj_worth2 = %eval( @gbj_worth - 10)}
#say @gbj_1c of @gbj_1csuit + @gbj_2c of @gbj_2csuit = @gbj_worth %if(@gbj_ace = Y,OR @gbj_worth2,)
#if {@gbj_bot = Y} {#IF ((@gbj_worth > 17) & (@gbj_worth <= 21)) {stay} {#IF (@gbj_worth2 <= 17) {hit} {stay}}}

I have 8 triggers of that, each adding another card. I hope this makes SOME sense, and thanks for any help you've got to give.

Fat Tony
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Mar 06, 2002 2:16 pm   
 
It doesn't really affect your first trigger unless you have two aces, but would affect the others.

Near the beginning you have:
gbj_ace = N
Change that to:
gbj_ace = 0

Next all occurences similar to this:
#if {%2 = A} {
gbj_1c = Ace
gbj_1cw = 11
gbj_ace = Y
}
Get changed like this:
#if {%2 = A} {
gbj_1c = Ace
gbj_1cw = 11
#ADD gbj_ace = 1
}

Then you worth2 calculation, you have:
#if {@gbj_1c = Ace} {@gbj_worth2 = %eval( @gbj_worth - 10)}
#if {@gbj_2c = Ace} {@gbj_worth2 = %eval( @gbj_worth - 10)}
It would become:
gbj_worth2=@gbj_worth
#WHILE ((@gbj_worth2>21)&(gbj_ace)) {
#ADD gbj_worth2 -10
#ADD gbj_ace -1
}

I would really recommend not tracking suits, as they don't figure into scoring black jack. Then I would say put your card worth conversion into an alias, so it can be editted once and affect all your triggers. Also put the final hit/stay ifs into another alias, because you may yet wish to make the logic better. Final thing is statistcally speaking there are only about 6 possible ways to get eight cards and not bust. Most blackjack games have a win if you got 5 and didn't bust. The odds of getting that win are about 1:500. So I don't think you need 8 triggers.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net