diff --git a/src/py/slots/Slots.py b/src/py/slots/Slots.py index 9846765..c786e34 100644 --- a/src/py/slots/Slots.py +++ b/src/py/slots/Slots.py @@ -8,14 +8,14 @@ class SlotMachine(): for i in range(screen_w): wheel = Wheel(size=screen_h) self.wheels.append(wheel) - - def spin(self, wSpins=3, randomness=0.5): + + def spin(self, wSpins=3): for _ in range(wSpins): for wheel in self.wheels: - if random() >= randomness: wheel.spin() + def __str__(self): string = "" # Create an empty matrix with the sole purpose of transposing it @@ -39,8 +39,13 @@ class SlotMachine(): def main(): machine = SlotMachine() print(machine) - machine.spin() + machine.spin(wSpins=1) print(machine) + machine.spin(wSpins=1) + print(machine) + machine.spin(wSpins=1) + print(machine) + pass if __name__ == "__main__": diff --git a/src/py/slots/Wheel.py b/src/py/slots/Wheel.py index d2c9772..0190046 100644 --- a/src/py/slots/Wheel.py +++ b/src/py/slots/Wheel.py @@ -1,10 +1,14 @@ +import random as rand + + """ Wheel Class for implementing a wheel that spins in a poker machine """ class Wheel(): - def __init__(self, size=3): + def __init__(self, size=3, num_icons = 3): self.size=size self.icons = list(range(size)) + self.num_icons = num_icons def spin(self, offset=1): new_icons = list(range(self.size)) @@ -12,6 +16,9 @@ class Wheel(): # Uses modulus to loop final icon to first position for i, icon in enumerate(self.icons): new_icons[(i + offset) % len(new_icons)] = icon + + # Randomise the first element + new_icons[0] = rand.randint(0, self.num_icons - 1) self.icons = new_icons diff --git a/src/py/slots/__pycache__/Wheel.cpython-313.pyc b/src/py/slots/__pycache__/Wheel.cpython-313.pyc index 532b4f4..3031495 100644 Binary files a/src/py/slots/__pycache__/Wheel.cpython-313.pyc and b/src/py/slots/__pycache__/Wheel.cpython-313.pyc differ