basic level design sanity checks assert startx !none and starty !none'level % (around line %sin % is missing "@or "+to mark the start point (levelnum+ linenumfilename assert len(goals 'level % (around line %sin % must have at least one goal (levelnum+ linenumfilename assert len(stars>len(goals)'level % (around line %sin % is impossible to solve it has % goals but only % stars (levelnum+ linenumfilenamelen(goals)len(stars) create level object and starting game state object gamestateobj {'player'(startxstarty) 'stepcounter' 'stars'stars levelobj {'width'maxwidth 'height'len(mapobj) 'mapobj'mapobj 'goals'goals 'startstate'gamestateobj levels append(levelobj reset the variables for reading the next map maptextlines [ mapobj [ gamestateobj { levelnum + return levels def floodfill(mapobjxyoldcharacternewcharacter) """changes any values matching oldcharacter on the map object to newcharacter at the (xypositionand does the same for the positions to the leftrightdownand up of (xy)recursively "" in this gamethe flood fill algorithm creates the inside/outside floor distinction this is "recursivefunction for more info on the flood fill algorithmsee if mapobj[ ][ =oldcharacter mapobj[ ][ynewcharacter if len(mapobj and mapobj[ + ][ =oldcharacter floodfill(mapobjx+ yoldcharacternewcharactercall right if and mapobj[ - ][ =oldcharacteremail questions to the authoral@inventwithpython com