VB/VB.Net Besoin d'aider pour mon pathfinding EDITE

asyade

Membre Actif
Inscrit
26 Avril 2013
Messages
368
Reactions
1
#1
Salut, je travaille sur mon patfinthing depuis un moment est sa veut toujours pas marcher -_- svp i need your help ^^'
voici mon code (c'est un a*)

Code:
Public Class pathfinding

#Region "Declarations"

    Dim NODE_DISTANCE_VALUE As Integer = 10
    Dim m_openList As New List(Of Node)
    Dim m_closeList As New List(Of Node)

#End Region

#Region "Metode"

    Public Function findPath(ByVal param_graphe(,) As Node, ByVal param_start As Node, ByVal param_end As Node) As List(Of Node)

        Dim finalPath As New List(Of Node)

        addToOpenList(param_start)

        Dim currentNode As Node = Nothing

        While (m_openList.Count > 0) '  stopper la boucle si la liste ouverte est vide
            ' a. Récupération du node avec le plus petit F contenu dans la liste ouverte. On le nommera CURRENT.
            currentNode = getCurrentNode(param_end)

            '  stopper la boucle si n ajoute le noeud d'arrivée à la liste fermée
            If currentNode.col = param_end.col And currentNode.line = param_end.line Then
                Exit While
            End If
            ' b. Basculer CURRENT dans la liste fermée.
            addToCloseList(currentNode)
            Dim neighbours As List(Of Node) = getNeighbours(currentNode, param_graphe)
            For i As Integer = 0 To neighbours.Count - 1
                Dim node As Node = neighbours(i)

                'Si le node est un obstacle ou est dans la liste fermée ignorez-le et passer à l'analyse d'un autre node.
                If node.walkable = False Then
                    Continue For
                End If
                If isOnCloseList(node) Then
                    Continue For
                End If

                Dim newG As Integer = node.parent.G + NODE_DISTANCE_VALUE
                Dim newH As Integer = (Math.Abs(param_end.line - node.line) + Math.Abs(param_end.col - node.col)) * NODE_DISTANCE_VALUE
                Dim newF As Integer = newH + newG


                If (isOnOpenList(node)) Then

                    If (newG < node.G) Then
                        node.parent = currentNode
                        node.G = newG
                        node.H = newH
                        node.F = newF

                    Else

                        addToOpenList(node)
                        node.parent = currentNode
                        node.G = newG
                        node.H = newH
                        node.F = newF
                    End If

                End If

            Next
        End While


        ' on est sorti de la liste, on a deux solutions, soit la liste ouverte est vide dans ces cas là il 
        ' n'y a pas de solutions et on retoure directement finalPath

        If m_openList.Count = 0 Then
            Return finalPath
        End If

        ' Soit on maintenant on construit le chemin à rebours

        Dim lastNode As Node = param_end
        While lastNode IsNot param_start
            finalPath.Add(lastNode)
            lastNode = lastNode.parent
        End While


        ' on retourne le chemin final

        Return finalPath
    End Function

    Sub removeFromCloseList(ByVal param_node As Node)
        m_closeList.Remove(param_node)
    End Sub

    Sub removeFromOpenLisC:\Users\asyai\Desktop\SlimeBot\Pathfindtinh\WindowsApplication1\pathfinding.vbt(ByVal param_node As Node)
        m_openList.Remove(param_node)
    End Sub

    Sub addToCloseList(ByVal param_node As Node)
        removeFromOpenList(param_node)
        m_closeList.Add(param_node)
    End Sub

    Sub addToOpenList(ByVal param_node As Node)
        removeFromCloseList(param_node)
        m_openList.Add(param_node)
    End Sub

    Function getCurrentNode(paramend As Node) As Node
        Dim tmpList As New List(Of Node)
        Dim minF As Integer = 1000000
        Dim curNode As Node = Nothing

        For i As Integer = 0 To m_openList.Count - 1
            Dim node As Node = m_openList(i)
            If (node.F < minF) Then
            minF = node.F
            curNode = node
            End If
        Next
        Return curNode
    End Function

    Function getNeighbours(ByVal param_node As Node, ByVal param_graphe(,) As Node) As List(Of Node)
        Dim neighbours As New List(Of Node)
        Dim maxcol As Integer = 10
        Dim maxline As Integer = 10


        ' on calcule l'indice de la ligne au dessus de la ligne du node
        Dim indiceUp As Integer = param_node.line - 1

        ' on calcule l'indice de la ligne au dessus de la ligne du node
        Dim indiceBottom As Integer = param_node.line + 1

        ' on calcule l'indice de la colonne à gauche de la colonne du node
        Dim indiceLeft As Integer = param_node.col - 1

        ' on calcule l'indice de la colonne à droite de la colonne du node
        Dim indiceRight As Integer = param_node.col + 1


        ' si la ligne du dessus existe alors le node du dessus existe on ajoute alors le  node du dessus
        If indiceUp > -1 Then
            neighbours.Add(param_graphe(indiceUp, param_node.col))
        End If
        ' si la ligne du dessous existe alors le node du dessous existe on ajoute alors le  node du dessous  
        If indiceBottom < maxline Then
            neighbours.Add(param_graphe(indiceBottom, param_node.col))
        End If
        ' si la colonne de gauche existe alors le node de gauche existe on ajoute alors le  node de gauche
        If indiceLeft > -1 Then
            neighbours.Add(param_graphe(param_node.line, indiceLeft))
        End If
        ' si la colonne de droite existe alors le node de droite existe on ajoute alors le  node de droite
        If indiceRight < maxcol Then
            neighbours.Add(param_graphe(param_node.line, indiceRight))
        End If

        Return neighbours
    End Function

    Function isOnOpenList(param_node As Node) As Boolean
        Dim ret As Boolean = False
        For i As Integer = 0 To m_openList.Count - 1
            If m_openList(i) = param_node Then
                ret = True
            End If
        Next
        Return ret
    End Function

    Function isOnCloseList(param_node As Node) As Boolean
        For i As Integer = 0 To m_closeList.Count - 1
            If m_closeList(i) = param_node Then
                Return True
            End If
        Next
        Return False
    End Function

#End Region

#Region "Proprieter"

#End Region

End Class
et la class node
Code:
Public Class Node

#Region "Declaration"

    Dim m_parent As Node
    Dim m_G, m_H, m_F As Integer
    Dim m_col As Integer
    Dim m_line As Integer
    Dim m_walkable As Boolean

#End Region

#Region "Metode"

    Sub New()
        m_walkable = False
        m_parent = Me
        m_G = m_H = m_F = 0
    End Sub

    Sub New(ByVal col As Integer, ByVal line As Integer)
        m_walkable = False
        m_parent = Me
        m_G = m_H = m_F = 0
        m_col = col
        m_line = line
    End Sub

    Public Function CalculeH(ByVal param_end As Node)
        m_H = (Math.Abs(param_end.line - Me.line) + Math.Abs(param_end.col - Me.col)) * 10
        Return m_H
    End Function

    Public Function CalculeG()
        m_G = Me.parent.G + 10
        Return m_G
    End Function

    Public Function CalculeF()
        m_F = m_G + m_H
        Return m_F
    End Function

    Public Sub Calcule(ByVal param_end As Node)
        CalculeH(param_end)
        CalculeG()
        CalculeF()
    End Sub
    Shared Operator <>(ByVal valeur1 As Node, ByVal valeur2 As Node)
        Dim ret As Boolean = False
        If valeur1.col = valeur2.col And valeur2.line = valeur1.line Then
            ret = True
        End If
        Return ret
    End Operator

    Shared Operator =(ByVal valeur1 As Node, ByVal valeur2 As Node)
        Dim ret As Boolean = False
        If valeur1.col = valeur2.col And valeur2.line = valeur1.line Then
            ret = True
        End If
        Return ret
    End Operator
#End Region

#Region "Proprieter"

    Property parent As Node
        Get
            Return m_parent
        End Get
        Set(value As Node)
            m_parent = value
        End Set
    End Property

    Property G As Integer
        Get
            Return m_G
        End Get
        Set(value As Integer)
            m_G = value
        End Set
    End Property

    Property H As Integer
        Get
            Return m_H
        End Get
        Set(value As Integer)
            m_H = value
        End Set
    End Property

    Property F As Integer
        Get
            Return m_F
        End Get
        Set(value As Integer)
            m_F = value
        End Set
    End Property

    Property col As Integer
        Get
            col = m_col
        End Get
        Set(value As Integer)
            m_col = value
        End Set
    End Property

    Property line As Integer
        Get
            line = m_line
        End Get
        Set(value As Integer)
            m_line = value
        End Set
    End Property

    Property walkable
        Get
            walkable = m_walkable
        End Get
        Set(value)
            m_walkable = value
        End Set
    End Property

#End Region

End Class
Help me T_T en analisant jai remarquer que la liste ouverte etait vide ce qui provoquait la fin de l'éxécutions
 
Inscrit
29 Septembre 2011
Messages
393
Reactions
3
#2
Re: Besoin d'aider pour mon pathfinding

Salut, déjà j'ai une question pourquoi tu utilise une librairie pour géré le pathfinding? pourquoi tu ne code pas ton propre pathfinding surtout que A*Star est un algorithme plutôt simple de prise en main :
Inscript toi dans la zone c++ j'ai poster une source d'un pathfinding que j'ai fait en c++ avec Qt sa pourra surement t'aider!
-> pathfinding.854/]viewtopic.php?f=47&t=1310
-> je me suis aider de se site http://forums.mediabox.fr/wiki/tutoriau ... thme_astar je trouve que l'explication est plutôt bien.
Ayant plus dofus sur mon pc je n'est pas réussi a tester ton programme j'essayerais plus tard!
 

