top boxy (boxsize gapsizeymargin return (lefttop def getboxatpixel(xy) for boxx in range(boardwidth) for boxy in range(boardheight) lefttop lefttopcoordsofbox(boxxboxy boxrect pygame rect(lefttopboxsizeboxsize if boxrect collidepoint(xy) return (boxxboxy return (nonenone def drawicon(shapecolorboxxboxy) quarter int(boxsize syntactic sugar half int(boxsize syntactic sugar lefttop lefttopcoordsofbox(boxxboxyget pixel coords from board coords draw the shapes if shape =donut pygame draw circle(displaysurfcolor(left halftop half)half pygame draw circle(displaysurfbgcolor(left halftop half)quarter elif shape =square pygame draw rect(displaysurfcolor(left quartertop quarterboxsize halfboxsize half) elif shape =diamond pygame draw polygon(displaysurfcolor((left halftop)(left boxsize top half)(left halftop boxsize )(lefttop half)) elif shape =lines for in range( boxsize ) pygame draw line(displaysurfcolor(lefttop )(left itop) pygame draw line(displaysurfcolor(left itop boxsize )(left boxsize top ) elif shape =oval pygame draw ellipse(displaysurfcolor(lefttop quarterboxsizehalf) def getshapeandcolor(boardboxxboxy) shape value for xy spot is stored in board[ ][ ][