Grown grid with start and end point (modify c# script)

Hi guys :slight_smile:
I’m here to ask you a question because I have a problem writing a script.
Heiwayuuri-2D.gh (19.6 KB)

Here is Mahdiyar’s c# script, But I want to change this with start & end point.
And this script, if the biggest value is already selected, then it stops But I wants to change this script to grow the next big value until that get to the end point.

II tried to change it, but I don’t know, so I ask a question. I’d really appreciate it if you could answer

Where’s any C# in that? Probably you attached the wrong thing.

Oh I attached the wron file…
This is the original file from by Mahdiyar.
Heiwayuuri-2D.gh (19.6 KB)

This (VERY slow) C# needs rethinking in quite a few areas (for istance the GetIndex Method, the startPt policy/checks

… etc etc). Better ask from the author to do the mods required.

I think that is because startPt’s x,y value have to integer?
I had the same problem, and I solved that with that method

A valid start pt idx is in fact an elementary thing to do. The fastest way:
Screen Shot 033

Anyway with regard the preparation of pts/indices get this (the method used for the rnd indices is the fastest way known to man):

PtGridAndSomeOtherStuff_V1.gh (13.6 KB)

But the core of the matter is the rather questionable logic. As I said ask from the author to do it properly.

BTW: you want - in fact - to implement an A-Star algo on that? (from/to pts … plus a rnd population “along” the shortest route(s)).

Aside from the arguable methods used there, if I understand correctly you want to create a “snake” going from one point to another one, each time jumping to the highest number available. But the problem is there are situations where it could get stuck (if you loop back) depending on the original distribution of numbers.

Like, I just did ONE test randomly and it gets stuck : starts on bottom left at 90 and attempts to go to 35 on top right. Road gets blocked at 25…

Heiwayuuri-2D.gh (23.7 KB)

If we follow the initial logic … that’s a classic backtracing thing .

1 Like

Sure, but there is no sign of that in the current code, implementing this from scratch is more work than what the original question was about.

Er … for that exactly the reason I said that the author … blah, blah.

Thank you so so much for your reply!!
I asked autor, but it was posted 4 years ago, so it’s hard to expect an answer.
My final goal is to start from first point and go second point, and in the process, follow the highest number possibly, not necessarily the highest number.
And if there are the same number around one grid, that put it together with block.

Thank you very much magicteddy!!
I opened the file you uploaded, and the same happens to me


Actually I’m going to use the one called from the excel file like the picture above rather than putting in random numbers.
So, is there a way to retrace the path that have taken when they are stuck, or jump and get as high as they can to reach final destination?

what is this? the biggest prox rnd index? (out of the 8 neighbors that are NOT visited) some other thing? (and if yes … why?)

Anyway … here’s the deal: describe EXPLICITLY (like talking to some idiot robot) what you want to do. Like:

  1. I have a grid (2d ? 3d? 4d? (4rth space dim is dollars)).
  2. I want to define one (or several) pts (random within the x/y Interval? according some other logic?)
  3. Then I want to find other points accodring the following logic .
  4. blah, blah.

and we’ll see what we can do on that matter

  1. I have a 2D grid
  2. that grid have vale (range 1~10)
  3. I want to make network between point A to B
  4. When make network, I want to choose higher number grid as much as possible.
  5. Like, If there are 1,5,7,10 around starting point A, choose 10
  6. When it’s blocked, it is okay that choose same grid to choose another highest value grid.
  7. But, I want to choose the highest value grid that I didn’t choose, if it’s not a blocked,
    So that I don’t follow the same network.

This is the plan of my project.
Thank you very, very much for your long help :sob: :sob:

1 Like

Did I said like talking to a stupid robot? No I forgot that part I guess.

Anyway:

What is “vale” for the grid ? Maybe a 1-10 number randomly assosiated with a grid pt? (like the weight of some Graph node?).

What means “network”? Maybe a collection of points? Or the connections of these points in the order of finding them? (Points are called Nodes in Graphs).

Is the grid seriously big? (in order to use things the likes of RTree on some custom object defined via a Class (Properties: grid pt , idx, rnd pt weight/ number)).

Your explanation on the “blocked” (i.e. visited) pt event is poor: You mean expand the search (i.e. go from the 8 prox neighbors to the next 16 … blah, blah) until a non visited pt is found?

Other than that a basic tip:

When searching - in this case - for prox neighbors populate 2 arrays: the Idx Array with the indices found AND the Num Array with the “numbers” assosiated with these indices (i.e. points). Then do a sync sort (Array.Sort(Num, Idx)) and get the LAST item in the idx Array (that points to the biggest value in Num).

  1. Yes!! value is the 1-10 number randomly assosiated with a gird pt
  2. Network is collection of points
  3. grid is quite large, 98 * 167 grid
  4. Yes, epand the search until a non visited pt is found is exactly right!!

So the 1st C# becomes:

Is this correct? (the FisherYates is NOT required).

What happens IF the weights (in the Sorted Num, Idx Arrays as above) are the same? What is the 2nd criterion for the prox pt? (a random choice?).

And what exactly is the purpose of all that? a bit pointless approach for doing things?

1 Like

It’s to occupy your mind, dear Lord :smiley:

Well … I’m just the manager. Others do that sort of stuff (plus I hate computers, Windows, A.I., Gin Tonic, any Toyota and any Harley Davidson).

But I assigned this to my top dog IT guru (of gurus).
Screen Shot 035

Genius said: since all the Graph conn things are internal … I’ll use a Mesh in order to get the VV Conn > Recursive “expansive” search (using multi “start points” ) > Until the End of Time > Elementary.

I said: I don’t understand an iota … can you elaborate more? Guru said: imagine this, then just add node weights (thus voids in the collections):

Update (I hate that dog):

Guru said: done (Recursive stuff, multi start points, expansion loop control etc etc) , where’s some extra bones?

Lord said: wait a minute: in an existed C# … you’ve just added a few lines and a Weights clause. And for one minute job you ask bonus bones ? Guru said: a pro cuts the mustard with minimum effort while demands maximum reward(s).

1 Like

On that matter that idiot dog did a poor solution.

Using multi start “points” (in fact Mesh Face random indices) results are a bit on the primitive side (but very fast no matter the N of Faces) . But the 1M question is: who’s gonna notice if the logic is correct or bananas? Meaning: another academic case lost in the big rabbit hole ???