asyade

Membre Actif
Inscrit
26 Avril 2013
Messages
368
Reactions
1
#3
Re: Besoin d'aider pour mon pathfinding

Ok, merci je vais essayer de coder sa alors :p
 

asyade

Membre Actif
Inscrit
26 Avril 2013
Messages
368
Reactions
1
#4
Re: Besoin d'aider pour mon pathfinding

J'ai essayer ... san succes j'ai essayer de traduire ton code (honte a moi ^^) sans succes (encore plus honte a moi) voici ce que j'ai obtenu en traduisant ton code

La class principale
Code:
Imports D2pReader.MapInformations
Imports D2pReader

Public Class clsAStar

#Region "Declarations"

    Dim MAP_WIDTH As Integer
    Dim MAP_HEIGHT As Integer
    Dim MAPID As Long = 84674062
    Dim CELLPOS(560) As Nods
    Dim currentMap As Map
    Dim finish_search As Boolean
    Dim openList As List(Of Nods)
#End Region

#Region "Metode"

    Public Function findPath(ByVal startId As Integer, ByVal endId As Integer) As List(Of Integer)
        initializeCurrentMap()
        Dim loc_1 As Integer = 0
        Dim loc_2 As Integer = 0
        Dim loc_3 As Integer = 0
        Dim loc_4 As Integer = 0
        Dim loc_5 As Integer = 0
        While (loc_5 < MAP_HEIGHT)
            loc_4 = 0
            While (loc_4 < MAP_WIDTH)
                CELLPOS(loc_3) = New Nods(loc_3, loc_1 + loc_4, loc_2 + loc_4)
                loc_3 += 1
                loc_4 += 1
            End While
            loc_1 += 1
            loc_4 = 0
            While (loc_4 < MAP_WIDTH)
                CELLPOS(loc_3) = New Nods(loc_3, loc_1 + loc_4, loc_2 + loc_4)
                loc_3 += 1
                loc_4 += 1
            End While
            loc_2 = loc_2 - 1
            loc_5 += 1
        End While

        For i As Integer = 0 To 559
            Dim appli As Boolean = False
            Dim _currentCell As CellData = currentMap.Cells(i)
            If i = startId Then
                appli = True
                CELLPOS(i).closed = False
                CELLPOS(i).started = True
                CELLPOS(i).walkable = _currentCell.Mov
            End If

            If i = endId Then
                appli = True
                CELLPOS(i).closed = True
                CELLPOS(i).started = False
                CELLPOS(i).walkable = _currentCell.Mov
            End If
            If appli = False Then
                CELLPOS(i).closed = False
                CELLPOS(i).started = False
            End If
            CELLPOS(i).walkable = _currentCell.Mov
            CELLPOS(i).calculH(CELLPOS(endId))
        Next
        Dim currentNode As Nods = CELLPOS(startId)

        While finish_search = False
            findNeighboringCell(currentNode, False)
            currentNode = openList(0)
            currentNode.inClosedList = True
            currentNode.inOpenList = False
            openList.RemoveAt(0)
        End While
        Dim currentCell As Nods = CELLPOS(endId)
        Dim cells As New List(Of Integer)
        While (currentCell.cellid = Not CELLPOS(startId).cellid)
            cells.Add(currentCell.cellid)
            currentCell = CELLPOS(currentCell.parent)
        End While
        cells.Add(startId)
        Dim chemin As New List(Of Integer)
        For reverse As Integer = cells.Count - 1 To -1
            reverse -= 2
            chemin.Add(cells(reverse))
        Next
        Return chemin
    End Function

    Sub initializeCurrentMap()
        Dim reader As New MapManager("C:\Program Files (x86)\Dofus2\app\content\maps")
        currentMap = reader.GetMap(MAPID)
    End Sub

    Sub findNeighboringCell(ByVal c_node As Nods, ByVal diagonal As Boolean)
        addCell(getCellIdFromPoint(c_node.x(), c_node.y() + 1), c_node)
        addCell(getCellIdFromPoint(c_node.x() - 1, c_node.y()), c_node)
        addCell(getCellIdFromPoint(c_node.x() + 1, c_node.y()), c_node)
        addCell(getCellIdFromPoint(c_node.x(), c_node.y() - 1), c_node)
        If diagonal Then
            addCell(getCellIdFromPoint(c_node.x() - 1, c_node.y() + 1), c_node)
            addCell(getCellIdFromPoint(c_node.x() + 1, c_node.y() + 1), c_node)
            addCell(getCellIdFromPoint(c_node.x() + 1, c_node.y() - 1), c_node)
            addCell(getCellIdFromPoint(c_node.x() - 1, c_node.y() - 1), c_node)
        End If
        sortOpenList()
    End Sub

    Sub addCell(ByVal cell As Integer, ByVal c_node As Nods)
        If CELLPOS(cell).walkable = True Then
            If CELLPOS(cell).closed = True Then
                CELLPOS(cell).parent = c_node.cellid
                finish_search = True
            End If
            If CELLPOS(cell).inOpenList() = False & CELLPOS(cell).inClosedList() = False Then
                CELLPOS(cell).parent = c_node.cellid
                CELLPOS(cell).inOpenList = True
                CELLPOS(cell).g = c_node.g() + 10
                CELLPOS(cell).f = CELLPOS(cell).g + CELLPOS(cell).h()
                openList.Add(CELLPOS(cell))
            End If
        End If
    End Sub

    Function getCellIdFromPoint(ByVal x As Integer, ByVal y As Integer)
        Return (x - y) * MAP_WIDTH + y + (x - y) / 2
    End Function

    Sub sortOpenList()
        Dim ok As Boolean = False
        While (ok = False)
            ok = True
            Dim temp As Nods
            For i As Integer = 0 To openList.Count - 1
                If openList(i).f > openList(i + 1).f Then
                    temp = openList(i)
                    openList(i) = openList(i + 1)
                    openList(i + 1) = temp
                    ok = False
                End If
            Next
        end while
    End Sub
