Introduction And The First Step
My class and I were tasked with creating 3 projects over 6 weeks. A python coding project, a CAD project, and an arduino robotics project. I decided to start with the python project and created a Slot Machine. These are some of the various steps I went through in order to make this a possibility.
First, I needed to create a FlowChart in order to project what my final product was going to look like.
Quick note before I begin, I have highlighted the comments in a light green for organization.
After finishing the FlowChart, I started with the slot machine system portion and added a random number generator that will draw randomly from all the numbers in the “box” and put them into my code. I made sure that the numbers/signs that will give you more money like the “7” and the “$” had a much smaller chance of being rolled to make it harder than it looks to get a jackpot. After, I created a function that when ran, prints “WELCOME TO THE SLOT MACHINE” and then ran it.
I set up the function where it actually asks whether or not you would like to roll as long as you have 5 dollars left. If you say that you would like to roll, it prints the 3 digits that you got in a “# # #” order and you will lose 5 dollars so as to simulate the price of the slot machine.
To the right you will find the different conditions in which you get money. I made it so if you get a “# $ #” it is worth more than a “# # $” or a “$ # #” because it looks more aesthetically pleasing. I also made a regular jackpot where if all the numbers are the same, you get 750 dollars. I made a double jackpot for 1k dollars if you get three sevens and a super jackpot that beats the game and gives you 10K if you get three $ signs in one roll. I made sure that all of these chances with the exception of the “# $ #” have a lower chance of you getting them then the amount of money they give you. As an example, the chance to get a “$ # #” is a 1/30 chance because there are 30 numbers in the box and only one of them is a dollar sign, but it only gives you 25 which is much less than what it should give.
Here was the final thing to make my coding work; conditions to end the game. This just shows that if you say no to the offer of rolling, you walk away and do not gamble which ends the game. The other option is that if you were to get over 10,000 dollars, you would win.
Here was the final thing to make my coding work; conditions to end the game. This just shows that if you say no to the offer of rolling, you walk away and do not gamble which ends the game. The other option is that if you were to get over 10,000 dollars, you would win. The picture will be shown down below.
Please note that for some reason no matter what you say in response to the asking whether or not you would like to roll, it will roll for you unless you say “N”. This is not supposed to happen and I believe it is a glitch with the python coding website I am using.
After all of this, the final output will look like this:
Leave a Reply