ignore the linesthey're comments in the level file line line[:line find(';')if line !''this line is part of the map maptextlines append(lineelif line ='and len(maptextlines blank line indicates the end of level' map in the file convert the text in maptextlines into level object find the longest row in the map maxwidth - for in range(len(maptextlines))if len(maptextlines[ ]maxwidthmaxwidth len(maptextlines[ ]add spaces to the ends of the shorter rows this ensures the map will be rectangular for in range(len(maptextlines))maptextlines[ +(maxwidth len(maptextlines[ ])convert maptextlines to map object for in range(len(maptextlines[ ]))mapobj append([]for in range(len(maptextlines))for in range(maxwidth)mapobj[xappend(maptextlines[ ][ ]loop through the spaces in the map and find the @and characters for the starting game state startx none the and for the player' starting position starty none goals [list of (xytuples for each goal stars [list of (xyfor each star' starting position for in range(maxwidth)for in range(len(mapobj[ ]))if mapobj[ ][yin ('@''+')'@is player'+is player goal startx starty if mapobj[ ][yin (''+''*')is goal'*is star goal goals append((xy)if mapobj[ ][yin ('$''*')'$is star stars append((xy)