0
Pygame
I have a 30x30 grid, how do I make a prims maze half the height and width of that grid?
1 Answer
+ 2
Kirill Vidov
#This is a colour guessing game.
#There are 3 colours to guess from: red,blue,yellow
#Just type your colour choice.
#Guess rightly and win, otherwise you loose :)
#Please upvote if you like it.
import sys
from random import randint as rad
class Obj:
def __init__(self,rec): #initialization
self.rec = rec
def __repr__(self): #magic method for automatic object formatting
return ("Memory slot({})".format(self.rec))
class Choice(Obj): #choice inherits frm obj
def __getitem__(self,val): #magic method to get a specified index value from a list
res = self.rec[rad(0,val)] #randomizing indices btw 0 and a specified index "val"
print ("CPU says {}".format(res)) #printing the randomized result.
return (res)
def __eq__(self,other): #magic method defining a behaviour for the "==" operator
return (self.rec==other)
def __exit__(self,other):
if self.rec not in other:
return sys.exit()
mem= Choice(["red","blue","yel