orect osurf get_rect( orect center (int(windowwidth int(windowheight while true keep looping until the player has clicked on color checkforquit( for event in pygame event get()event handling loop if event type =mousebuttonup mousexmousey event pos if xrect collidepoint(mousexmousey) return [white_tileblack_tile elif orect collidepoint(mousexmousey) return [black_tilewhite_tile draw the screen displaysurf blit(textsurftextrect displaysurf blit(xsurfxrect displaysurf blit(osurforect pygame display update( mainclock tick(fps def makemove(boardtilexstartystartrealmove=false) place the tile on the board at xstartystartand flip tiles returns false if this is an invalid movetrue if it is valid tilestoflip isvalidmove(boardtilexstartystart if tilestoflip =false return false board[xstart][ystarttile if realmove animatetilechange(tilestofliptile(xstartystart) for xy in tilestoflip board[ ][ytile return true def isoncorner(xy) returns true if the position is in one of the four corners return ( = and = or ( =boardwidth and = or ( = and =boardheightor ( =boardwidth and =boardheight