Scrap Galaxy is a local build-and-destroy deathmatch game for up to 4 players. It is a 2D top-down shooter taking place out in space in a galactic junkyard. In this setting, the players are trying to survive by constructing space ships.

Post news Report RSS AI Development - Spaceship Construction - Scrap Galaxy

Scrap Galaxy is a local build-and-destroy deathmatch game for up to 4 players. It is a 2D top-down shooter taking place out in space in a galactic junkyard. The AI in Scrap Galaxy faces two problems, first one is how to build a decent spaceship from a pile of random parts, where we do not know the next parts beforehand. Second problem is how to pilot a spaceship made out of a lot of random parts. This article will cover the first problem, how to build a spaceship from random parts.

Posted by on

Hi,

Jesper from Catalope Games here again. This time I will tell something about the AI in Scrap Galaxy. Scrap Galaxy is a local build-and-destroy deathmatch game for up to 4 players. It is a 2D top-down shooter taking place out in space in a galactic junkyard. In this setting, the players are trying to survive by constructing spaceships. They can use these ships to fight against each other or they can fight together against the AI. You can also play it with bots instead of real players.

The AI in Scrap Galaxy faces two problems, first one is how to build a decent spaceship from a pile of random parts, where we do not know the next parts beforehand. Second problem is how to pilot a spaceship made out of a lot of random parts with weapons sticking out at all directions, enemies trying to shoot you down and space junk we can collide with. This article will cover the first problem, how to build a spaceship from random parts!

AIs building spaceships

First we need to define what we mean by "decent spaceship". We want to make an AI that builds ships which are.

  • Sound - do not shoot itself apart. So do not build weapons facing already placed components nor place components in places so they'll get hit.
  • Functional as in the ship can fly decently and has weapons. A balance of components.
  • Aesthetic - a spaceship does not look like a pile of junk taped together but has symmetry.
  • And lastly not deterministic. Given the same pool of components, which is the case in some game modes, it should not build the same spaceship over and over again.

How I solved this is like an local optimization problem. For each build step it searches after the best part and the best position to place it in. Here are the different parameters it can optimize over. When the AI constructs a new ship these are randomized within certain ranges. This also gives the feature of being able to have AIs with different playstyles - one likes fast ships while another one prefers slow large ones.


public enum SymmetryType {
   X_AXIS,
   BOTH_AXIS,
   Y_AXIS,
   BEND,
}

public float RandomPart;
public float Symmetry;
public SymmetryType PreferedSymmetry;
public float Speed;
public float Damage;
public float Range;
public float Defence;
public float Size;
public float[] Direction;

But this does not solve the problem completely, as the AI needs take into account what parts have already been placed on the ship. Otherwise an AI with a high liking of Damage would always place weapons until the entire ship is covered in nothing else, without any engines or other components whatsoever.

That is why the utility value of a component is scaled via a diminishing return function. This functions says that the more components of a certain type, for example weapons, you have the lesser you gain from having yet another weapon on your ship.

utilityValue = DiminishingReturn(weapon.DPS, ShipData.TotalDPS) * BuildStrategy.Damage;

// ....

private float DiminishingReturn(float value, float shipValue) {
   float pow = 0.5f ;
   return Mathf.Pow(value + shipValue, pow) - Mathf.Pow(shipValue, pow);
}

We are going live on Steam 1:st December! If that sounds cool check it out or follow us at @CatalopeGames or our Facebook page. Or add the game to your Steam wishlist!

Want to review our game or apply for a promo code? Contact: Rasmus@spearheadnordic.com

Comments
Roarkes
Roarkes

It will be free ?

Reply Good karma Bad karma+1 vote
CatalopeGames Author
CatalopeGames

No, it will be around the same cost as a pizza.

Reply Good karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Icon
Scrap Galaxy
Platforms
Windows
Developer & Publisher
Catalope Games
Engine
Unity
Contact
Send Message
Homepage
Scrapgalaxy.com
Release date
Game watch
Follow
Purchase
Related Games
Scrap Galaxy
Scrap Galaxy Arcade
Related Engines
Unity
Unity Commercial
Related Groups
Catalope Games
Catalope Games Developer & Publisher with 2 members
Indie Gamers
Indie Gamers Hobbies & Interests with 1,469 members
Unity Devs and Gamers
Unity Devs and Gamers Hobbies & Interests with 1,742 members