tom13 Posted July 24, 2007 Share Posted July 24, 2007 (edited) Hi, I'm working on a poker bot. The bot reads a decision for each combination of cards from Strategy.ini - looks like this: If $Card7 <> "" AND $Card6 <> "" AND $Card5 <> "" AND $Card4 <> "" AND $Card3 <> "" AND $Card2 <> "" AND $Card1 <> "" Then $Decision = IniRead ( $StrategyFile, "7Cards", $Card1 & "|" & $Card2 & "|" & $Card3 & "|" & $Card4 & "|" & $Card5 & "|" & $Card6 & "|" & $Card7, "unknown" ) DecisionGo() EndIf This example is for when there are 7 cards (2 in your hand and 5 on the table). The problem is that the order of the cards does not matters for my decision. It can be $card1|$card2|$card3|$card4|$card5|$card6|$card7 But it must make the same decision when the same cards are there but in an other order, for example: $card4|$card2|$card1|$card7|$card6|$card5|$card3 Assuming that the cards are still the same of course. Anyone can explain me how to do this with If ... then ? Creating a new if ... then when $decision is unknown with a different order would be (almost) impossible, since there are 7 x 7 = 49 possibilities. Edited July 24, 2007 by tom13 Link to comment Share on other sites More sharing options...
tom13 Posted July 24, 2007 Author Share Posted July 24, 2007 Or well if some pro can tell me if this is not possible that would be nice.. Maybe I shouldn't use if ... then ? Any suggestions? Link to comment Share on other sites More sharing options...
bluebearr Posted July 24, 2007 Share Posted July 24, 2007 Easiest way, I think, would be to sort the cards so that they are always in the same order for the decision. Something like: #include <Array.au3> Const $iAscending = 0 $CardTest = $Card1 & "|" & $Card2 & "|" & $Card3 & "|" & $Card4 & "|" & $Card5 & "|" & $Card6 & "|" & $Card7 $aCardTest = StringSplit($CardTest, "|") $aSorted = _ArraySort($aCardTest, $iAscending, 1) $CardTest = $aSorted[1] & "|" & $aSorted[2] & "|" & $aSorted[3] & "|" & $aSorted[4] _ & "|" & $aSorted[5] & "|" & $aSorted[6] & "|" & $aSorted[7] If Not StringInStr("|" & $CardTest & "|", "||") Then $Decision = IniRead ( $StrategyFile, "7Cards", $CardTest, "unknown" ) DecisionGo() EndIf Hope this helps. BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
tom13 Posted July 24, 2007 Author Share Posted July 24, 2007 Easiest way, I think, would be to sort the cards so that they are always in the same order for the decision. Something like: #include <Array.au3> Const $iAscending = 0 $CardTest = $Card1 & "|" & $Card2 & "|" & $Card3 & "|" & $Card4 & "|" & $Card5 & "|" & $Card6 & "|" & $Card7 $aCardTest = StringSplit($CardTest, "|") $aSorted = _ArraySort($aCardTest, $iAscending, 1) $CardTest = $aSorted[1] & "|" & $aSorted[2] & "|" & $aSorted[3] & "|" & $aSorted[4] _ & "|" & $aSorted[5] & "|" & $aSorted[6] & "|" & $aSorted[7] If Not StringInStr("|" & $CardTest & "|", "||") Then $Decision = IniRead ( $StrategyFile, "7Cards", $CardTest, "unknown" ) DecisionGo() EndIf Hope this helps. Hmmm, nice idea.. So I have to do the same when writing a new combination to Strategy.ini? Link to comment Share on other sites More sharing options...
tom13 Posted July 24, 2007 Author Share Posted July 24, 2007 (edited) I tried it but getting an error. Test Script: #include <Array.au3> $Card1 = "4d" $Card2 = "Qc" $Card3 = "Td" $Card4 = "2h" $Card5 = "Ah" $Card6 = "9d" $Card7 = "2d" Const $iAscending = 0 $CardTest = $Card1 & "|" & $Card2 & "|" & $Card3 & "|" & $Card4 & "|" & $Card5 & "|" & $Card6 & "|" & $Card7 $aCardTest = StringSplit($CardTest, "|") $aSorted = _ArraySort($aCardTest, $iAscending, 1) $CardTest = $aSorted[1] & "|" & $aSorted[2] & "|" & $aSorted[3] & "|" & $aSorted[4] & "|" & $aSorted[5] & "|" & $aSorted[6] & "|" & $aSorted[7] If Not StringInStr("|" & $CardTest & "|", "||") Then $Decision = IniRead ( $StrategyFile, "7Cards", $CardTest, "unknown" ) MsgBox(4096, "Test", $CardTest) EndIf Error Code: >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\Tom\Bureaublad\testa.au3" C:\Documents and Settings\Tom\Bureaublad\testa.au3 (14) : ==> Subscript used with non-Array variable.: $CardTest = $aSorted[1] & "|" & $aSorted[2] & "|" & $aSorted[3] & "|" & $aSorted[4] & "|" & $aSorted[5] & "|" & $aSorted[6] & "|" & $aSorted[7] $CardTest = $aSorted^ ERROR >Exit code: 0 Time: 0.208 Unfortunately I have no idea what's wrong.. anyone does? Edited July 24, 2007 by tom13 Link to comment Share on other sites More sharing options...
Developers Jos Posted July 24, 2007 Developers Share Posted July 24, 2007 I tried it but getting an error. Test Script: #include <Array.au3> $Card1 = "4d" $Card2 = "Qc" $Card3 = "Td" $Card4 = "2h" $Card5 = "Ah" $Card6 = "9d" $Card7 = "2d" Const $iAscending = 0 $CardTest = $Card1 & "|" & $Card2 & "|" & $Card3 & "|" & $Card4 & "|" & $Card5 & "|" & $Card6 & "|" & $Card7 $aCardTest = StringSplit($CardTest, "|") $aSorted = _ArraySort($aCardTest, $iAscending, 1) $CardTest = $aSorted[1] & "|" & $aSorted[2] & "|" & $aSorted[3] & "|" & $aSorted[4] & "|" & $aSorted[5] & "|" & $aSorted[6] & "|" & $aSorted[7] If Not StringInStr("|" & $CardTest & "|", "||") Then $Decision = IniRead ( $StrategyFile, "7Cards", $CardTest, "unknown" ) MsgBox(4096, "Test", $CardTest) EndIf Error Code: >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\Tom\Bureaublad\testa.au3" C:\Documents and Settings\Tom\Bureaublad\testa.au3 (14) : ==> Subscript used with non-Array variable.: $CardTest = $aSorted[1] & "|" & $aSorted[2] & "|" & $aSorted[3] & "|" & $aSorted[4] & "|" & $aSorted[5] & "|" & $aSorted[6] & "|" & $aSorted[7] $CardTest = $aSorted^ ERROR >Exit code: 0 Time: 0.208 Unfortunately I have no idea what's wrong.. anyone does? Sure, _Arraysort() doesn't return the sorted array but is using ByRef to store it back into $aCardTest ....$aSorted contains the returncode for the function. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
tom13 Posted July 24, 2007 Author Share Posted July 24, 2007 Sure, _Arraysort() doesn't return the sorted array but is using ByRef to store it back into $aCardTest ....$aSorted contains the returncode for the function.Ah, that explains alot.Thanks alot JdeB Link to comment Share on other sites More sharing options...
bluebearr Posted July 24, 2007 Share Posted July 24, 2007 Sure, _Arraysort() doesn't return the sorted arrayOopsie. Sorry about that. :"> BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now