Exemplo n.º 1
0
        public List <Node> nextNode()
        {
            List <Node> listNode = new List <Node>();

            foreach (EnumIA.Action action in actionsAvailable())
            {
                switch (action)
                {
                case EnumIA.Action.bas:
                    List <EnumIA.Action> tempBas = new List <EnumIA.Action>();
                    tempBas.AddRange(this.actions);
                    tempBas.Add(EnumIA.Action.bas);
                    listNode.Add(new Node(posAgent.move(EnumIA.Action.bas), Jewels, Dust,
                                          tempBas, calculHeuristic(action), this, null));
                    break;

                case EnumIA.Action.haut:
                    List <EnumIA.Action> tempHaut = new List <EnumIA.Action>();
                    tempHaut.AddRange(this.actions);
                    tempHaut.Add(EnumIA.Action.haut);
                    listNode.Add(new Node(posAgent.move(EnumIA.Action.haut), Jewels, Dust,
                                          tempHaut, calculHeuristic(action), this, null));
                    break;

                case EnumIA.Action.droite:
                    List <EnumIA.Action> tempDroite = new List <EnumIA.Action>();
                    tempDroite.AddRange(this.actions);
                    tempDroite.Add(EnumIA.Action.droite);
                    listNode.Add(new Node(posAgent.move(EnumIA.Action.droite), Jewels, Dust,
                                          tempDroite, calculHeuristic(action), this, null));

                    break;

                case EnumIA.Action.gauche:
                    List <EnumIA.Action> tempGauche = new List <EnumIA.Action>();
                    tempGauche.AddRange(this.actions);
                    tempGauche.Add(EnumIA.Action.gauche);
                    listNode.Add(new Node(posAgent.move(EnumIA.Action.gauche), Jewels, Dust,
                                          tempGauche, calculHeuristic(action), this, null));
                    break;

                case EnumIA.Action.aspirer:
                    Dust.Remove(posAgent);
                    List <EnumIA.Action> tempAspirer = new List <EnumIA.Action>();
                    tempAspirer.AddRange(this.actions);
                    tempAspirer.Add(EnumIA.Action.aspirer);
                    listNode.Add(new Node(posAgent, Jewels, posAgent.remove(Dust),
                                          tempAspirer, calculHeuristic(action), this, null));
                    break;

                case EnumIA.Action.recuperer:
                    Jewels.Remove(posAgent);
                    List <EnumIA.Action> tempRecuperer = new List <EnumIA.Action>();
                    tempRecuperer.AddRange(this.actions);
                    tempRecuperer.Add(EnumIA.Action.recuperer);
                    listNode.Add(new Node(posAgent, posAgent.remove(Jewels), Dust,
                                          tempRecuperer, calculHeuristic(action), this, null));
                    break;
                }
            }

            return(listNode);
        }