Pathfinding in Life and Games

Question:

How do you find your way in this world?

If you interpret the question as merely geographic, the answer is trivial at this point in history. With superpowered GPS navigation systems in our phones and built into our vehicles, navigation travel is a solved problem. But what about the other issues of life that feel more challenging and less clear how to maneuver through?

As a follower of Jesus, you might say that you follow his example and ask the Father for wisdom, guidance, and his will for your life, which is a great answer! The Bible tells us that God has stored wisdom and is waiting for us to ask for it. Amazingly, sometimes God gives us detailed directions, akin to a GPS.

We see this in Paul's life in the sixteenth chapter of Acts, verses nine through ten: "And a vision appeared to Paul in the night: a man of Macedonia was standing there, urging him and saying, 'Come over to Macedonia and help us.' And when Paul had seen the vision, immediately we sought to go on into Macedonia, concluding that God had called us to preach the gospel to them." Those are pretty clear directions: Come to Macedonia and help us.

Pathfinding in Games

If Paul were a character in a video game, the developers might use a pathfinding algorithm to move him to the correct place on the map. Pathfinding algorithms plot the most optimal route between two points. Optimal could mean the shortest route, but it could also mean the cheapest, fastest, or based on many other criteria, like obstacles, elevation, and the character's movement abilities.

Under the hood, pathfinding algorithms accomplish their task by dividing the traversable area into a grid system or a network of connected nodes. With the map data in a suitable data structure, they iterate over the points while calculating the possible paths and returning the optimal route. Depending on the use case, programmers have various algorithms, such as Dijkstra's Algorithm, The Greedy Best-First-Search, or A*. However, A* (pronounced "A-star") is generally the most popular because of its flexibility in various contexts.

A* algorithm displaying the optimal path from the starting point to the destination point

I thought about sharing some code here, but I didn't know how many of my readers were programmers and would find it interesting. I was also concerned that the length of the code may dominate the article. However, if you are interested in learning more about the inner workings of pathfinding, I found this interactive pathfinding tutorial created by Eike Decker that walks you through various pathfinding algorithms. It's easy to follow and does a great job explaining the logic step by step. To play the tutorial, click on the picture below.

 

Steering Behaviors in Life

Algorithms like A* are great when you have a clearly defined goal and a map, but life isn't always that clear. Often, situations in life feel more nuanced and less structured. In my experience, praying for God's will and direction in life rarely results in a simple turn-by-turn GPS answer.

"For most of us, walking with God is a mysterious journey of faith and discovery," writes Erwin Raphael McManus. "Even when you have an intimate relationship with God, you might find yourself heading full steam ahead in the wrong direction. Or it may be that your life is suddenly making a sharp left turn."

The problem is that we often come to God desiring quick, turn-by-turn instructions for all of life's concerns. And we get frustrated or assume something is wrong when we don't receive them. Yet, this is a regular part of the Christian walk—even for heroes of the faith like Paul. If we back up a few verses from the passage we looked at earlier, we will see Paul experiencing what Erwin described.

Acts 16:6-8 says, "And they went through the region of Phrygia and Galatia, having been forbidden by the Holy Spirit to speak the word in Asia. And when they had come up to Mysia, they attempted to go into Bithynia, but the Spirit of Jesus did not allow them. So, passing by Mysia, they went down to Troas."

Paul and Timothy thought they knew their assignment, but the Holy Spirit had other plans, which He updated them on as they traveled. In my experience, much of the Christian walk involves God guiding us little by little, day by day, moment by moment, as we take steps in obedience. This is especially true when we embrace a fuller view of God's will. Passages like 1 Thessalonians 5:12–22 and 1 Peter 2:15–17 reveal that the will of God involves adopting particular behaviors and becoming a certain type of person, which is not a place you arrive.


1 Peter 2:15–17 says, "For this is the will of God, that by doing good you should put to silence the ignorance of foolish people. Live as people who are free, not using your freedom as a cover-up for evil, but living as servants of God. Honor everyone. Love the brotherhood. Fear God. Honor the emperor."

Steering Behaviors in Games

In game development, this guiding pattern via continued adjustments and nudges is called steering behaviors. Steering behaviors are another set of algorithms used to control the movement of agents, like characters or vehicles, in games and simulations.

Some common examples of steering behaviors include:

  1. Seeking a target

  2. Evading obstacles

  3. Pursuing another agent

  4. Arriving at a destination

  5. Maintaining formation with other agents

 

Wall avoid behavior

Hide behavior

 

It may appear that these two sets of algorithms compete or that your game needs to pick one or the other. However, one helpful distinction is that while pathfinding algorithms focus on finding and plotting the optimal path, steering behaviors focus on an agent's immediate local decisions to achieve its goal. Just as God employed multiple strategies to direct Paul, these patterns can be used independently or in conjunction to achieve a goal.

If you would like to dig deeper into steering behaviors, here are some resources:


I don't know where you are in your life or what you're trying to navigate, but I know that God wants to guide you through it, and I pray that God will grant you wisdom and success as you find your way through life. God bless.

Brock Henderson

Brock believes the world is a better place when we play together. As co-founder and CTO of PxlPug, he is excited to share that message with the world. PxlPug’s purpose is to create a healthy community where individuals are valued for who they are and are encouraged to grow into who they were created to be. The studio does this by crafting games that bring people together.

A designer, developer, and entrepreneur, he has a passion for creating video games and a proven track record with over 25 shipped titles and 3+ million downloads. Before entering the games industry, he co-founded the design firm Paper Tower where he served as creative director for over a decade. During that time, he designed interactive experiences for clients like Coca-Cola, Motorola, and Harvard.

Brock currently resides in a small town in Iowa with his beautiful wife Vanessa and their six children.

https://brockhenderson.com
Next
Next

Enjoying Order