#!/usr/bin/perl #Created by Miles - Bladdo.Net, miles@bladdo.net #Edit this script how you like just give me credit #Vist Bladdo.Net! # Just enter in the cards as you go along, if it is a face card you only need the first letter (J Q K A) # If you guess wrong and are reset, to enter in a number with no change type your number preceeded by a * (ex: 8* ) # deck will show you the cards left in the deck print "Moola Hi/Lo Cards Probablity Analysis Script\nBy Miles Sandlar (miles@bladdo.net - www.bladdo.net)\nNote:Do not enter the inital 2, it is accounted for\nUsage:Just enter in the cards as you go along\n If the card is a face card enter in the first letter (ex: J for Jack)\n If you guess wrong and brought back to a point you have already been at enter a * after the letter to denote no change in the deck\n"; $run = 1; ###52 card deck @deck = ("2","2","2","2","3","3","3","3","4","4","4","4","5","5","5", "5","6","6","6","6","7","7","7","7","8","8","8","8","9","9", "9","9", "10","10","10","10","11","11","11","11","12","12", "12","12","13","13","13","13","14","14","14","14",); &sub_deal("2"); #kill begining 2, you are always delt a 2 ##START MAIN LOOP while ($run == 1) { $higher=0; $lower=0; ###reset high/low count values print "\nCard?:";###prompt for card $input = <>; chomp($input);### prompt for card+chomp if ($input eq "deck") { ##if reset deck, give it to em &sub_show; } elsif ($input eq "exit" | $input eq "quit") { $run = 0; #Quit the script } else { ##normal card entry here if ($input =~ /.*\*/ig) { $nochange = 1; $input =~ s/\*//; $conv = &sub_face($input); ###Run through Face, replace input(A/K/Q/J) with numbers print "[no change in deck]\n"; } else { $conv = &sub_face($input); ###Run through Face, replace input(A/K/Q/J) with numbers &sub_deal($conv); #throw input number outta the deck } foreach $card (@deck) { ##loop each card in the deck if ($card >= $conv) { $higher++; ##if card is greater or equal one card in deck then higher++ } else { $lower++; ##if lower then lower-- } } $percentHigher = $higher/&sub_count; $pH=$percentHigher*100; ##calculate go higher % $perecentLower = $lower/&sub_count; $pL=$percentLower*100; ##calculate go lower % if ($lower>$higher) { print "Lower is the better choice (" . $Pl . " % chance the next card will be lower /" . $pH . "% chance higher)\n"; ###Lower>higher choice, + show percents } elsif ($higher>$lower) { print "Higher is the better choice (" . $pH . " % chance the next card will be higher /" . $pL . "% chance lower)\n"; ###Higher>lower choice, + show percents } else { print "Equal Probability 50% higher/ 50% lower, Use a Lock/Change\n"; ##equal probablity } } } ##MAIN LOOP END sub sub_face { ##This subroutine converts face cards to numbers for easy handeling my($faceIn) = @_; $faceCard=uc($faceIn); ##capalitilize if not already done so if ($faceCard eq "J") { $returnCard = "11"; } elsif ($faceCard eq "Q") { $returnCard = "12"; } elsif ($faceCard eq "K") { $returnCard = "13"; } elsif ($faceCard eq "A") { $returnCard = "14"; } else { $returnCard= $faceCard; ##if not a face card just return } return $returnCard; ###Return with new number values } sub sub_deal { #Sub deal takes in a number and cut it out of the array/deck ($come) = @_; $count = 0; foreach $card(@deck) { $count++; ##count+1 in the array for each element(card) reviewd if ($card == $come) { $count--; ##arrays start with 0, annoying as fuck but easily solved delete $deck[$count]; ###delete card last; #gtfo foreach loop } } #Trash the card $deckStack = $#deck; for ($tempa = 0; $tempa <= $deckStack; $tempa++) { $tempo = shift (@deck); if (length ($tempo)) { push (@deck, $tempo); } } return(); } sub sub_show { ##Show remaining cards, replace numbs with J/Q/K/A foreach $card (@deck) { if ($card=="11") { $new="J"; # JACK } elsif ($card=="12") { $new="Q"; # QUEEN } elsif ($card=="13") { $new="K"; # KING } elsif ($card=="14") { $new="A"; # ACE } else { $new=$card; ##to show, no face, no go } print $new . " - ";## show reamining cards } print "\n"; } sub sub_count { #Subroutine to count remaining cards left in deck $cardsindeck=0; # Nullify foreach $card (@deck) { $cardsindeck++; } return $cardsindeck; }