I've been working with my Ardunino mega now for several weeks and the results have been pleasing but I am still very much a newbie.
With the help of people on this forum, my first electronic game is nearing completion.
For my next project, I want to do a 3 reel fruit machine.
I know how the game should work and I can work out the electronics, my question broadly is how to map reel position to the win table.
Basic concept. Three stepper motors each with an optic, the motors rotate until the optic registers the start position, so the position of each reel is known. I then need to spin each reel a random amount of time, but I need to count from the start position, so the code always knows which symbol is on the win line.
So if each motor has 24 steps, each step will correspond to a symbol(fruit). So reel 1, position 1 = Orange, reel 1 position 2 = Lemon and so on. I would then test if matching symbols appear on the win line across all 3 reels and if so pay a win accordingly.
Before I start thinking about coding the project, I need some pointers on how to program the logic. I'm not asking for the code, I just need some help getting started really.
The way I see it there are 3 reels, 24 potential positions/fruit on each reel, and lets say 10 winning combinations, somehow I need to put that together into a motor control/win table.
and lets say 10 winning combinations, somehow I need to put that together into a motor control/win table.
It sounds like you are making this more complicated than it needs to be. Nothing in the table controls the motor. That is done by the random time.
The final position of 3 reels, with 24 positions each, would be simple to look up in a 72 element boolean array. A true in positions 0 to 23 would correspond to whether that spot on reel 1 was a winner. A true on positions 24 to 47 would correspond to whether that spot on reel 2 was a winner. Similarly, for reel 3, a true in positions 48 to 71 would indicate a winner.
Look up the value in three positions. Three trues indicate a win. Any falses and you loose.
But to be clear, reel 1 - position 7 could be a lemon, reel 2 - position 14 could be a lemon, reel 3 position 21 could be a lemon.
What, exactly, is at each position is not that important. What is important is that each position in the array corresponds to a win or loss. Rather than booleans, perhaps a byte array, with values between 0 and 255. Look up a value for each reel/position. Add the values. Certain totals mean win, while others mean loss. The actual payout could be determined from the totals.