Esempio n. 1
0
 def textToLife(self, text):
     # figure out game dimensions
     width = len(text) * 5 + 1
     height = 9
     lifeGame = Life(height=height, width=width)
     lifeGame.clean(state=LifeState.DEAD)
     currI = 1
     currJ = 1
     for character in text.upper():
         for iIdx in range(7):
             for jIdx in range(4):
                 gameIndices = (currI + iIdx, currJ + jIdx)
                 dictIndices = (iIdx, jIdx)
                 lifeGame.game[0][gameIndices[0]][gameIndices[1]].state \
                     = self.strDict[character][dictIndices[0]][dictIndices[1]]
         currJ += 5
     return lifeGame