How to Help Your Business Become an AI Early Adopter
Part 1 - The basics
I have a confession to make... I like gambling. OK, I am not addicted to gambling at all, but every once in a while (when the wife and I have a date night) we'll go to an internet cafe and gamble a bit. We like playing video slot games.
I have always found them fascinating - that is mainly why I play. As curious as I am, I told my wife once that I'd like to try to make my own, hence, this article series.
The video slot machine is a more recent innovation, with no moving parts at all – instead a graphical representation of one appears on screen. Since the player is essentially playing a computer/video game, the manufacturers are able to offer more interactive elements, such as advanced bonus games and advanced video graphics.
In addition, because there are no mechanical constraints on the design of video slot machines, most display five reels rather than three. This greatly expands the number of possibilities: a machine can have 50 or more symbols on a reel, giving odds as high as 300 million to 1 against – enough for even the largest jackpot. As there are so many combinations given by five reels, the manufacturers do not need to weight the payout symbols (although some may still do so). Instead, higher paying symbols will typically appear only once or twice on each reel, while more common symbols, earning a more frequent payout, will appear many times.
Video slot machines typically encourage the player to play multiple 'lines', so rather than simply taking the middle of the three symbols displayed on each reel, a line could go from top left to bottom right, or any of the other patterns specified by the manufacturer. As each symbol is equally likely, there is no difficulty for the manufacturer in allowing the player to take any or all of the possible lines on offer – the long-term return to player will be the same. The difference for the player is that the more lines he plays the more likely he is to get paid on a given spin – though of course he is betting more in the first place.
To avoid the feeling that the player's money is simply ebbing away (whereas a payout of 100 credits on a single line machine would be 100 bets, and the player would feel they had made a substantial win, on a 20 line machine, it would only be 5 bets and would not seem significant), manufacturers commonly offer bonus games, which can return many times their bet. The player is encouraged to keep playing to reach the bonus: even if he is losing, the bonus game could allow him to win back his losses.
Our project will function the same way. Obviously I am not the world's best graphic designer, so my pictures will not be fantastic. I will try to relate the logic used to make these games to you. Unfortunately, there will be no bonus rounds. I'll leave that logic to you.
Time to get our hands dirty! Our project's name is HTG Slots. It is a VB.NET Windows Forms Project. Once you have created the project, add the following controls to it and set the appropriate properties for each.
|Image||HTG_Slots.My.Resources.Resources.SPIN ( Or a Picture of your choice )|
This produces a screen with five columns, i.o.w our wheels, in which we can put all our pictureboxes. The easiest would be to add the PictureBoxes at runtime, as they will be easier to maintain and keep track of when they are stored in an array or two. We will have four pictures in each column, so that gives us twenty PictureBoxes in total. Now, we need to fill them with images and make the wheels spin! In general Video Slot games have 5 columns ( wheels ) of three pictures each. I am not saying my variant is not common; it is not as common as its three row counterpart.
Making Them Spin - the Code
The obvious place to start is with the images, and putting them into pictureboxes - which we will create on the fly. Create the following objects in General Declarations :
Private arrImages(9) As Image 'Images Private Column1(3) As PictureBox 'Wheel 1 Private Column2(3) As PictureBox 'Wheel 2 Private Column3(3) As PictureBox 'Wheel 3 Private Column4(3) As PictureBox 'Wheel 4 Private Column5(3) As PictureBox 'Wheel 5
Add the next code inside Form_Load :
Private Sub frmHTGSlots_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Load all images from resources arrImages(0) = My.Resources.applesmall1 arrImages(1) = My.Resources.bananasmall1 arrImages(2) = My.Resources.cherry21 arrImages(3) = My.Resources.fruitbowlz1 arrImages(4) = My.Resources.grapesmall1 arrImages(5) = My.Resources.lemonsmall1 arrImages(6) = My.Resources.orangesmall1 arrImages(7) = My.Resources.strawberrysmall1 arrImages(8) = My.Resources.Kiwi1 arrImages(9) = My.Resources.Pineapple_jumps1 End Sub
We have created the picturebox arrays to be used as our wheels, and we initialized our Images array with pictures that I have added into the project's resources. These pictures I have found on the internet - there are numerous websites that offer free gif files - feel free to use these, or add your own. Now we need to display the pictures randomly in all possible 20 pictureboxes. Add the following objects to your General Declarations section :
Private RandGen As Random 'Random number generator Private RandIndex As Integer 'Random index