#End Region
End Class
La class node
Code:
Public Class Nods

#Region "declarations"
    Dim m_x As Integer
    Dim m_y As Integer
    Dim m_cellid As Integer
    Dim m_started As Boolean = False
    Dim m_closed As Boolean = False
    Dim m_fermer As Boolean = False
    Dim m_walkable As Boolean
    Dim m_parent As Integer
    Dim n_inClosedList As Boolean
    Dim n_inOpenList As Boolean
    Dim m_h, m_f, m_g As Integer
#End Region

#Region "Fonctions public"
    Sub New(ByVal cellid As Integer, ByVal x As Integer, ByVal y As Integer)
        m_cellid = cellid
        m_x = x
        m_y = y
    End Sub

    Public Sub calculH(ByVal endNode As Nods)
        m_h = 10 * (endNode.x - m_x) + (endNode.y - m_y)
    End Sub
#End Region

#Region "Propriété"

    Property h As Integer
        Get
            h = m_h
        End Get
        Set(value As Integer)
            m_h = value
        End Set
    End Property

    Property f As Integer
        Get
            f = m_f
        End Get
        Set(value As Integer)
            m_f = value
        End Set
    End Property

    Property g As Integer
        Get
            g = m_g
        End Get
        Set(value As Integer)
            m_g = value
        End Set
    End Property

    Property x As Integer
        Get
            x = m_x
        End Get
        Set(value As Integer)
            m_x = value
        End Set
    End Property

    Property y As Integer
        Get
            y = m_y
        End Get
        Set(value As Integer)
            m_y = value
        End Set
    End Property

    Property cellid As Integer
        Get
            cellid = m_cellid
        End Get
        Set(value As Integer)
            m_cellid = value
        End Set
    End Property

    Property started As Boolean
        Get
            started = m_started
        End Get
        Set(value As Boolean)
            m_started = value
        End Set
    End Property

    Property closed As Boolean
        Get
            closed = m_closed
        End Get
        Set(value As Boolean)
            m_closed = value
        End Set
    End Property

    Property fermer As Boolean
        Get
            fermer = m_fermer
        End Get
        Set(value As Boolean)
            m_fermer = value
        End Set
    End Property

    Property walkable As Boolean
        Get
            walkable = m_walkable
        End Get
        Set(value As Boolean)
            m_walkable = value
        End Set
    End Property

    Property parent As Integer
        Get
            parent = m_parent
        End Get
        Set(value As Integer)
            m_parent = value
        End Set
    End Property

    Property inClosedList As Boolean
        Get
            inClosedList = n_inClosedList
        End Get
        Set(value As Boolean)
            n_inClosedList = value
        End Set
    End Property

    Property inOpenList As Boolean
        Get
            inOpenList = n_inOpenList
        End Get
        Set(value As Boolean)
            n_inOpenList = value
        End Set
    End Property

