#include <Array.au3> $newdeck = _CutDeck(_ShuffleDeck(_InitializeDeck())) While 1 $newhand = _DrawCards($newdeck,5) _ArrayDisplay($newhand,"Five Cards Drawn") If _ArraySearch($newhand,"12~3") <> -1 Then ExitLoop WEnd Exit Func _InitializeDeck($faces=0,$suits=0,$decks=1) If Not IsArray($faces) Then Dim $faces[13]=[1,2,3,4,5,6,7,8,9,10,11,12,13] If Not IsArray($suits) Then Dim $suits[4]=[0,1,2,3] Dim $deck[4] Dim $suit = 0 Dim $card = 0 For $i = 1 to $decks For $x = 0 To UBound($faces)-1 ReDim $deck[$card+4] Do $deck[$card] = $suits[$suit] & $faces[$x] $card += 1 $suit +=1 Until $suit >= 4 $suit = 0 Next Next Return $deck EndFunc Func _ShuffleDeck($deck) SRandom(Random(0,10)) For $x = 0 To 50 _ArraySwap($deck[Random($x,51,1)],$deck[$x]) Next For $x = 51 To 1 Step -1 _ArraySwap($deck[Random(0,$x,1)],$deck[$x]) Next Return $deck EndFunc Func _CutDeck($deck,$count=0) If $count <= 0 Or $count >= UBound($deck)-1 Then $count = Random(13,39,1) For $i = 1 to $count _ArrayPush($deck,$deck[UBound($deck)-1],1) Next Return $deck EndFunc Func _DrawCards(ByRef $deck,$count) If Ubound($deck) <= $count Then $deck = _CutDeck(_ShuffleDeck(_InitializeDeck())) _ArrayReverse($deck) Dim $cards[$count] For $i = 0 to $count-1 $cards[$i] = $deck[UBound($deck)-1] _ArrayPop($deck) Next _ArrayReverse($deck) Return $cards EndFunc Func _PlayCards(ByRef $hand,$cards) Dim $played[UBound($cards)] For $i = 0 To UBound($played)-1 $card = _ArraySearch($hand,$cards[$i]) $played[$i] = $hand[$card] _ArrayDelete($hand,$card) Next Return $played EndFuncoÝ÷ ÚËkG ºwuÔè©ÝÓ~¡jwtß§ÛzÛ« ëk ¨Æzv{Mú ©ÝÓ~j·lwEºwºw¢fâàÞrK4ß§^rMtß§^rMzÛ« ëk ¨Æzv{Múuç$×Múuç$ØIÝéÜþËkGv+HÁ«%¢"+^¶¦ßÛ.®

**Edited by nitekram, 01 October 2008 - 08:02 PM.**