Dev Blog

GDC Talks – GDC 2018 – Math for Programmers by Squirrel Eiserloh

September 26th, 2018

Math for Programmers: 6 Courses on Procedural Content Generation for Games – GDC 2018

by: Squirrel Eiserloh

There are 6 talks about techniques and implementations of procedural content generation in games. The order is as follows:

  1. The Power of Procedural Recipes – Procedural Recipes
  2. Semi-Procedural Content Pipelines – Semi-Procedural Methods
  3. Staged Parametric Map Generation – Staged Parametric Generation
  4. Digging with Perlin Worms – Perlin Worms (for rivers/roads/caves)
  5. Discrete Constructs in Endless Worlds – Infinite Worlds
  6. Juicing World Generation with Metadata Feedback – Juicing PCG with Metadata

Experimenting with Unity: Player Movement – Rotation

August 1st, 2018

Experimenting with Unity: Player Movement

Player controlled by rotation about a point

Vimeo – Video of Rotational Movement

I was experimenting with controlling a player agent solely through rotational forces. The first style I looked at was not a force in the physical sense as it just operates on moving the player at a constant rotation speed. This is dictated by the placement of a rotation pivot which the player can place to indirectly move the player agent.

To add an extra amount of control, the player can also press a key in order to reverse the direction of the rotation (switch between clockwise and counterclockwise). This combination of features led to some interesting movement patterns. One of the first things that jumps out is the fact that the movement being dictated by a constant rotation speed still leads to varying velocities by the player agent as this will vary drastically with the radius between the pivot point and the player object. Large pivot distances can lead to dramatic speeds, but will lead to the player covering a larger area.

Notes to remember:

I was having an issue where the rotation was not perfectly making a circle in the game view. It turns out the scripts were correct, but the camera needed to be set to orthographic so the camera was just viewing it at an angle. Remember to check both the editor view and game view closely to help determine camera-based issues.

Using cursor inputs in Unity is a bit awkward. It has been done plenty of times so the basic scripting is available on Unity’s main site, but the process of creating a plane, raycasting, and converting between screen and world space is a lot to keep track of. This might also be something to look into if mouse inputs are acting strange.

Procedural Generation – Far Cry 5 GDC Content Generation

July 30th, 2018

Procedural Generation – GDC 2018 Talk – Procedural World Generation of ‘Far Cry 5’

By: Etienne Carrier

GDC 2018 – Procedural World Generation of ‘Far Cry 5’ – GDC Vault Link

GDC talk where Etienne details a large scale tool they created using procedural generation techniques to help build the world of Far Cry 5. It covers both the user end (world editors/designers) and the behind the scenes processes that make everything possible. They use Dunia and Houdini together to create these tools.

Instantiating Objects Randomly Within a Given Polygon

June 11th, 2018

Randomly Selecting Points within a Given Polygon

References Used:

Stack Overflow – Random Points in a Quadrilateral
Wolfram Alpha Information on Points in a Triangle

Notes

I needed to be able to randomly but evenly distribute a number of objects within a 2D area so these are the sources I started with. The Stack Overflow question ended up being a very good starting point, but there were errors with the calculations that I needed to solve in order to actually use their logic.

Fixes from Stack Overflow

First calculation to fix was the originally randomly selected position of the object. It turned out that it was very close, but it actually only worked if v0 was the origin. It was simple enough to fix by adding v0 to the x equation.

The second equation to fix was the v3 equation. They were subtracting v0 twice which is incorrect (again something unnoticeable if v0 is that origin as you’re simply subtracting (0,0) twice). v0 should only be subtracted once to obtain the correct v3 value.

Finally, a correction that was found in the comments was that there are two rotation equations for x’ and the larger one is incorrect. In the text, it can be found that a rotation of pi is necessary. This can be mathematically applied by simply reversing (x – v3) to (v3 – x).

Work to do

Fixing these mathematical errors has appeared to give me the desired results with some further testing required after a final issue. I still need to determine how to let it know mathematically when to “flip” the x position into the x’ position. The original thought was to simply compare the distance from x to v3 and v0, and if it was closer to v3 (distance was less), then apply the x’ flip transformation. This however does not seem to be a geometrically sound solution as I am sometimes getting the flipped applied when it is within the proper bounds.

July 2nd, 2018

Update: Resolved issue for determining when to flip the spawn positions

Reference:

Point in Triangle Test: Math Foundation

Building off of the previous work and calculations being done, the points for the triangles to contain the objects to spawn already exist. Using these with the calculations found in the reference for “Point in Triangle Test”, it can be determined if the point the collectible will be spawned at is indeed within the 3 vector locations of the vertices of the triangle. If it is not, then the “flip” algorithm is applied to put it into the triangle.

The test uses the existing triangle to basically check the cross products of each edge with the potential spawn location and the location of the third/final vertex of the triangle. As long as the directions of the cross product results of these two checks are the same, it can be concluded that the points are on the same side of the tested edge. If this is applied to all three edges, and the case is true for all three, it can be concluded that the point is within the triangle. If any of these are false, it is outside of the triangle and the “flip” algorithm is applied.


Video of Spawner in Action

This shows a few test runs of having the collectibles randomly spawned to check if they consistently spawn within the play area. The small red orbs that sometimes appear are error checking markers added to help determine if everything was working properly. These are spawned right before an out of bounds collectible if flipped, to leave an indication of where it was at to see if it was truly out of bounds. Some of them appear very close to the edges of the play area, but those still appear to be just outside of the triangle and seem to be getting flipped into the play area effectively so those seem correct as well.

DIGM 540 – Engineering Statics Game Concept 00 – Ring with Strings

May 24th, 2018

Engineering Statics Game Concept – 00

Vimeo – Concept for Engineering Statics Game

This was a quick proof of concept to show the idea from the last post at work. This concept takes inspiration from the hands on engineering kit that used masses on strings tugging on a central ring object to teach topics such as center of mass and vector math.

The forces from the nodes on the ring are calculated to emulate that of a mass attached to a string. Each node has a mass value associated with it (which would be the mass hanging off of it in the real world kit), and this influences how much force that node is applying to the main circular object. Moving the nodes or changing their mass value will influence the position of the ring, as it effectively represents the center of mass of the entire system through the forces applied by the nodes.

Using a simple example, I was quickly able to run a test to double check if the values provided by this toy were matching that of the true calculations and they did for the single test I’ve run so far. The center of mass equations of a system of particles was used, which can be found here on Wikipedia: Center of Mass – Wiki

DIGM 540 – Engineering Statics Game Project – Forces in Unity

May 23rd, 2018

Forces in Unity

AddForce – Unity Official Tutorials

Youtube – AddForce – Unity Official Tutorials

The bare basics of scripting forces in Unity with rigidBody’s. The AddForce can take two inputs: a vector for direction and magnitude, and what type of force it is.

ForceModes
  • Acceleration – Continuous change; not affected by mass
  • Force – (Default) Continuous change; affected by mass
  • Impulse – Instant change; affected by mass
  • VelocityChange – Instant change; not affected by mass

AddTorque – Unity Official Tutorials

Youtube – AddTorque – Unity Official Tutorials

The bare basics of scripting torques in Unity with rigidBody’s. The AddTorque can take two inputs: a vector axis to apply torque around, and what type of torque it is. This is very similar to AddForce. Important to remember, Unity uses “LEFT HAND RULE” for rotation.

ForceModes
  • Acceleration – Continuous change; not affected by mass
  • Force – (Default) Continuous change; affected by mass
  • Impulse – Instant change; affected by mass
  • VelocityChange – Instant change; not affected by mass

Game Ideation

Engineering Teaching & Research Equipment – Armfield

EF-1.1 – Statics – Forces experiment kitYoutube – EF series video Statics Forces 1 1 3

The links are similar videos, the first is just directly to the site of those that made the kit, and the second is a Youtube link. This kit provides hand on experience for understanding a lot of topics based around static equilibrium. Topics such as 2D shape center of masses, force vectors, and much more can be covered with this tool.

Game Idea – Engineering Statics Game

Following the general idea of the kit shown above, the game environment is populated with nodes that apply controllable forces to a central ring object. These forces can be altered to change the position of the ring. The environment will spawn collectibles that the player must direct the ring towards in order to collect them. To move the ring, they will need to intelligently alter the forces applied by the nodes.

Quick sketch of concept

Talks Every Game Designer Should Watch

May 23rd, 2018

Talks Every Game Designer Should Watch

These are two talks suggested to be seen by anyone in game design by Squirrel Eiserloh in his talk “GDC 2015 – Math for Game Programmers: Fast and Funky 1D Nonlinear Transformations”. They cover general game design topics on making your game feel good no matter the concept.

Juice it or lose it – a talk by Martin Jonasson & Petri Purho

Youtube – Juice It or Lose It

Jan Willem Nijman – Vlambeer – “The art of screenshake”

Youtube – The Art of Screenshake

May 22nd, 2018

Research Papers on Procedural Content Generation for Games

Darwin’s Avatars: A Novel Combination of Gameplay and Procedural Content Generation

by: Dan Lessin, Sebastian Risi

Citation: [Lessin & Risi, 2015] D. Lessin and S. Risi, “Darwin’s Avatars: A Novel Combination of Gameplay and Procedural Content Generation,” 2015, pp. 329–336.

Key Terms:

  • Evolved Virtual Creatures
  • Artificial Life
  • Muscles Drives
  • Physics-based Character Animation
  • Procedural Content Generation
Summary

Use evolved virtual creature (EVC) system from Lessin et al. reference to procedurally generate creatures that provided interesting control and locomotion problems. Originally these were piloted by an AI trying to learn how to move, but this “brain” was removed for this paper so that players could run them. Movement was determined by the activation of muscles/actuators between the procedurally generated segments of the creatures. These muscles could range in value from [0, 1], where 0 is fully relaxed and 1 is fully activated. Players would press keys to activate muscles in an attempt to move the creature.

The morphology of the creature was made up of PhysX primitive (cubes, spheres, and capsules). Body in original paper was coevolved with the locomotion system to help ensure that the creature had successful ways to move. The gameplay was compared to QWOP and Incredipede

The conclusions were: novel combination of gameplay and procedural content generation made possible by evolutionary computation, a new way of unique creature control with 3D creatures not created by the user, and game can generate novel control challenges on its own.

Further Sources to Look Into from This:
  • [8] M. Mitchell. An Introduction to Genetic Algorithms. MIT Press, Cambridge, MA, USA, 1998.
  • [15] N. Shaker, G. N. Yannakakis, J. Togelius, M. Nicolau, and M. O’Neill. Evolving personalized content for Super Mario Bros using grammatical evolution. In Proceedings of the Artificial Intelligence and Interactive Digital Entertainment Conference (AIIDE 2012), Menlo Park, CA, 2012. AAAI Press.

Petalz: Search-Based Procedural Content Generation for the Casual Gamer

by: Sebastian Risi, Joel Lehman, David B. D’Ambrosio, Ryan Hall, and Kenneth O. Stanley

Citation: [Risi et al., 2016] S. Risi, J. Lehman, D. B. D’Ambrosio, R. Hall, and K. O. Stanley, “Petalz: Search-Based Procedural Content Generation for the Casual Gamer,” IEEE Transactions on Computational Intelligence and AI in Games, vol. 8, no. 3, pp. 244–255, Sep. 2016.

Key Terms:

  • Collection Mechanics
  • Compositional Pattern Producing Networks (CPPNs)
  • Procedural Content Generation
  • 3-D Printing
Summary

This research explored the use of PCG for a casual, social, collection mechanic focused game. In this research it also explored the effects of PCG on markets for in game economies and translation to real world objects with 3D printing.

The game uses procedural generation along with AI to create an Interactive Evolutionary Computation (IEC) system to create the flowers in the game. The generator is a modified compositional pattern producing network (CPPN) and the evolutionary algorithm chosen was Neruoevolution of Augmenting Topologies (NEAT).

The game focuses on users breeding flowers which can be seen by other players. These other players can “like” their flowers or purchase ones that are put up for sale. Breeding is done by three methods: pollination (allow for natural mutation through a single flower), cross pollination (combine traits of two different flowers), and cloning (simply replicate a flower). The player’s selection of what and how to breed is the interactive part of this IEC system, which allows the user to employ a search-based method of exploring the PCG design space.

To help provide a goal for players, this research also looked into creating a guided categorization system using the inherent properties of the parametric PCG technique used to create these flowers. They took advantage of the fact that this technique can lead to spatial design spaces where objects near each other in the design space will also tend to have similar aesthetic attributes. They explore this further with a Self-Organizing Map (SOM).