Skip to content

Instantly share code, notes, and snippets.

@lvidarte
Created June 9, 2017 06:10
Show Gist options
  • Save lvidarte/02101fe099ef23aff5324be94382c810 to your computer and use it in GitHub Desktop.
Save lvidarte/02101fe099ef23aff5324be94382c810 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
"""
Author: Leo Vidarte <http://nerdlabs.com.ar>
This is free software,
you can redistribute it and/or modify it
under the terms of the GPL version 3
as published by the Free Software Foundation.
"""
"""
Las transiciones dependen del número de células vecinas vivas:
* Una célula muerta con exactamente 3 células vecinas vivas "nace"
(al turno siguiente estará viva).
* Una célula viva con 2 ó 3 células vecinas vivas sigue viva.
* En otro caso muere o permanece muerta (por "soledad" o "superpoblación").
"""
DEAD = 0
ALIVE = 1
def print_board(board):
for row in board:
print(' '.join(['.' if col == DEAD else '#' for col in row]))
if __name__ == '__main__':
# Glider
board = [
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
]
print_board(board)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment