Click here to Skip to main content
15,898,374 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# to Excel Pin
Christian Graus19-Sep-06 20:45
protectorChristian Graus19-Sep-06 20:45 
Questionhi, help me , exe path problem in c#.net Pin
premkamalg19-Sep-06 19:03
premkamalg19-Sep-06 19:03 
AnswerRe: hi, help me , exe path problem in c#.net Pin
Andrei Ungureanu19-Sep-06 19:35
Andrei Ungureanu19-Sep-06 19:35 
GeneralThanks Karkster Pin
premkamalg19-Sep-06 20:32
premkamalg19-Sep-06 20:32 
GeneralThanks Karkster Pin
premkamalg19-Sep-06 20:32
premkamalg19-Sep-06 20:32 
GeneralThanks Karkster Pin
premkamalg19-Sep-06 20:32
premkamalg19-Sep-06 20:32 
GeneralRe: Thanks Karkster Pin
Nafiseh Salmani19-Sep-06 23:37
Nafiseh Salmani19-Sep-06 23:37 
QuestionSimple path finding problem. Pin
f*** YOU19-Sep-06 16:11
f*** YOU19-Sep-06 16:11 
Iv been trying to learn the A* pathfinding algorithm. I think I got it down but im having a problem with my implimitation. The problem is that the path is very sloppy. It will not make a diagonal move when it is supposed to and so on. The path looks like it was drawn by a 3 year old. I have beat my head against the wall on this and I am so sick of it, I just want it to work. I have done everything the way its supposed to be done, Iv even looked at some pathfinding articals here. Im using a heavily modified version of an algorithm I downlaoded from this site. Here is the code for the core of the algorithm for which I belive the problem exists.

using System;
using System.Collections.Generic;


  namespace PathFinding
  {
    public class SimplePathFinder
    {
      Map nodeMap;

      Node startNode;
      Node endNode;

      Queue<Node> finalPath = new Queue<Node>();

      bool isPathFound;

      public bool this[int x, int y]
      {
        get { return nodeMap[(ushort)x, (ushort)y]; }
        set
        {
          nodeMap[(ushort)x, (ushort)y] = value;
          isPathFound = false;
        }
      }

      public Coordinate StartNodePositon
      {
        get { return new Coordinate(startNode.X, startNode.Y); }
        set
        {
          startNode.X = (ushort)value.X;
          startNode.Y = (ushort)value.Y;
          isPathFound = false;
        }
      }
      
      public Coordinate EndNodePositon
      {
        get { return new Coordinate(endNode.X, endNode.Y); }
        set
        {
          endNode.X = (ushort)value.X;
          endNode.Y = (ushort)value.Y;
          isPathFound = false;
        }
      }

      public Coordinate[] Path
      {
        get
        {
          if (!isPathFound)
            FindPath();
          
          if (finalPath.Count == 0)
            throw new ApplicationException("Path not found, the start node or the end node is enclosed or do not exist.");

          Stack<Coordinate> coordinateStack = new Stack<Coordinate>();
          foreach (Node pathNode in finalPath)
          {
            coordinateStack.Push(new Coordinate(pathNode.X, pathNode.Y));
          }

          return coordinateStack.ToArray();
        }
      }

      public SimplePathFinder(int width, int height, Coordinate startNodePos, 
                              Coordinate endNodePos, Coordinate[] unwalkableNodes)
      {
        nodeMap = new Map((ushort)width, (ushort)height, unwalkableNodes);
        endNode = new Node(null, null, nodeMap, endNodePos.X, endNodePos.Y);
        startNode = new Node(null, endNode, nodeMap, startNodePos.X, startNodePos.Y);
      }

      void FindPath()
      {
        SortedNodeList Open = new SortedNodeList();
        SortedNodeList Closed = new SortedNodeList();

        if (startNode == null || endNode == null || nodeMap == null)
          throw new ApplicationException("StartNodePosition, EndNodePosition, or the Map is not instantiated.");

        Open.Push(startNode);

        while (Open.Count > 0)
        {
          Node currentNode = Open.Pop();

          if (currentNode.Equals(endNode))
          {
            endNode.ParentNode = currentNode.ParentNode;
            break;
          }

          Node[] successors = currentNode.GetSuccessors();

          foreach (Node successorNode in successors)
          {
            int oFound = Open.IndexOf(successorNode);
            if(oFound > 0)
            {
              if (Open.NodeAt(oFound).CompareTo(currentNode) <= 0)
                continue;
            }

            int cFound = Closed.IndexOf(successorNode);
            if (cFound > 0)
            {
              if (Closed.NodeAt(cFound).CompareTo(currentNode) <= 0)
                continue;
            }

            if (oFound >= 0)
              Open.RemoveAt(oFound);
            if (cFound >= 0)
              Closed.RemoveAt(cFound);

            Open.Push(successorNode);
          }

          Closed.Push(currentNode);
        }

        Node p = endNode;
        while (p != null)
        {
          finalPath.Enqueue(p);
          p = p.ParentNode;
        }
        if (finalPath.Count == 1)
          finalPath.Clear();

        isPathFound = true;
      }
    }
  }


If you need the whole project let me know, I would greatly appreciate any help.

static int Sqrt(int x) { if (x<0) throw new ArgumentOutOfRangeException(); int temp, y=0, b=0x8000, bshft=15, v=x; do { if (v>=(temp=(y<<1)+b<<bshft--)) {="" y+="b;" v-="temp;" }="" while="" ((b="">>=1)>0); return y; OMG | :OMG:

QuestionXPath expression problem... Pin
Kasic Slobodan19-Sep-06 15:35
Kasic Slobodan19-Sep-06 15:35 
AnswerRe: XPath expression problem... Pin
Stefan Troschuetz19-Sep-06 22:05
Stefan Troschuetz19-Sep-06 22:05 
GeneralRe: XPath expression problem... Pin
Kasic Slobodan20-Sep-06 0:31
Kasic Slobodan20-Sep-06 0:31 
QuestionDeveloping a voice chat application Pin
amor5019-Sep-06 15:02
amor5019-Sep-06 15:02 
AnswerRe: Developing a voice chat application Pin
Andrei Ungureanu19-Sep-06 19:40
Andrei Ungureanu19-Sep-06 19:40 
GeneralRe: Developing a voice chat application Pin
amor5020-Sep-06 14:30
amor5020-Sep-06 14:30 
Questionproblem using VC++ DLL in VC# Pin
saania khan19-Sep-06 13:42
saania khan19-Sep-06 13:42 
AnswerRe: problem using VC++ DLL in VC# Pin
Christian Graus19-Sep-06 13:54
protectorChristian Graus19-Sep-06 13:54 
QuestionRe: problem using VC++ DLL in VC# Pin
saania khan21-Sep-06 19:44
saania khan21-Sep-06 19:44 
AnswerRe: problem using VC++ DLL in VC# Pin
Christian Graus21-Sep-06 19:51
protectorChristian Graus21-Sep-06 19:51 
GeneralRe: problem using VC++ DLL in VC# Pin
saania khan22-Sep-06 11:43
saania khan22-Sep-06 11:43 
QuestionWork with voice applications Pin
Charlesmaster19-Sep-06 11:57
Charlesmaster19-Sep-06 11:57 
QuestionHave anyone done this problem before Pin
tmn11419-Sep-06 11:42
tmn11419-Sep-06 11:42 
AnswerRe: Have anyone done this problem before Pin
Christian Graus19-Sep-06 11:45
protectorChristian Graus19-Sep-06 11:45 
GeneralRe: Have anyone done this problem before Pin
tmn11420-Sep-06 11:05
tmn11420-Sep-06 11:05 
Questiongetting an HTMLInputElement using mshtml.dll Pin
Green Fuze19-Sep-06 11:16
Green Fuze19-Sep-06 11:16 
AnswerRe: getting an HTMLInputElement using mshtml.dll Pin
Nick Parker19-Sep-06 11:46
protectorNick Parker19-Sep-06 11:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.