well now i gotta show an algorithm i wrote
this was for my texas holdembot
i never finished it but this gauges what the strongest 5 card hand that can be made out of 7 cards
Code:
alias hand {
var %hand = $($+(%,player.,$$1),2)
var %suits = $remove(%hand,2-,3-,4-,5-,6-,7-,8-,9-,10-,J-,Q-,K-,A-)
var %suitless = $remove(%hand,-S,-C,-D,-H)
var %cnum = $replace(%suitless,J,11,Q,12,K,13,A,14)
var %scnum = $sorttok(%cnum,44,nr)
var %rscnum = $sorttok(%cnum,44,n)
var %suitnum = $replace(%suits,S,1,C,2,D,3,H,4)
var %a = 0
while (%a <= 4) {
inc %a
if ((*14*13*12*11*10* iswm %scnum) && ($wildtok(%suitnum,%a,0,44) >= 5)) {
return 10 $+ $chr(44)
halt
}
}
var %b = 0
var %c = 1
var %d = 0
while (%c <= 7) {
inc %b
inc %c
var %e = $gettok(%rscnum,%b,44)
var %f = $gettok(%rscnum,%c,44)
if ((%e == $calc(%f - 1)) && (%d < 4)) {
inc %d
var %q = %f
}
if (%d >= 4) {
var %a = 0
while (%a <= 4) {
inc %a
if ($findtok(%suitnum,%a,0,44) >= 5) {
return 9 $+ $chr(44) $+ %q
halt
}
}
}
}
var %g 1
while (%g <= 14) {
inc %g
if ($findtok(%scnum,%g,0,44) >= 4) {
return 8 $+ $chr(44) $+ %g
halt
}
}
var %h = 15
while (%h >= 2) {
dec %h
if ($findtok(%scnum,%h,0,44) >= 3) {
var %j = %h
var %q = $remove(%scnum,%j)
break
}
}
var %h = 15
while (%h >= 2) {
dec %h
if ($findtok(%q,%h,0,44) >= 2) {
var %i = %h
break
}
}
if ((%i) && (%j)) {
return 7 $+ $chr(44) $+ %j
halt
}
var %a = 0
while (%a <= 4) {
inc %a
if ($findtok(%suitnum,%a,0,44) >= 5) {
return 6 $+ $chr(44) $+ $gettok(%scnum,1,44)
halt
}
}
var %b = 0
var %c = 1
var %d = 0
while (%c <= 7) {
inc %b
inc %c
var %e = $gettok(%rscnum,%b,44)
var %f = $gettok(%rscnum,%c,44)
if ((%e == $calc(%f - 1)) && (%d < 4)) {
inc %d
var %q = %f
}
}
if (%d >= 4) {
return 5 $+ $chr(44) $+ %q
halt
}
var %g = 15
while (%g >= 2) {
dec %g
if ($findtok(%scnum,%g,0,44) >= 3) {
var %h = %g
return 4 $+ $chr(44) $+ %h
halt
}
}
var %h = 15
while (%h >= 2) {
dec %h
if ($findtok(%scnum,%h,0,44) >= 2) {
var %j = %h
var %q = $remove(%scnum,%j)
break
}
}
var %h = 15
while (%h >= 2) {
dec %h
if ($findtok(%q,%h,0,44) >= 2) {
var %i = %h
break
}
}
if ((%i) && (%j)) {
return 3 $+ $chr(44) $+ %j
halt
}
var %g = 15
while (%g >= 2) {
dec %g
if ($findtok(%scnum,%g,0,44) >= 2) {
return 2 $+ $chr(44) $+ %g
halt
}
}
return 1 $+ $chr(44) $+ $gettok(%scnum,1,44)
}
fj33r the enormity of my free time _________________
I think we can advance further. It is all about playing lots of scrims, practice. We did that towards the end, and that's why we won our last 5 matches. Good luck to you Xion, you are welcome any time as you know.
XO members, it is time to get together, make quick plans, start scrims for sure... CAL season is going to start in 3 weeks.
p.s.: Please start login and using TS to talk. Send me a pm if you need TS info.
Thanks to Allen and other hma, dk members for supporting us. _________________
Joined: Sep 25, 2005 Posts: 444 Location: Stuck in a lab
Posted: May 04, 2006 - 02:54 AM Post subject:
Don't worry gr3y.......XO. can find a way to pay me back for using my TS.....you know the correct position to assume....thats what i gave you those knee pads for
but seriously yall boys are always welcome in there
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