def addToBoard(board, piece): # fill in the board based on piece's location, shape, and rotation for x in range(TEMPLATEWIDTH): for y in range(TEMPLATEHEIGHT): if PIECES[piece['shape']][piece['rotation']][y][x] != BLANK: board[x + piece['x']][y + piece['y']] = piece['color']
The board data structure is a data representation for the rectangular space where pieces that have previously landed are tracked. The currently falling piece is not marked on the board data structure. What the
addToBoard() function does is takes a piece data structure and adds its boxes to the board data structure. This happens after a piece has landed.
for loops on lines 3  and 4  go through every space in the piece data structure, and if it finds a box in the space (line 5 ), it adds it to the board (line 6 ).