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

Langage Delphi Discussion :

Stack OverFlow


Sujet :

Langage Delphi

  1. #1
    Membre averti Avatar de Goundy
    Profil pro
    Étudiant
    Inscrit en
    Avril 2005
    Messages
    605
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2005
    Messages : 605
    Points : 386
    Points
    386
    Par défaut Stack OverFlow
    Bonsoir les gens,
    Bon je suis en train de simuler un demineur à mon rithme mais j'ai rencontrer un bug qui dis: Stack overflow
    J'ai créer une fonction récursive qui dévoile toutes les case vides voisines comme ca se passe dans le vrai demineur mais ca va pas comme je le souhaite et j'ai toujours l'erreur mentionée en haut, bon voilà un bout de 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
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
     
    type  TGameArray = array of array of integer;
    const
       L = 9; //Ligne
       C = 9;//Colone
       M = 10;//Nombre de mine
     
    var Table:TGameArray;//Table de jeu
    //Alors la vienne les procedure et fonctions qui initialise le jeu et tout
    ....
     
    //Le joueur click sur une cellule
    procedure TForm1.GrilleSelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    begin
     case Table[ARow,ACol] of // selon le nombre se trouvant dans le tableau
     8://Grille.Cells[ACol,ARow] := ' ';// 8 designe un blanc
      KillBlanks (ARow, ACol); // j'affiche tout les blanc voisins
     0:Grille.Cells[ACol,ARow] := 'O';//0 designe une mine
     else
      Grille.Cells[ACol,ARow] := inttostr(Table[ARow,ACol]);
     end (*case*)
    end;
     
    //et voila la procedure KillBlank
    procedure TForm1.KillBlanks (Row,Col:integer);
    var MinesNbr:integer;
     begin
     Grille.Cells[Col,Row] := ' ';//J'affiche le blanc actuel
     
     // je traite les cases voisines
      if Row > 0 then
       begin
        if Col + 1 < C then
         if Table[Row-1,Col+1] = 8 then
              KillBlanks(Row-1,Col+1)
               else
                 Grille.Cells[Col+1,Row-1]:=inttostr(Table[Row-1,Col+1]);
     
         if Table[Row-1,Col] = 8 then
              KillBlanks(Row-1,Col)
               else
                 Grille.Cells[Col,Row-1]:=inttostr(Table[Row-1,Col]);
     
        if Col - 1 > 0 then
         if Table[Row-1,Col-1] = 8 then
            KillBlanks(Row-1,Col-1)
             else
                 Grille.Cells[Col-1,Row-1]:=inttostr(Table[Row-1,Col-1]);
       end;(*Row>0*)
     
         if Row < (L-1) then
       begin
        if Col + 1 < C then
         if Table[Row+1,Col+1] = 8 then
           KillBlanks(Row+1,Col+1)
            else
              Grille.Cells[Col+1,Row+1]:=inttostr(Table[Row+1,Col+1]);
     
         if Table[Row+1,Col] = 8 then
            KillBlanks(Row+1,Col)
             else
               Grille.Cells[Col,Row+1]:=inttostr(Table[Row+1,Col]);
     
        if Col - 1 > 0 then
         if Table[Row+1,Col-1] = 8 then
             KillBlanks(Row+1,Col-1)
              else
               Grille.Cells[Col-1,Row+1]:=inttostr(Table[Row+1,Col-1]);
       end;(*Row<L-1*)
     
        if Col < (C-1) then
         if Table[Row,Col+1] = 8 then
             KillBlanks(Row,Col+1)
              else
               Grille.Cells[Col+1,Row]:=inttostr(Table[Row,Col+1]);
     
        if Col > 0 then
          if Table[Row, Col-1] = 8 then
              KillBlanks(Row,Col-1)
               else
                Grille.Cells[Col-1,Row]:=inttostr(Table[Row,Col-1]);
     
     
     end;(*KillBlanks*)
    Merci d'avance

  2. #2
    Expert éminent
    Avatar de smyley
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    6 270
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 6 270
    Points : 8 344
    Points
    8 344
    Par défaut
    Stack Overflow c'est que la fonction s'appelle à l'infini. Vérifie bien à chaque étape la valeur de ARow et ACol pour vérifier si tu ne crées pas une boucle sans fin

  3. #3
    Membre averti Avatar de Goundy
    Profil pro
    Étudiant
    Inscrit en
    Avril 2005
    Messages
    605
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2005
    Messages : 605
    Points : 386
    Points
    386
    Par défaut
    C'est bon probleme regler enfait j'effetuait le check des case voisines infiniment et voilà quoi lol
    Merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [GNU-Prolog][Mémoire] Local stack overflow
    Par Maxoo dans le forum Prolog
    Réponses: 15
    Dernier message: 04/06/2008, 22h15
  2. Repérer un stack overflow ?
    Par khayyam90 dans le forum C++
    Réponses: 3
    Dernier message: 19/02/2007, 13h23
  3. stack overflow: question insoluble
    Par coyotte507 dans le forum SDL
    Réponses: 3
    Dernier message: 19/12/2006, 17h50
  4. Problème de stack overflow
    Par heider dans le forum Langage
    Réponses: 13
    Dernier message: 22/09/2005, 19h50
  5. Stack overflow
    Par portu dans le forum Langage
    Réponses: 3
    Dernier message: 26/11/2003, 15h16

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