tsaw
New member
When I first learned programming on the TRS 80 - There was 3.8k ram to work with. Not much there to work with.
I wrote a text version of video poker.
At first I never thought anyone could fit a routine to identify the hand you got after the draw.
After lots of work - I got it down to this tiny code.
This works 100% today in LB
[idhand]
'check for flush
If heart=5 or diamond=5 or spade=5 or club=5 then
flush=true
end if
'check for 4 of a kind
If ace=4 or two=4 or three=4 or four=4 or five=4 or six=4 or seven=4 then
fourofakind=true
return
end if
If eight=4 or nine=4 or ten=4 or jack=4 or queen=4 or king=4 then
fourofakind=true
return
end if
if five=1 then [test2]
if nine=1 then [test5]
[test1]
if nine=1 then [test4]
goto [checkpair]
[test2]
if four<>1 then [test1]
if six<>1 then [test3]
if two=1 and three=1 then [straight]
if three=1 and seven=1 then [straight]
if seven=1 and eight=1 then [straight]
[test3]
if ace=1 and two=1 and three=1 then [straight]
[test4]
if six=1 and seven=1 and eight=1 then [straight]
goto [checkpair]
[test5]
if ten<>1 then [checkpair]
if eight<>1 then [test6]
if six=1 and seven=1 then [straight]
if seven=1 and jack=1 then [straight]
if jack=1 and queen=1 then [straight]
[test6]
if jack=1 and queen=1 and king=1 then [straight]
[checkpair]
if ace=2 or two=2 or three=2 or four=2 or five=2 or six=2 or seven=2 then [test]
if eight=2 or nine=2 or ten=2 or jack=2 or queen=2 or king=2 then [test]
if twopairchecked=true then
if pair=true then return
end if
nothing=true
goto [checkthreeofakind]
[straight]
straight=true
if flush=true then straightflush=true
return
[test]
if twopairchecked=true then'-this is not exact as on paper
twopair=true'-------------- original if twopairchecked=true then twopair=true:return
return
end if
'--------------------------------------------------------------------------------
if ace=2 then aces=true' needed for jacks or better
if king=2 then kings=true
if queen=2 then queens=true
if jack=2 then jacks=true
pair=true
[checkthreeofakind]
if ace=3 or two=3 or three=3 or four=3 or five=3 or six=3 or seven=3 then [checkfullhouse]
if eight=3 or nine=3 or ten=3 or jack=3 or queen=3 or king=3 then [checkfullhouse]
goto [checktwopair]
[checkfullhouse]
threeofakind=true' not the same as on paper
if pair=true then
fullhouse=true
return
end if
[checktwopair]
If nothing=true then return
if ace=2 then ace=0:goto [confirm]
if two=2 then two=0:goto [confirm]
if three=2 then three=0:goto [confirm]
if four=2 then four=0:goto [confirm]
if five=2 then five=0:goto [confirm]
if six=2 then six=0:goto [confirm]
if seven=2 then seven=0:goto [confirm]
if eight=2 then eight=0:goto [confirm]
if nine=2 then nine=0:goto [confirm]
if ten=2 then ten=0:goto [confirm]
if jack=2 then jack=0:goto [confirm]
if queen=2 then queen=0:goto [confirm]
if king=2 then king=0:goto [confirm]
[confirm]
twopairchecked=true
goto [checkpair]
return' every possible hand should have returned by now - not needed!
I wrote a text version of video poker.
At first I never thought anyone could fit a routine to identify the hand you got after the draw.
After lots of work - I got it down to this tiny code.
This works 100% today in LB
[idhand]
'check for flush
If heart=5 or diamond=5 or spade=5 or club=5 then
flush=true
end if
'check for 4 of a kind
If ace=4 or two=4 or three=4 or four=4 or five=4 or six=4 or seven=4 then
fourofakind=true
return
end if
If eight=4 or nine=4 or ten=4 or jack=4 or queen=4 or king=4 then
fourofakind=true
return
end if
if five=1 then [test2]
if nine=1 then [test5]
[test1]
if nine=1 then [test4]
goto [checkpair]
[test2]
if four<>1 then [test1]
if six<>1 then [test3]
if two=1 and three=1 then [straight]
if three=1 and seven=1 then [straight]
if seven=1 and eight=1 then [straight]
[test3]
if ace=1 and two=1 and three=1 then [straight]
[test4]
if six=1 and seven=1 and eight=1 then [straight]
goto [checkpair]
[test5]
if ten<>1 then [checkpair]
if eight<>1 then [test6]
if six=1 and seven=1 then [straight]
if seven=1 and jack=1 then [straight]
if jack=1 and queen=1 then [straight]
[test6]
if jack=1 and queen=1 and king=1 then [straight]
[checkpair]
if ace=2 or two=2 or three=2 or four=2 or five=2 or six=2 or seven=2 then [test]
if eight=2 or nine=2 or ten=2 or jack=2 or queen=2 or king=2 then [test]
if twopairchecked=true then
if pair=true then return
end if
nothing=true
goto [checkthreeofakind]
[straight]
straight=true
if flush=true then straightflush=true
return
[test]
if twopairchecked=true then'-this is not exact as on paper
twopair=true'-------------- original if twopairchecked=true then twopair=true:return
return
end if
'--------------------------------------------------------------------------------
if ace=2 then aces=true' needed for jacks or better
if king=2 then kings=true
if queen=2 then queens=true
if jack=2 then jacks=true
pair=true
[checkthreeofakind]
if ace=3 or two=3 or three=3 or four=3 or five=3 or six=3 or seven=3 then [checkfullhouse]
if eight=3 or nine=3 or ten=3 or jack=3 or queen=3 or king=3 then [checkfullhouse]
goto [checktwopair]
[checkfullhouse]
threeofakind=true' not the same as on paper
if pair=true then
fullhouse=true
return
end if
[checktwopair]
If nothing=true then return
if ace=2 then ace=0:goto [confirm]
if two=2 then two=0:goto [confirm]
if three=2 then three=0:goto [confirm]
if four=2 then four=0:goto [confirm]
if five=2 then five=0:goto [confirm]
if six=2 then six=0:goto [confirm]
if seven=2 then seven=0:goto [confirm]
if eight=2 then eight=0:goto [confirm]
if nine=2 then nine=0:goto [confirm]
if ten=2 then ten=0:goto [confirm]
if jack=2 then jack=0:goto [confirm]
if queen=2 then queen=0:goto [confirm]
if king=2 then king=0:goto [confirm]
[confirm]
twopairchecked=true
goto [checkpair]
return' every possible hand should have returned by now - not needed!