Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


lucky6969b

Member Since 06 Apr 2007
Offline Last Active Private

Topics I've Started

How to display all explored nodes with A*?

22 July 2015 - 01:20 AM

My goal is to debug the A* program.

So whenever a node is opened, I want to display it visually.

 

Despite all the programming flaws (due to testing purposes only), how do I keep a SortedSet of ArrayList

of Opened Nodes?

 

In this case, I just keep all the nodes that are opened along the correct path.

How do I display all other opened/discarded nodes as well?

 

Thanks

Jack

 

public synchronized Path2 findPath(Node2 from, Node2 to, Unit unit) throws NoPathException {
        if (unit == null)
           throw new NullPointerException("context is null");        
        
        unit.clearOpenedNodes();
        try {
             
            Node2 current = null;
            
            openList.clear();
            if (useBitSet)
                bitSetClosedList.clear();
            else intSetClosedList.clear();
            
            int maxOpenSize = 0;  
            
            from.transition = null;
            from.h = from.getActualTimelessCost(to);
            if (from.h < 0)
                throw new NoPathException("initial cost: " + from.h);
            from.g = 0;
            from.f = from.h;             
            
            openList.add(from);
            
            // Add backup node to the unit object             
            PathPoint2 pp = new PathPoint2(from.x, from.z, 0);
            pp.f = from.getF();
            pp.g = from.getG();
            pp.h = from.getH();
            unit.AddOpenedNode(pp);                            
            
            while (! openList.isEmpty()) {
                current = openList.first();
                if (! openList.remove(current))
                    assert false;
           
                
                
                // find nodes in open list till it is exhausted
                if (useBitSet) {
                    bitSetClosedList.set(current.id);
                } else {
                    intSetClosedList.add(current.id);
                }
                
                if (current.x == to.x && current.z == to.z) {
                    float totalCost = current.g;
                    List<AStar2.Transition2> transitions = new ArrayList<AStar2.Transition2>();
                    while (current.transition != null) {
                        transitions.add(0, current.transition);                        
                        current = current.transition.fromNode();
                    }
                    
                    return new AStar2.Path2(from, transitions, totalCost);
                }
                
                for (Transition2 transition : current.getTransitions()) {
                    float cost = transition.getCost(unit);
                    if (cost < 0)
                        continue;
                    
                    // new a node out, id will not be the same, so a new node is produced
                    Node2 neighbour = transition.toNode();
                    
                    if (useBitSet) {
                        if (bitSetClosedList.get(neighbour.id))
                            continue;
                    } else {
                        if (intSetClosedList.contains(neighbour.id))
                            continue;
                    }
                    
                    if (openList.contains(neighbour))
                    {
                        // check if this path is better
                        if (current.g + cost < neighbour.g)
                        {                            
                            if (!openList.remove(neighbour))
                                assert false;
                            
                            neighbour.transition = transition;
                            neighbour.g = current.g + cost;
                            neighbour.f = neighbour.g + neighbour.h;
                             
                            pp = new PathPoint2(neighbour.x, neighbour.z, 0);
                            pp.f = neighbour.getF();
                            pp.g = neighbour.getG();
                            pp.h = neighbour.getH();
                            unit.AddOpenedNode(pp);                            
                            openList.add(neighbour);
                            
                         }
                        
                    } else { // if neighbour in openList
                        
                        neighbour.transition = transition;
                        neighbour.g = current.g + cost;
                        neighbour.h = neighbour.getActualTimelessCost(to);
                        neighbour.f = neighbour.g + neighbour.h;
                         
                        // Add backup node to the unit object                         
                        pp = new PathPoint2(neighbour.x, neighbour.z, 0);
                        pp.f = neighbour.getF();
                        pp.g = neighbour.getG();
                        pp.h = neighbour.getH();
                        unit.AddOpenedNode(pp);                                                     
                        openList.add(neighbour);
                    }  
                }
            }
              
        } finally {}
        
        throw new NoPathException();
         
}

Starting an DX7 Retained mode program in windows 7 x64 sp1

21 July 2015 - 11:02 PM

Sorry, I forgot I've asked this question before. I want to start a DX7 retained mode program written

in VB6 in Windows 7 x64 sp1 I've checked the back compatibility checkbox for the program.

I've downloaded the vb activex control for DX7 and the retained mode DLL called d3drm.dll

But the function call namely Direct3DRMCreate still unable to step over.

It just fails. BTW, VB6 SP6 does work on windows 7 x64 sp1

DX8 programs do work this way. But DX7 don't.

I wonder did Intel put the silicon into the HD 3000 chip for DX7?

Thanks

Jack


Could anyone recommend a free-tool for viewing game assets?

18 July 2015 - 05:21 AM

like .3ds, .obj, .max, .blend etc etc Better off to be installation-free.

Thanks

Jack


How to test the current path is congested?

15 July 2015 - 01:45 AM

If a path is congested, how would you test it?
One option is to test if a group of agents haven't moved to the destinations in
a specified time range.

What are the other ways?

Thanks

Jack


[Cooperative Pathfinding] Agents get stuck at choke point

14 July 2015 - 05:42 AM

I am right now trying silver's WHCA* algorithm, but with the following setup,
where the narrow corridor has a dead end, the agents just spin around at
the choke point and stuck. Agent 3 is unwilling to get out of the way and just sits there.
The other 4 agents just keep spinning around at the entrance of the choke point.
How do I work around this?
 


PARTNERS