Jump to content

[1.18.1] Cable


1HA

Recommended Posts

It's me again.

I'm currently studying Dijkstra Algorithm and BFS (Graph theory) to make this thing work.

And I've looked up a few codes like

https://github.com/refinedmods/refinedpipes/tree/develop/src/main/java/com/refinedmods/refinedpipes

this.

Q.

If I use BFS to measure the distance to find the shortest, is there any different thing with using Dijkstra or not?

I'm more used to C rather than Java, so I coded a few BFS(Also DFS) problems with C.

Let's say that I could make cable networks into a certain graph, then the edges of the graph will have no weight, which means that I can use BFS, isn't it?

Sorry that I have poor knowledge about theory yet because I'm a student.

Edited by 1HA
Link to comment
Share on other sites

On 3/2/2022 at 9:44 AM, MFMods said:

yes, you can use bfs.

what are you trying to do?

Glad to hear that I can use BFS.

I need some cable to connect the power.

 

I used a 3d array in the C test code to get the "map". And it worked pretty well.

However, in minecraft, the server can't receive the cable network data with a 3d array cause it's inefficient.

Therefore somehow, as others did, the server has to receive the data with a linked list? maybe? And I have no idea what to do.

 

 

thx for replying

Link to comment
Share on other sites

i think this "server receiving things" is confusing you. server knows the stuff you see in the world - blocks, sheep, zombies. the only time you send information to server is when you receive a mod-specific keypress or you open a gui window and interpret clicks into something the server would know about. even things like immersive engineering cables - player sets two endpoints, client will have to draw a "cable" all the time, but server should know about endpoints of each cable all the time - no need to send anything manually.

 

and before you tackle this, look into more dynamic algorithms. do not calculate unchanged distances multiple times - store them somehow, and when another cable piece is added (i assume you are using blocky cables), see if any of the distances might be improved thanks to the new block; and if i destroy a block, recheck distances. do not do any non-trivial calculations when worlds "tick" and when block entities "tick".

Link to comment
Share on other sites

Thx

I'd like to ask you one more thing. The current of the cable might constantly change(caused by generators and machines). In this case, the server has to fix the change every tick, right?🤔

And I used neighborChanged() to check distances 

Edited by 1HA
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.