Example of separating game state/logic from the UI library (pygame)
Python API for minesweeper game and an implementation with pygame