Finally got it working!

in #code7 years ago

After nearly a week of bashing my head against code that just wouldn’t do what I wanted, I finally got the breakthrough today.


image source

Finally!

It turns out writing a route-finding algorithm is not so easy. Give it a starting point and an end point and a list of junctions to turn at until you get to the destination. Easy right?

That’s what I thought. And my first lot of code almost worked perfectly. Nearly, almost. It kept hanging on one particular node and then going in circles. If I didn’t visit that node it worked fine.

It turns out the problem was in my mapping of the routes. It was following the highway numbering as a route. But what I needed was to segment the highways between the junctions. Now I have a web / network of highways that I can set a start point and end point on and navigate to the end point successfully, no matter where the start and end points are.

That forms the heart of my new game engine for Steemit. Now that I have that sorted, I can build the rest of it.

Super excited about that. It’s going to be a fun game. And now I can sleep a bit better at night without trying to crack this problem.

Whew!


Check out my stories here on Steemit

Running Deer

Running Deer - part 1
Running Deer - How legends are born

Charlie Rabbit

Meet Charlie Rabbit
Charlie tides up
Charlie Rabbit and Margery Mouse
Charlie Rabbit and Margery Mouse make music

Little Peppers Adventures

Runaway Rabbit and the hungry fox
Maybe and the land of purple rainbows – A Little Peppers adventure
How Pappa Pepper and Monster Truck the Pepper got their wild hogs - a Little Peppers Adeventure

Dark Angel Regiment of the Space Marines - Mission Files

First Squad Sniper Elite - Zaresith mission

Other stories

Stranded
The Lady Of The Lake


Also don't forget to check out my Dad's blog

Who else can tell you stories about impersonating an officer, stealing a military aircraft to go on a booze run, or steal military aircraft and go on an unsanctioned bombing run - and that's all before he turned 18!

Check out @len.george and find out what other madness he got up to!


Are you new to Steemit and trying to figure out what it's all about?

Head over to: https://www.steemithelp.net/. It's the best place to get a handle on what the platform is all about.


Sort:  

Clever Trevor strikes again lol :)

Does this find the shortest way between places or just a way?

It finds a designated route. So you start from here you are going to there, along the way when you get to this junction you will take this direction, and so on until you get to where you are going.

Each route has nodes that are junctions and nodes that are not junctions, so if it is not a junction, it carries on the same route until it gets to a junction, and calculates the distance traveled as it goes.

That's all it does so far. Now that I have this bit working correctly, I can add the rest of the functionality in around it. :-)

Glad you had that breakthrough! Hope to see great things :)

Thanks. It will still take a while to get the rest of it built, but this was the one thing I had to get working first I order to get the rest of it to work.

Now nothing can stop me! hehee (except my wife telling me dinner is ready)

Well done, what game is this for?

This is the game engine for your game :-)

I had better start thinking then

Take your time. I still have plenty of work to do.

Very cool idea to create a game base of running. Are you planning to release it to the public at any point?

I wasn't planning on it. I hadn't thought about it really. It's just a bit of code to help with figuring out how far people run. The concept is pretty much open for anyone to use though

Coin Marketplace

STEEM 0.28
TRX 0.24
JST 0.040
BTC 94794.05
ETH 3301.38
USDT 1.00
SBD 7.75