#End Region

End Class
pouriez vous me dire ce qui va pas ?
 
Inscrit
29 Septembre 2011
Messages
393
Reactions
3
#5
Re: Besoin d'aider pour mon pathfinding

Traduit mon code n'a vraiment aucun utilité car mon code c'été a mes début en c++ et surtout il y a de grave bug que j'ai peut voir sur ce pathfinding. j'ai partager le lien d'ou j'ai eux de l'aide sur la conception d'un pathfinding A*star donc essaye un minimum de lire et de comprendre, puis tu essaye de faire un code par toi même.
PS : tu verra ça sera plus simple que de traduire mon code!
 

asyade

Membre Actif
Inscrit
26 Avril 2013
Messages
368
Reactions
1
#6
Re: Besoin d'aider pour mon pathfinding

ok ^^ je vais revoire sa mai je tavoue que j'ais vraiment du mal avec cette mer**
 

asyade

Membre Actif
Inscrit
26 Avril 2013
Messages
368
Reactions
1
#7
Probléme résolut T_T ^^

voici mon patfinding :p

Code:
Imports API.Files.d2p.Map.MapInformations
Imports API.Files.d2p.Map

Public Class PathFinding
    Public CELLPOS() As node = Arrays.InitializeWithDefaultInstances(Of node)(560)
    Private MAP_WIDTH As Integer
    Private MAP_HEIGHT As Integer
    Private currentMap As Map
    Private openList As New List(Of node)()
    Private finish_search As Boolean

    Public Sub New()
        MAP_WIDTH = 14
        MAP_HEIGHT = 20
        finish_search = False
    End Sub
    Public Function findPath(ByVal startId As Integer, ByVal endId As Integer, ByVal diagonal As Boolean) As List(Of Integer)
        initializeCurrentMap()
        Dim loc_1 As Integer = 0
        Dim loc_2 As Integer = 0
        Dim loc_3 As Integer = 0
        Dim loc_4 As Integer = 0
        Dim loc_5 As Integer = 0
        Do While loc_5 < MAP_HEIGHT '  on actualize tout les noeud avec leur vrais valeur x,y
            loc_4 = 0
            Do While loc_4 < MAP_WIDTH
                CELLPOS(loc_3) = New node(loc_3, loc_1 + loc_4, loc_2 + loc_4)
                loc_3 += 1
                loc_4 += 1
            Loop
            loc_1 += 1
            loc_4 = 0
            Do While loc_4 < MAP_WIDTH
                CELLPOS(loc_3) = New node(loc_3, loc_1 + loc_4, loc_2 + loc_4)
                loc_3 += 1
                loc_4 += 1
            Loop
            loc_2 = loc_2 - 1
            loc_5 += 1
        Loop

        ' on initialize tous les information des cellules Id
        For i As Integer = 0 To 559
            Dim appli As Boolean = False
            Dim currentCell_ As CellData = currentMap.Cells(i)
            If i = startId Then
                appli = True
                CELLPOS(i).setClosed(False)
                CELLPOS(i).setStarted(True)
                CELLPOS(i).setWalkable(currentCell_.Mov)
            End If

            If i = endId Then
                appli = True
                CELLPOS(i).setClosed(True)
                CELLPOS(i).setStarted(False)
                CELLPOS(i).setWalkable(currentCell_.Mov)
            End If
            If appli = False Then
                CELLPOS(i).setClosed(False)
                CELLPOS(i).setStarted(False)
            End If
            CELLPOS(i).setWalkable(currentCell_.Mov)
            CELLPOS(i).calculH(CELLPOS(endId))
        Next i
        Dim currentNode As node = CELLPOS(startId)

        Do While finish_search = False ' on créé une boucle jusqu'a qu'il trouve son chemin jusqu'a sa destination
            findNeighboringCell(currentNode, diagonal) ' on cherche les cellules voisines par rapport à noeud actuel.

            currentNode = openList(0) ' on remplace la noeud actuel par la première de la openList don celle qui a le plus petit F a notre noeud actuel
            currentNode.setInClosedList(True)
            currentNode.setInOpenList(False)
            openList.RemoveAt(0)
        Loop

        Dim currentCell As node = CELLPOS(endId)
        Dim cells As New List(Of Integer)()
        Do While currentCell.getCellid() <> CELLPOS(startId).getCellid()
            cells.Insert(0, currentCell.getCellid())
            currentCell = CELLPOS(currentCell.getParent())
        Loop
        cells.Insert(0, startId)
        Dim chemin As New List(Of Integer)()
        For reverse As Integer = cells.Count - 1 To 0 Step -1
            chemin.Insert(0, cells(reverse))
        Next reverse

        Return chemin
    End Function

    Private Sub initializeCurrentMap()
        Dim reader As New MapManager("C:\Program Files (x86)\Dofus2\app\content\maps")
        currentMap = reader.GetMap(84674062)
    End Sub
    Private Sub findNeighboringCell(ByVal c_node As node, Optional ByVal diagonal As Boolean = False)
        addCell(getCellIdFromPoint(c_node.getX(), c_node.getY() + 1), c_node)
        addCell(getCellIdFromPoint(c_node.getX() - 1, c_node.getY()), c_node)
        addCell(getCellIdFromPoint(c_node.getX() + 1, c_node.getY()), c_node)
        addCell(getCellIdFromPoint(c_node.getX(), c_node.getY() - 1), c_node)
        If diagonal Then
            addCell(getCellIdFromPoint(c_node.getX() - 1, c_node.getY() + 1), c_node)
            addCell(getCellIdFromPoint(c_node.getX() + 1, c_node.getY() + 1), c_node)
            addCell(getCellIdFromPoint(c_node.getX() + 1, c_node.getY() - 1), c_node)
            addCell(getCellIdFromPoint(c_node.getX() - 1, c_node.getY() - 1), c_node)
        End If
        sortOpenList()
    End Sub
 

    Private Sub sortOpenList()
        Dim ok As Boolean = False
        Do While ok = False
            ok = True
            Dim temp As New node()

            For i As Integer = 0 To openList.Count - 2 ' on fait regarde tous les noeud qui son dans l'openList puis on regarde qui a le plus petit F
                If openList(i).getF() > openList(i + 1).getF() Then
                    temp = openList(i)
                    openList(i) = openList(i + 1)
                    openList(i + 1) = temp
                    ok = False
                End If
            Next i
        Loop
    End Sub
    Private Function getCellIdFromPoint(ByVal x As Integer, ByVal y As Integer) As Integer
        Return (x - y) * MAP_WIDTH + y + (x - y) \ 2
    End Function
    Private Sub addCell(ByVal cell As Integer, ByVal c_node As node)
        Try
            If CELLPOS(cell).getWalkable() = True Then
                If CELLPOS(cell).getClosed() = True Then
                    CELLPOS(cell).setParent(c_node.getCellid())
                    finish_search = True
                    Return
                End If

                If CELLPOS(cell).getInOpenList() = False AndAlso CELLPOS(cell).getInClosedList() = False Then
                    CELLPOS(cell).setParent(c_node.getCellid())
                    CELLPOS(cell).setInOpenList(True)
                    CELLPOS(cell).setG(c_node.getG() + 10)
                    CELLPOS(cell).setF(CELLPOS(cell).getG() + CELLPOS(cell).getH())
                    openList.Insert(0, CELLPOS(cell))
                End If
            End If

        Catch ex As Exception

        End Try
    End Sub
