Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/09/2013 in all areas

  1. I wrote/wrapped this up last year, and it's geared to evaluate a 5, 6, or 7 card hand, meaning it can tell you, given 7 cards, what the best 5 card hand you can make from the cards, how strong that hand is within it's own category (such as, 4 of a kind sixes will beat four of a kind fives.) It's based on the Two+Two forum brilliance, using a hash table (a 123 mb table of every possible 5, 6, and 7 card hand.) http://www.codingthewheel.com/archives/poker-hand-evaluator-roundup#2p2 This is fast. It can evaluate 1 million hands in 28 seconds, ymmv. There are 4 functions: LoadHRDat() AnalyzeHand($iCardOne, $iCardTwo, $iCardThree, $iCardFour, $iCardFive, $iCardSix, $iCardSeven) AnalyzeHand6($iCardOne, $iCardTwo, $iCardThree, $iCardFour, $iCardFive, $iCardSix) AnalyzeHand5($iCardOne, $iCardTwo, $iCardThree, $iCardFour, $iCardFive) You need to have the HandRanks.dat file in your script directory, LoadHRDat() expects to find it there. I could make it more user friendly, but I'm not sure why it would ever need that, at this point. The functions return a hash value. $HandCategory = BitShift($Analysis, 12) $HandRankWithinCategory = BitAND($Analysis, 0x00000FFF) You need to perform a BitShift($return, 12) to get the hand category. You need to perform a BitAND($return, 0x00000FFF) to get the hand rank within that category. There are 9 categories. 1 is the lowest ranking, the highest rank depends on the category. A hand that tells you it is category 4, rank 858, means you've got 3 aces, a King, and a Queen, the best possible 3 of a kind. Rank 1 would be 3 deuces, a three, and a four. I have some helper code packaged up to interpret the information to english, these are _CardList.au3, _HandCategories.au3, and _HandStrength.au3. These denote the cards, the types of categories, and a normalized database of every 5 card hand (no variation.) They allow you to translate the results into english. _HandEval.rar To use: run XPokerEval.TwoPlusTwo.exe to create the HandRanks.dat database, then run RandomHandGenerator.au3 to generate random hands and see the results of evaluation.The hands database is important, without it the functions won't work. DealAHandOptimum() is a nice function if you want to generate your own random card hands. Or, download and unrar HandRanks.dat from here. And yes. Yes, I know.
    1 point
  2. TheSaint requested sometime ago that _PathSplit be changed to extract the 'parent folder' of a path. After much discussion about the subject, I went ahead and drew up the following code. Function: Func _PathSplitEx($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sParentDir, ByRef $sFileName, ByRef $sExtension) Local Enum $eFilePath, $eDrive, $eDir, $eParentDir, $eFileName, $eExtension, $eMax Local $aReturn[$eMax], _ $bAppended = True, _ $iExtension = StringInStr($sFilePath, '.', $STR_NOCASESENSEBASIC, -1), $iSlash = 0 $aReturn[$eFilePath] = $sFilePath If StringInStr($sFilePath, '/', $STR_NOCASESENSEBASIC) Then $sFilePath = StringReplace($sFilePath, '/', '\') ; Replace '/' with '\' EndIf $aReturn[$eDir] = $sFilePath $aReturn[$eDrive] = StringLeft($sFilePath, 2) ; Drive. If $aReturn[$eDrive] == '\\' Then ; UNC path. $iSlash = StringInStr($sFilePath, '\', $STR_NOCASESENSEBASIC, 3) If $iSlash Then $aReturn[$eDrive] = StringLeft($sFilePath, $iSlash - 1) EndIf $aReturn[$eDir] = 'A:' & StringTrimLeft($aReturn[$eDir], StringLen($aReturn[$eDrive])) $iExtension = StringInStr($aReturn[$eDir], '.', $STR_NOCASESENSEBASIC, -1) EndIf $iSlash = StringInStr($aReturn[$eDir], '\', $STR_NOCASESENSEBASIC, -1) If $iExtension Then ; If an extension exists. $aReturn[$eExtension] = StringTrimLeft($aReturn[$eDir], $iExtension - 1) ; Extension. $aReturn[$eFileName] = StringTrimRight(StringTrimLeft($aReturn[$eDir], $iSlash), StringLen($aReturn[$eExtension])) ; Filename. Else $bAppended = (StringRight($aReturn[$eDir], 1) == '\') ; Check if a backslash is appended to the end. If Not $bAppended Then ; If backslash doesn't exist (when it's a directory) then append to the end. $aReturn[$eDir] &= '\' $iSlash = StringInStr($aReturn[$eDir], '\', $STR_NOCASESENSEBASIC, -1) EndIf EndIf $aReturn[$eDir] = StringTrimLeft(StringLeft($aReturn[$eDir], $iSlash), 2) ; Path. $aReturn[$eParentDir] = StringTrimLeft($aReturn[$eDir], StringInStr($aReturn[$eDir], '\', $STR_NOCASESENSEBASIC, -2)) ; Parent folder. $aReturn[$eDir] = StringTrimRight($aReturn[$eDir], StringLen($aReturn[$eParentDir])) ; Remove parent folder from the path. If Not $bAppended Then $aReturn[$eParentDir] = StringTrimRight($aReturn[$eParentDir], 1) EndIf If $aReturn[$eDir] == '\' Then ; If no folder is present then copy the contents of the parent folder. $aReturn[$eDir] &= $aReturn[$eParentDir] $aReturn[$eParentDir] = '' EndIf $sDrive = $aReturn[$eDrive] $sDir = $aReturn[$eDir] $sParentDir = $aReturn[$eParentDir] $sFileName = $aReturn[$eFileName] $sExtension = $aReturn[$eExtension] Return $aReturn EndFunc ;==>_PathSplitEx Example use of Function: #include <File.au3> Example() #cs [0] C:\Program Files\Chat Tools\Skype\SkypeGUI.exe - Filepath [1] C: - Drive. [2] \Program Files\Chat Tools\ - Folder. [3] Skype\ - Parent folder. [4] SkypeGUI - Filename. [5] .exe - Extension. #ce Func Example() Local $sDrive = '', $sDir = '', $sParentDir = '', $sFileName = '', $sExtension = '' ConsoleWrite('_PathSplitEx:' & @CRLF) Local $aPathSplit = _PathSplitEx('C:\Program Files\Chat Tools\Skype\SkypeGUI.exe', $sDrive, $sDir, $sParentDir, $sFileName, $sExtension) Print1DArray($aPathSplit) ConsoleWrite('_PathSplitEx:' & @CRLF) $aPathSplit = _PathSplitEx('C:\user\docs\Letter.txt', $sDrive, $sDir, $sParentDir, $sFileName, $sExtension) Print1DArray($aPathSplit) ConsoleWrite('_PathSplit:' & @CRLF) $aPathSplit = _PathSplit('C:\user\docs\Letter.txt', $sDrive, $sDir, $sFileName, $sExtension) Print1DArray($aPathSplit) ConsoleWrite('_PathSplitEx:' & @CRLF) $aPathSplit = _PathSplitEx('C:\user\docs\', $sDrive, $sDir, $sParentDir, $sFileName, $sExtension) Print1DArray($aPathSplit) ConsoleWrite('_PathSplitEx:' & @CRLF) $aPathSplit = _PathSplitEx('C:\user\docs', $sDrive, $sDir, $sParentDir, $sFileName, $sExtension) Print1DArray($aPathSplit) ConsoleWrite('_PathSplitEx:' & @CRLF) $aPathSplit = _PathSplitEx('\\Server01\user\docs\Letter.txt', $sDrive, $sDir, $sParentDir, $sFileName, $sExtension) Print1DArray($aPathSplit) ConsoleWrite('_PathSplit:' & @CRLF) $aPathSplit = _PathSplit('\\Server01\user\docs\Letter.txt', $sDrive, $sDir, $sFileName, $sExtension) Print1DArray($aPathSplit) ConsoleWrite('_PathSplitEx:' & @CRLF) $aPathSplit = _PathSplitEx('\\Server01/user\docs/Letter.txt', $sDrive, $sDir, $sParentDir, $sFileName, $sExtension) Print1DArray($aPathSplit) EndFunc ;==>Example Func Print1DArray(ByRef Const $aArray, $iStart = Default, $iEnd = Default, $sDelim = Default) If $iEnd = Default Then $iEnd = UBound($aArray) - 1 If $iStart = Default Then $iStart = 0 If $sDelim = Default Then $sDelim = @CRLF Local $iIndex = 0 For $i = $iStart To $iEnd ConsoleWrite('[' & $iIndex & '] ' & $aArray[$i] & @CRLF) $iIndex += 1 Next ConsoleWrite(@CRLF) EndFunc ;==>Print1DArray
    1 point
  3. jeyes56, It's also quite insulting when I provided an answer and you didn't bother to read it. Learn some manners before you learn AutoIt.
    1 point
  4. DiOgO, And where does it say in the Forum rules that download automators are not permitted? Yes you are, by posting as you did above. We are very grateful to those who help us keep the forum a pleasant place to visit, but we do ask that if they believe there is a problem that is not immediately obvious that they take the time to tell us why. Please do not take this as any form of admonition, but I hope you can see why we have that extra bullet in there: if you think it is a problem, then you need to explain why - the Mods just do not have the time to research every possible EULA. PoojaKrishna, On a quick search I can find no restriction on automation in the iTunes EULA - unless DiOgO (or someone else) comes up with chapter and verse, i am happy for this thread to continue. M23
    1 point
  5. Till the information #include <Array.au3> ;Im assuming that 62 and 0 is included in the count of the integers #cs 098989898 : Match 6231231234 : Match after replacing 62 to 0 the number is still 9 digits 0623123123 : Match after replacing 062 with 00 the number is still 9 digits 1623123123 : No Match because 62 being in second index will get replaced but the starting is 1 hence the number is not captured *023456721212 : Match when no other match is found #ce Local $sString = "blablablabla:0989129839120000000 blblas blasab lblablablsa *334*no okoakdo#, kjadla : *229*023456721212#" _Main( $sString ) Func _Main($String) ;Find 62 in First Index, when found replace with a 0 $String = StringRegExpReplace($String, "(\D|^)(62)(\d{7,11})(\D|$)", '${1}0\3\4') ;Find 062 in Second Index, when found replace with a 0 $String = StringRegExpReplace($String, "(\D|^)(062)(\d{6,10})(\D|$)", '${1}00\3\4') ConsoleWrite($String & @CR) Local $aRet = StringRegExp($String, "(?:\D|^)(?<!\*)(0\d{8,12})(?:\D|$)", 3) If @error Then $aRet = StringRegExp($String, "(?:\D|^)(0\d{8,12})(?:\D|$)", 3) _ArrayDisplay($aRet) EndFunc ;==>_Main If this doesnt fulfill the conditions please do answer my questions..! Regards Phoenix XL
    1 point
×
×
  • Create New...