Ejemplo n.º 1
0
def main():
    key = ''
    load_succesful = False

    while (key != '3'):
        key = menu_main()

        if (key == '2'):
            g = menu_load()
            load_succesful = True
        elif (key == '3'):
            sys.exit()

        if ((key == '1') or (load_succesful is True)):
            if (load_succesful is False):
                modo = menu_game_modes()

                if (modo == '1'):
                    """Modo Normal"""
                    tab_size = int(input('\n' + 'Tamaño del tablero: '))
                    t = Tablero(tab_size, tab_size)
                    random_place = input('\n' + 'Usar patron al azar? (s/n): ')

                    if (random_place == 's'):
                        cell_alive = int(
                            input('\n' + 'Cantidad '
                                  'de celdas vivas? '))
                        t.fill(cell_alive)

                    else:
                        t.manual_fill()

                    g = Game(int(modo), t)

                elif (modo == '2'):
                    """Modo Vidas Estaticas"""
                    tab_size = int(input('\n' + 'Tamaño del tablero: '))
                    cell_alive = int(input('\n' +
                                           'Cantidad de celdas vivas? '))
                    t = Tablero(tab_size, tab_size)

                    g = Game(int(modo), t, cell_alive)

            if (modo != '3'):
                g.running = True

                while (g.running):
                    try:
                        g.run()

                    except KeyboardInterrupt:
                        key = menu_pause()

                        if (key == '1'):
                            continue
                        elif (key == '2'):
                            menu_save(g)
                        elif (key == '3'):
                            g = menu_load()
                        elif (key == '4'):
                            g.tablero.manual_fill()
                        elif (key == '5'):
                            g.running = False
Ejemplo n.º 2
0
def main():
    key = ''
    load_succesful = False

    while (key != '3'):
        key = menu_main()

        if (key == '2'):
            g = menu_load()
            load_succesful = True
        elif (key == '3'):
            sys.exit()

        if ((key == '1') or (load_succesful is True)):
            if (load_succesful is False):
                modo = menu_game_modes()

                if (modo == '1'):
                    """Modo Normal"""
                    tab_size = int(input('\n' + 'Tamaño del tablero: '))
                    t = Tablero(tab_size, tab_size)
                    random_place = input('\n' + 'Usar patron al azar? (s/n): ')

                    if (random_place == 's'):
                        cell_alive = int(input('\n' + 'Cantidad '
                                               'de celdas vivas? '))
                        t.fill(cell_alive)

                    else:
                        t.manual_fill()

                    g = Game(int(modo), t)

                elif (modo == '2'):
                    """Modo Vidas Estaticas"""
                    tab_size = int(input('\n' + 'Tamaño del tablero: '))
                    cell_alive = int(
                        input('\n' + 'Cantidad de celdas vivas? '))
                    t = Tablero(tab_size, tab_size)

                    g = Game(int(modo), t, cell_alive)

            if (modo != '3'):
                g.running = True

                while (g.running):
                    try:
                        g.run()

                    except KeyboardInterrupt:
                        key = menu_pause()

                        if (key == '1'):
                            continue
                        elif (key == '2'):
                            menu_save(g)
                        elif (key == '3'):
                            g = menu_load()
                        elif (key == '4'):
                            g.tablero.manual_fill()
                        elif (key == '5'):
                            g.running = False