#!/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 $tempor (@deck) { ##loop each card in the deck if ($tempor >= $conv) { $higher++; ##if card is greater or equal one card in deck then higher++ } else { $lower++; ##if lower then lower-- } } $gah = $higher/&sub_count; $percentuno=$gah*100; ##calculate go higher % $gag = $lower/&sub_count; $percentdos=$gag*100; ##calculate go lower % if ($lower>$higher) { print "Lower is the better choice (" . $percentdos . " % chance the next card will be lower /" . $percentuno . "% chance higher)\n"; ###Lower>higher choice, + show percents } elsif ($higher>$lower) { print "Higher is the better choice (" . $percentuno . " % chance the next card will be higher /" . $percentdos . "% 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($gtfo) = @_; $gtfi=uc($gtfo); ##capalitilize if not already done so if ($gtfi eq "J") { $de = "11"; } elsif ($gtfi eq "Q") { $de = "12"; } elsif ($gtfi eq "K") { $de = "13"; } elsif ($gtfi eq "A") { $de = "14"; } else { $de=$gtfi; ##if not a face card just return } return $de; ###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 $temp(@deck) { $count++; ##count+1 in the array for each element(card) reviewd if ($temp == $come) { $count--; ##arrays start with 0, annoying as fuck but easily solved delete $deck[$count]; ###delete card last; #gtfo foreach loop } } #Trash the card $countor = $#deck; for ($tempa = 0; $tempa <= $countor; $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 $donotworry (@deck) { if ($donotworry=="11") { $new="J"; # JACK } elsif ($donotworry=="12") { $new="Q"; # QUEEN } elsif ($donotworry=="13") { $new="K"; # KING } elsif ($donotworry=="14") { $new="A"; # ACE } else { $new=$donotworry; ##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 $variblethisdoesntmattergod(@deck) { $cardsindeck++; } return $cardsindeck; }