A guide to Pathfinding in CoBlocks

Hello everybody!

I have made a guide/ little game about pathfinding in Cospaces (or pathfinding in general really). You can find an (hopefully approachable) explanation/ tutorial when clicking the explanation button; And you can move the target & enemy by clicking them to “pick them up” and clicking once again to put them down. The visuals can be a bit laggy at times due to the text blocks having to be copy pasted; But they are very helpfull to understand whats going on I think. Also currently the code has only a few comments inbetween, but I’ll add more in the future.
Hope people can make use of this, if you have any questions I’d be happy to answer! Ah and do let me know if you feel like the explanation is still vague or complex at times, since spreading the knowledge and intrest is more so the point then spreading the code.


Updated it, added another maze & made the padding work better; It now adds extra grids on an axis if the enemy & target are close together. Grid adjusts size & padding if it cant find the target up to 2 times. Also made some adjustments on the explanation where I deemed neccesary; Please feel free to leave some feedback, any is highly appreciated.

Comments, comments and more comments. I have updated… again. Added all of the steps of the explanation as comments into the code at their appropriate spots, as well as a bunch of extra information and clarification.

For now I think I’ll leave it as is, ofcourse I’d love to hear if you feel something is missing or could be better. I do truely hope I managed to teach some people something, or simply peaked your intrest in algorithms/ game design. Thank you once again for all the interest and the astounding amount of views it has already gotten!



Made a quick mockup up a heap sorting system, this system sorts a linear list into a tree like structure whereby each parent must by smaller or equal to it’s children and where we can “extract” the first piece of data and restructure the tree accordingly. This should (in theory) increase the speed of my pathfinding algorithm by alot as opposed to the original sorting method, especially as the path grows longer.

Okay I’ve gotten around to implementing the sorting system, good news is the calculations happen near instantanious; Measured about 1 to 2 miliseconds (though im not sure how accurate the reading is using coblocks). Bad news, cospaces does not like when so much data is handled at the same time. Running it constantly is therefore not an option; I have it set on a timer of 2 seconds in this cospace but even so it causes a lag spike the moment in triggers. So I think this is as far as I can push pathfinding in cospaces. Was a fun little experiment though, never had I worked with algorithms before so i managed to learn alot and it’s still a blast to see the algorithm working in such rapid speeds.

1 Like

Hi, me and my friends were planning on to play some games on cospace when we have a sleepover and this is the game we chose. It looks fun.

1 Like

That sounds really nice @Vaiga_Rajesh thank you for checking out my game and have fun!