IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Python Discussion :

Automate cellulaire


Sujet :

Python

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 2
    Par défaut Automate cellulaire
    Bonjour, je suis étudiant en bioingénierie et je dois créer un automate cellulaire pour mon cours d'informatique.


    J'aurais besoin d'un petit peu d'aide


    L'énoncé du travail se trouve en pièce jointe.


    Voici le début de mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    import sys
     
    n=int(raw_input('Entrez votre règle en décimal\n'))
     
    def dec2bin(n) :
        if n<0 or n>255 :
            return 'Nombre non compris entre 0 et 255'
        else :
            bin1 = []
            while n!=0 :
                if (n%2) ==0 :
                    n=n/2
                    bin1.insert (0,0)
                else :
                    n = (n-1)/2
                    bin1.insert (0,1)
            while len (bin1) <8 :
                bin1.insert (0,0)
        return bin1
     
    bin=dec2bin(n)
     
    print bin
     
    lignepapa = raw_input('Entrez une liste de chiffres\n')
     
    n = raw_input ('Nombres de lignes')
     
    lignepapa= str(lignepapa)
     
    lignepapa= list(lignepapa)
     
    u = len(lignepapa)
     
    def reglesautomate () :
        lignegarcon = []
        for i in range (0,u) :
            if lignepapa[int((i-1)%u)]==1 and lignepapa [i]==1 and lignepapa [int((i+1)%u)]==1 :
                lignegarcon.append (dec2bin [0])
            elif lignepapa[int((i-1)%u)]==1 and lignepapa [i]==1 and lignepapa [int((i+1%u)]==0 :
                lignegarcon.append (dec2bin [1])
            elif lignepapa[int((i-1)%u)]==1 and lignepapa [i]==0 and lignepapa [int((i+1)%u)]==1 :
                lignegarcon.append (dec2bin [2])
            elif lignepapa[int((i-1)%u)]==0 and lignepapa [i]==1 and lignepapa [int((i+1)%u)]==0 :
                lignegarcon.append (dec2bin [3])
            elif lignepapa[int((i-1)%u)]==0 and lignepapa [i]==1 and lignepapa [int((i+1)%u]==1 :
                lignegarcon.append (dec2bin [4])
            elif lignepapa[int((i-1)%u)]==0 and lignepapa [i]==1 and lignepapa [int((i+1)%u)]==0 :
                lignegarcon.append (dec2bin [5])
            elif lignepapa[int((i-1)%u)]==0 and lignepapa [i]==0 and lignepapa [int((i+1)%u)]==1 :
                lignegarcon.append (dec2bin [6])
            else :
                lignepapa [int((i-1)%u)]==0 and lignepapa [i]==0 and lignepapa [int((i+1)%u)]==0
                lignegarcon.append (dec2bin [7])
     
        return lignegarcon
     
    ligneenfant= reglesautomate ()
     
    print ligneenfant
     
    def repeat (n,regle, lignepapa) :
        n= int (n)
        print lignepapa

    J'ai plusieurs problèmes :

    1) J'ai réalisé le début en utilisant "raw_input" or, on demande de pouvoir invoquer l'automate à partir du terminal. Comment faire?

    2) la fin de mon code me donne une ligne de 0 et non un réel nouvel "état". Je ne comprends pas pourquoi

    3) Comment répéter la règle sur "n" ligne filles?

    Merci beaucoup d'avance !
    Images attachées Images attachées

Discussions similaires

  1. Réponses: 7
    Dernier message: 03/02/2010, 23h03
  2. [Turbo Pascal] Jeu de la vie (automate cellulaire)
    Par whatelse dans le forum Turbo Pascal
    Réponses: 2
    Dernier message: 25/10/2009, 01h52
  3. les automates cellulaire pour traitement d'image
    Par hanou88 dans le forum Traitement d'images
    Réponses: 0
    Dernier message: 27/04/2009, 13h30
  4. Les automates cellulaires
    Par charly dans le forum Algorithmes et structures de données
    Réponses: 3
    Dernier message: 10/08/2006, 17h35

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo