Fast Distance Comparison Algorithm

Hey, this is a quick post about quickly comparing the distance of two points (2D or 3D). In this article, I’ll be using Roblox Lua for demonstration, but this method ought to work in many different languages. The goal is to find a fast way to answer the questions:

  • Is a point within a certain distance of another point?
  • Which of these two points are closest to this point?

Continue reading “Fast Distance Comparison Algorithm”

Spell Slingers Character/Ability Previews

Hey everyone! I took some time today to record some previews for a few characters/abilities in Spell Slingers. These are all works-in-progress with placeholder character names, models and kits. Everything’s subject to change, but in the meantime I want your feedback! So, what do you think?

I’m open to feedback on Twitter or via the game’s Discord server; this invite link still has more than 50 uses left from last week’s announcement – check the Spell Slingers splash page and Twitter in case this invite expires!

Announcing: Spell Slingers

Aww yes! It’s time. I’m officially announcing my next title on Roblox…. Spell Slingers! Click here to visit the splash page for the game.

Spell Slingers is the name of the MOBA game I have been working on since December 2017. I briefly mentioned it in my graph theory series and on my personal Twitter feed. I’ve poured my heart and soul into developing the game and its engine, so I’m hoping this will be my best game yet. Open beta has not started yet, but I will make announcements (here, Twitter, Discord, Roblox…everywhere) when it does.

Please follow the official Twitter @Spell_Slingers! If a group on Roblox is more your speed, you can join it here. Finally, I’ve set up a Discord server for the game, but be warned: that invite link only has 100 uses on it! If you’re from the future, check the Twitter for an up-to-date link).

I’m excited to share more information with you soon. Thank-you for your unending support, and I’ll see you soon in-game.

Mirror Muse is now Free-to-Play!

Hello everyone! This is a quick blog post to announce that my 2015 game Mirror Muse is now free on Roblox.com! Click the game icon below to play it now:
Game Icon of Mirror MuseI made this game in Fall 2015 during my internship at Roblox Corp under the Accelerator Program. My goal was to create a compelling mobile puzzle game. While I feel that I mostly succeeded, single-player games don’t exactly thrive on Roblox, especially not ones designed for mobile play.

So, to help drive players to at least try out the game and blow the dust off, the game is now free-to-play. You can still unlock more puzzles with the variety of modules available for only 10 Robux each. The level editor is also still available for only 40 Robux.

If you’ve never tried the game out, now’s your chance! Thanks for your support.

Object-Oriented Programming in Lua (Part 5 – Inheritance)

Inheritance is ubiquitous in the world of object-oriented programming. It makes your classes easy-to-maintain and allows you to reuse a lot of your software. In Part 4, we cleaned up some class code and packaged it all into one nice complete class. In this part, we’ll talk about how we can form a relationship between two classes in which a subclass inherits the state and behaviors of a superclass.

Continue reading “Object-Oriented Programming in Lua (Part 5 – Inheritance)”

Graph Theory in Roblox (Part 3 – A Solution)

In the previous article, I described a problem I faced when developing a game with little dudes roaming around a pre-built map. In this article, I’ll outline how I applied graph theory (described in the first article) to solve my problem.

Graphs are about relationships between objects. On my map, there are places that I know a minion can be, and I know which of those places can be accessed from nearby places. I placed parts in Roblox Studio on my map to quickly identify such locations:

Locations on the map that are navigable. Pink nodes represent a path; yellow represents a junction.

Inside each of these Parts, I added ObjectValues whose Values point to adjacent locations in which a minion should be able to travel between. This is essentially building an adjacency list, where each node contains a list of adjacent nodes. This is one of the two main ways to represent a graph in memory; the other method is to store an adjacency matrix of size n-by-n, where n is the number of nodes in a graph. However, I am working with a sparse graph, which means the 100+ nodes only connect to a select few (2-6) other nodes near to them.

Now I have a representation of my map’s network of navigable areas. At runtime, I have the game convert my Parts and ObjectValues into nodes and edges in a graph. The weights of the edges are the euclidean distance between the nodes. If you’d like to view my implementation of graph, node and edge objects, you can download an rbxmx file here. If you’d like to view the source code of each script individually, here are some pastebin links:

The algorithm I selected for shortest path calculation  is the Floyd-Warshall algorithm. For my fellow CS nerds, it runs in order n-cubed time (for every n nodes, we perform n×n×n steps). This algorithm finds all possible paths between all nodes and leaves each node a list of nodes one should travel to if they are to reach a specific destination node. In other words, imagine an n-by-n table, on the left is your current node, on the top is your destination node. It fills out the table with an adjacent node one ought to which one should travel.

Using the results of the Floyd-Warshall algorithm to find the shortest path between two nodes on a graph.

Above is an animation of randomly chosen paths being rendered in sequence. Here is my implementation (also included in the rbxmx file above) as a mix-in for the Graph class:

The result is pretty awesome! Now, all I do is spawn minions at a random node and randomly choose another random node to path towards. And finally here’s a preview of the two minions using the generated paths.

Two minions traversing different paths.

Got questions or comments? Drop me a direct message on Twitter or a message on Roblox.com! I’d love to update this article series with more information.

Graph Theory in Roblox (Part 2 – A Problem)

In the previous article, I went over basic graph theory terms and concepts. Click here to read that article. In this one, I’m going to describe a game design problem I found while working on my project.

First, some background information on my project. Without going into too much detail, it involves two teams roaming a map killing neutral monsters as an objective. One of these neutral monsters I’m calling creeps or minions, similar to those in Defense of the Ancients 2 and League of Legends. In those games, minions align with a team and march  down set paths and assault enemy structures on those paths. However, in my game, minions aren’t on a team, don’t attack structures, and have no set path. Here’s an early draft of the map I’m using:

An early draft of the map (not final). Notice the navigable paths through the map. Click to view the full image.

Minions roam this map freely, and one challenge I’m facing is programming the minion roaming behavior.  I came up with a number of ideas immediately. Here’s some of them:

  • Just walk in some random navigable direction, changing direction if they run into a wall
  • Create a bunch of paths and pick one to follow
  • Pick a random target on the map and use Roblox’s pathfinding to do the hard work for me in finding a path to the point

Well, there’s going to be a lot of minions around this map. Maybe they’ll even travel in packs, who knows! I can’t have the minions raycasting for walls, and I can’t use expensive pathfinding for them to navigate. I also don’t want them switching directions a lot; I’d rather they travel a long path instead of small segments.

How did I apply graph theory to this problem? Find out in the next article.