End Class

Friend Module Arrays
    Friend Function InitializeWithDefaultInstances(Of T As New)(ByVal length As Integer) As T()
        Dim array(length - 1) As T
        For i As Integer = 0 To length - 1
            array(i) = New T()
        Next i
        Return array
    End Function
End Module

la classe node

Code:
Imports System

Public Class node
    Public Sub New()
        started = False
        closed = False
        fermer = False
    End Sub
    Public Sub New(ByVal cellId As Integer, ByVal _x As Integer, ByVal _y As Integer)
        m_x = _x
        m_y = _y
        m_cellid = cellId
    End Sub
    Public Sub setStarted(ByVal b_start As Boolean)
        started = b_start
    End Sub

    Public Function getStarted() As Boolean
        Return started
    End Function

    Public Sub setClosed(ByVal b_close As Boolean)
        closed = b_close
    End Sub

    Public Function getClosed() As Boolean
        Return closed
    End Function

    Public Sub setWalkable(ByVal b_walkable As Boolean)
        walkable = b_walkable
    End Sub

    Public Function getWalkable() As Boolean
        Return walkable
    End Function

    Public Sub calculH(ByVal endNode As node)
        h = 10 * (Math.Abs(endNode.getX() - m_x) + Math.Abs(endNode.getY() - m_y))
    End Sub

    Public Function getH() As Integer
        Return h
    End Function

    Public Function getX() As Integer
        Return m_x
    End Function

    Public Function getY() As Integer
        Return m_y
    End Function

    Public Sub setFermer(ByVal b_ferme As Boolean)
        fermer = b_ferme
    End Sub

    Public Function getCellid() As Integer
        Return m_cellid
    End Function

    Public Sub setInOpenList(ByVal b_inOpenList As Boolean)
        n_inOpenList = b_inOpenList
    End Sub
    Public Function getInOpenList() As Boolean
        Return n_inOpenList
    End Function

    Public Sub setInClosedList(ByVal b_inClosedList As Boolean)
        n_inClosedList = b_inClosedList
    End Sub
    Public Function getInClosedList() As Boolean
        Return n_inClosedList
    End Function

    Public Sub setParent(ByVal p_id As Integer)
        parent = p_id
    End Sub
    Public Function getParent() As Integer
        Return parent
    End Function

    Public Sub setG(ByVal value As Integer)
        g = value
    End Sub
    Public Function getG() As Integer
        Return g
    End Function

    Public Sub setF(ByVal value As Integer)
        f = value
    End Sub
    Public Function getF() As Integer
        Return f
    End Function


    Private m_x As Integer
    Private m_y As Integer
    Private m_cellid As Integer
    Private started As Boolean
    Private closed As Boolean
    Private fermer As Boolean
    Private walkable As Boolean
    Private parent As Integer
    Private n_inClosedList As Boolean
    Private n_inOpenList As Boolean
    Private h As Integer
    Private f As Integer
    Private g As Integer

End Class

Merci a vous pour vos conseil qui mon etait trés utile et pour la source qui ma vraiment beaucoup aider (petetre trop ^^')
 
Haut Bas