Need help with these things

The Undaddy

Creating with the power of rage
Reaction score
55
First things first:

thesethings.jpg


What I know:
-This is a network of points, some connected, kind of like a road system
-There are algorithms about them (find shortest path to,etc.)
-I need to use this

What I don't know:
-What it's called
-Aforementioned algorithms
-How to use this

Well, any assistance is welcomed, be it links to other sites or resources, or lengthy, difficult to understand explanations (I reckon there will be many).
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
I have no idea what these algorithms are.
But you could store these 'dots' in arrays.

(If they're units, great! if not, it's okay)
I'll assume you use co-ordinates.
This method will limit you to 8190 dots and will get slower as you add more dots.

I think you'll only notice the difference once you hit a large number.
The following was free-handed and might have some logical flaws.
I can't check because my WE has some error with it xD

JASS:
globals
    private constant integer Array_Size = 1000 //Put it to some number you know you'll never reach in a game.
endglobals
//Well, store your stuff in an array.
struct Stuff

    real array X[Array_Size]
    real array Y[Array_Size]

    integer array NearestDot[Array_Size]
    integer Stored = 0

    method StoringStuff takes real x, real y returns nothing
        //Let's say you wanna' store a co-ordinate to your array.
        set X[Stored] = x
        set Y[Stored] = y

        set Stored = Stored + 1

    endmethod

    method RemovingCoordinate takes integer index returns nothing
        local integer i = index

        loop
        exitwhen i == Stored
            set X<i> = X[i+1]
            set Y<i> = Y[i+1]
        set i = i + 1
        endloop

        set X<i> = 0.0
        set Y<i> = 0.0
        set Stored = Stored - 1
    endmethod

    method FindingShortestPath takes nothing returns nothing
        //The following will work even if your &#039;dots&#039; are always moving, as long as you update your co-ordinates.
        //Inefficient for periodic path-finding, trust me.
        //If you want efficient, then your &#039;dots&#039; must never move.
        local integer FirstLoop = 0
        local integer SecondLoop = 0
        local real Check = 99999999.0 //Setting this to some crazy high number    
        local integer Selected = 0 //In case there is only one dot in your array
        local real Dist
        local real dx
        local real dy

        loop
        exitwhen FirstLoop == Stored

            loop
            exitwhen SecondLoop == Stored

                if FirstLoop != SecondLoop then //Well, we don&#039;t want the dot to compare with itself, do we?
                    set dx = X[FirstLoop] - X[SecondLoop]
                    set dy = Y[FirstLoop] - Y[SecondLoop]
                    set Dist = SquareRoot( dx * dx + dy * dy)

                    if Dist &lt; Check then
                        set Check = Dist
                        set Selected = SecondLoop
                    endif
                endif 

            set SecondLoop = SecondLoop + 1
            endloop
 
            set NearestDot[FirstLoop] = Selected
 
        set FirstLoop = FirstLoop + 1
        endloop
 
    endmethod
endstruct

</i></i></i></i>
 

the Immortal

I know, I know...
Reaction score
51
http://en.wikipedia.org/wiki/Dijkstra's_algorithm

The simplest, most suitable and fast algorithm you should use. It's written in the wiki, but basically you keep a list of all 'open' (for evaluation) nodes, what node you reached them from, and the cost to reach them. First the list contains only source and all distances are infinity (except source = 0).

Then you loop, doing:
Remove the node from the list with smallest dist.
Add all nodes reachable from it, and set that point as their 'from' point. (the point you reached them from). Set their dist to "from" point + distance between those two.
If a point is already in the list, update the info for it, but ONLY if new dist < previous dist.
Loop until current node with smallest dist is the destination node.

Not sure if I explained it well. There's a pseudocode that probably does it better (optimizations ftl..) in the wiki page.

Hope it helps.


EDIT: If they are scattered on a plane (i.e. you know their co-ordinates), check out the A Star algorithm. It does essentially the same, but uses a heuristic to further optimize the search.
 

The Undaddy

Creating with the power of rage
Reaction score
55
Well you got the basic idea, but I should have elaborated a bit more.

Yes they are coordinates and never move.Also only some of them are connected (ooh, emphasis), this means that we can't go from point 1 directly to point 6, we must pass trough point 2 (refer to picture in post #1).

Edit: Now checking the links you posted, immortal
You must spread some reputation before giving it to SineCosine again. :[

Edit2: Ok, I think i got it, the A-star thing is quite a nuisance,though.
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
I'm going out now, but if your question has not been answered by the time I get home (read: 4-5hours time) then I'll help you as best I can.

Okay, so here's what I know:
01) These points never, ever, ever move for the duration of the game.
02) Some are connected.
03) You want to know the shortest path from A to C but must pass through any number of Point Bs.

Here's what I want to know.
These.. Connections.. Must they be followed strictly?
Like, you must pass through these point Bs and never deviate from them.

So..
We have to include the possibility that some of these 'dots' will have 3 or more 'paths' to other dots.

Hmm..
I'll be going out now.
 

The Undaddy

Creating with the power of rage
Reaction score
55
Well, my question has been answered, as far as theimmortal giving me enough information for me to expand on goes, but I'll address your questions.

No,the points do not move.

These 'connections' mean you can go from point A directly to point B if they are connected.No connection means that you cant go from point A to point C.And if B and C are connected, we can go from B to C. (and vice versa, but let's keep it simple for this example)

So if we would like to go from A to C, we have to pass trough B, since no direct connection is available.

Therefore, yes, multiple paths are possible, otherwise this wouldn't be so hard :p

And since there are multiple paths, one should stand out.And which better to stand out than the shortest one.Hence trying to find it.
 
General chit-chat
Help Users
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top