Transposed wheels in machine str
This commit is contained in:
@@ -18,16 +18,29 @@ class SlotMachine():
|
||||
|
||||
def __str__(self):
|
||||
string = ""
|
||||
for wheel in self.wheels:
|
||||
string += str(wheel) + "\n"
|
||||
# Create an empty matrix with the sole purpose of transposing it
|
||||
matrix = [[],[],[]]
|
||||
|
||||
for i, wheel in enumerate(self.wheels):
|
||||
for icon in wheel.icons:
|
||||
matrix[i].append(icon)
|
||||
|
||||
# Use Zip function to aggregate unpacked matrix (*matrix unpacks it)
|
||||
matrix = zip(*matrix)
|
||||
|
||||
for row in matrix:
|
||||
for icon in row:
|
||||
string += str(icon) + " "
|
||||
string += "\n"
|
||||
|
||||
return string
|
||||
|
||||
|
||||
def main():
|
||||
# machine = SlotMachine()
|
||||
# print(machine)
|
||||
# machine.spin(randomness=1)
|
||||
# print(machine)
|
||||
machine = SlotMachine()
|
||||
print(machine)
|
||||
machine.spin()
|
||||
print(machine)
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user