Difference between revisions of "Parts"

From Grassy Landscape Wiki
Jump to navigation Jump to search
Line 81: Line 81:
 
<code>rand(min, max, bias)</code> generates a random number between its two first arguments, biased by the third argument. Notice that lightnesses below 0.1 are impossible to spawn and so are saturations below 0.1, which are both reflected in the graph.
 
<code>rand(min, max, bias)</code> generates a random number between its two first arguments, biased by the third argument. Notice that lightnesses below 0.1 are impossible to spawn and so are saturations below 0.1, which are both reflected in the graph.
  
===Colors Found In Game===
+
=== BrickColors found in-game ===
 
{| class="wikitable"
 
{| class="wikitable"
 
! Color Name
 
! Color Name

Revision as of 01:58, 20 May 2021

Parts are Roblox parts that spawn throughout the map. They can be picked up, welded, and cut by players. Parts come in a variety of colors, shapes and sizes. They are one of the core building materials of the game, the other being items.

Spawning

Upon server start, 4,800 parts are spawned around the map. Each part has a random position, size, material, shape and color. For positioning, the map has designated spawn areas for parts and items. An algorithm picks between these areas, giving each one a probability equal to its volume, then calculates a random position and rotation within the area. For shape, each part has a ~60% chance of being a block and a ~40% chance of being a cylinder.

Materials

For material, one is picked according to the probability table below.

Material Chance Value
CorrodedMetal 30.6% 0.8
Metal 19.6% 1
SmoothPlastic 19.6% 1
DiamondPlate 13.6% 1.2
Glass 13.6% 1.2
Foil 3.1% 2.5

Below is the code used to calculate that table, which can be run by any injector such as Synapse or Script-Ware. The reason for the (1 / v) ^ 2 formula is that the part spawning script uses that formula when choosing which material to pick. (confirmed by the developer)

local valuebook = require(game.ReplicatedStorage.ValueBook)

local total = 0
for _, v in pairs(valuebook.MaterialValues) do
	total += (1 / v) ^ 2
end

for _, v in pairs(valuebook.Materials) do
	local value = (1 / valuebook.MaterialValues[v])^2
	print(v, tostring((value / total) * 100) .. '%', value)
end

Sizing

For size, the value of the picked material is used as a bias. The bias skews the random distribution such that higher bias values cause lower random numbers to be more common. In practice this means that parts with rarer materials tend to spawn smaller, but all sizes are still possible. Then, the Y and Z values are randomly generated. Each component is calculated as math.random()^bias * 9 + 1, which means a random number from 1 to 10, skewed by the bias. Again, higher biases (such as foil's bias of 2.5) mean that the size will tend towards the 1, while lower biases (such as in the case of corroded metal) tend to skew towards 10.

The maximum value for the X component will be a value N such that Y * Z * N == 125. In order words the maximum volume of the part will be 125 studs squared. The minimum value of the X component is always 0.2. Then a random number is generated between those two values, skewed by the bias once again.

The full function is thusly:

function Part:RandomSize(bias)
	local y = math.random()^bias * 9 + 1
	local z = math.random()^bias * 9 + 1
	local x = math.min(math.random()^bias * (125 / (y * z) - 0.2) + 0.2, 10)
	
	return Vector3.new(x, y, z)
end

Colors

Parts mainly spawn in dull and muted tones, with some greys and whites mixed in. Rather than a list of BrickColors, part colors are generated as Color3 values, so there is an entire spectrum of possible colors. Nonetheless, the spectrum is limited and is only a small fraction of the color space. Here is a graph showing the entire part color spectrum (click on it for a larger version):

GLS color spectrum.png

On the left is the hue and lightness spectrum, and on the right is the saturation spectrum. The range of saturation values for a color depends on its lightness, which is why there is a separate saturation graph next to the main one. To pick a color from the spectrum, first the game chooses the hue and lightness from the graph on the left, and then it chooses a saturation from the graph on the right. As you can see, brighter colors have a smaller saturation range.

The color generation code is as follows:

local hue = math.random()
local lightness = rand(0.1, 1, 0.75)
local saturation = rand(0.1, 0.5 - (lightness^0.5 * 0.4), 5)

rand(min, max, bias) generates a random number between its two first arguments, biased by the third argument. Notice that lightnesses below 0.1 are impossible to spawn and so are saturations below 0.1, which are both reflected in the graph.

BrickColors found in-game

Color Name Spawnrate Rgb
Black Very High *
Insitutional white Very High *
Mid grey Very High *
Cloudy grey High *
Dark grey High *
Dark taupe High *
Dirt brown High *
Earth green High *
Fossil High *
Ghost grey High *
Grey High *
Hurricane grey High *
Pearl High *
Light grey High *
Light stone grey High *
Quill grey High *
Sand green High *
Sand red High *
Sand violet High *
Sage green High *
Smoky grey High *
White High *
Artichoke Medium *
Cadet blue Medium *
Dark stone grey Medium *
Earth blue Medium *
Faded green Medium *
Flint Medium *
Grime Medium *
Lily white Medium *
Linen Medium *
Medium stone grey Medium *
Oyster Medium *
Pine Cone Medium *
Really Black Medium *
Sand blue Medium *
Sand yellow Medium *
Silver Medium *
Slime green Medium *
Brown Low *
Cocoa Low *
Copper Low *
Earth yellow Low *
Fog Low *
Moss Low *
Mulberry Low *
Laurel green Low *
Reddish lilac Low *
Bright bluish violet Very Low *
Bright reddish lilac Very Low *
Bright violet Very Low *
Bronze Very Low *
Lavender Very Low *
Lilac Very Low *
Medium bluish violet Very Low *
Medium lilac Very Low *
Plum Very Low *
Seashell Very Low *
Steel blue Very Low *
Storm blue Very Low *
Tawny Very Low *
Beige Extremely Low *
Bright green Extremely Low *
Bright reddish violet Extremely low *
Burlap Extremely Low *
Burgundy Extremely Low *
Dark green Extremely Low *
Earth orange Extremely Low *
Fawn brown Extremely Low *
Light bluish green Extremely Low *
Light lilac Extremely Low *
Med. reddish violet Extremely Low *
Medium green Extremely Low *
Olivine Extremely Low *
Parsley Green Extremely Low *
Reddish brown Extremely Low *
Daisy orange Almost impossible *
Royal Blue Almost impossible *
Turquoise Almost impossible *

Debug Colors

Older versions of Grassy Landscape spawned random BrickColors instead of using a color spectrum. Colors outside the spawnable spectrum are referred to as "debug colors", since they used an unfinished algorithm for debugging purposes (i.e. to get the rest of the game working first). Since there is currently no save system, and all debug colors have been removed from the game, it is no longer possible to encounter a part color outside of the spectrum.

"Rare BrickColors"

When generating colors, the game will refuse to generate any color that happens to be a "rare BrickColor". The list of rare BrickColors is below:

Name Reason
Lig. Yellowich orange Typo
Light green (mint) Parenthesis
Phosph. White Cool name
Transparent Transparent
Tr. Red Transparent
Tr. Lg blue Transparent
Tr. Blue Transparent
Tr. Yellow Transparent
Tr. Flu. Reddish orange Transparent
Tr. Green Transparent
Tr. Flu. Green Transparent
Tr. Brown Transparent
Tr. Medi. reddish violet Transparent
Tr. Bright bluish violet Transparent
Tr. Flu. Blue Transparent
Tr. Flu. Yellow Transparent
Tr. Flu. Red Transparent
Red flip/flop Flip/flop
Yellow flip/flop Flip/flop
Silver flip/flop Flip/flop
Sand blue metallic Metallic
Sand violet metallic Metallic
Sand yellow metallic Metallic
Dark grey metallic Metallic
Black metallic Metallic
Light grey metallic Metallic
Gun metallic Metallic
Lemon metalic Bkerr's favorite color

If the algorithm generates a color that is "rare", it will simply re-roll until it lands on one that isn't. Most likely, if someone has a part with one of these colors, it was obtained from an event or someone with the debug GUI.