From 278ede2c0f8f645a4fe721c31f81c66a50ac9427 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Tue, 20 Feb 2018 11:42:59 -0500 Subject: [PATCH] Stars? Solar Systems? Galaxies? Why not? 1e12 meters. --- game.js | 23 ++++++++--- recursive-macro.js | 99 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 112 insertions(+), 10 deletions(-) diff --git a/game.js b/game.js index e5f62c8..8c1c07b 100644 --- a/game.js +++ b/game.js @@ -430,7 +430,10 @@ function initVictims() "Town": 0, "City": 0, "Continent": 0, - "Planet": 0 + "Planet": 0, + "Star": 0, + "Solar System": 0, + "Galaxy": 0 }; }; @@ -445,7 +448,9 @@ function getOnePrey(biome,area) { var potential = ["Person"]; - if(macro.height > 1e6) + if (macro.height > 1e12) + potential = ["Planet","Star","Solar System","Galaxy"]; + else if (macro.height > 1e6) potential = ["Town","City","Continent","Planet"]; else switch(biome) { @@ -478,12 +483,20 @@ function getPrey(region, area) { var weights = {"Person": 1}; - if (macro.height > 1e6) { + if (macro.height > 1e12) { + weights = { + "Planet": 0.0001, + "Star": 0.0001, + "Solar System": 0.00001, + "Galaxy": 0.01 + } + } + else if (macro.height > 1e6) { weights = { "Town": 0.1, "City": 0.05, - "Continent": 0.5, - "Planet": 1 + "Continent": 0.005, + "Planet": 0.0001 } } else { diff --git a/recursive-macro.js b/recursive-macro.js index 768bada..af72611 100644 --- a/recursive-macro.js +++ b/recursive-macro.js @@ -18,7 +18,10 @@ var things = "Town": Town, "City": City, "Continent": Continent, - "Planet": Planet + "Planet": Planet, + "Star": Star, + "Solar System": SolarSystem, + "Galaxy": Galaxy }; var areas = @@ -40,7 +43,10 @@ var areas = "Town": 1e7, "City": 1e9, "Continent": 1.5e13, - "Planet": 5e14 + "Planet": 2.5e14, + "Star": 3e18, + "Solar System": 3e21, + "Galaxy": 2e42, }; var masses = @@ -62,7 +68,35 @@ var masses = "Town": 0, "City": 0, "Continent": 1e12, - "Planet": 5.972e24 + "Planet": 5.972e24, + "Star": 1e40, + "Solar System": 0, + "Galaxy": 0 +}; + +var clusters = +{ + "Container": 0, + "Person": 5, + "Cow": 15, + "Car": 3, + "Bus": 1, + "Tram": 1, + "Motorcycle": 1, + "House": 5, + "Barn": 1, + "Small Skyscraper": 10, + "Train": 2, + "Train Car": 1, + "Parking Garage": 1, + "Overpass": 1, + "Town": 1, + "City": 1, + "Continent": 5, + "Planet": 1, + "Star": 1, + "Solar System": 1, + "Galaxy": 1 }; // general logic: each step fills in a fraction of the remaining space @@ -96,8 +130,8 @@ function fill_area2(area, weights) // the first few ones get a much better shot while (limit > 0) { - if (limit <= 3) - count += Math.random() < (1 - Math.pow((1 - candidate.weight),limit*3)) ? 1 : 0; + if (limit <= clusters[candidate.name]) + count += 1; else count += Math.random() < candidate.weight ? 1 : 0; --limit; @@ -984,3 +1018,58 @@ function Planet(count = 1) { } } } + +function Star(count = 1) { + this.name = "Star"; + + copy_defaults(this,new DefaultEntity()); + this.count = count; + this.contents = {}; + + this.describe = function(verbose = true) { + return (this.count == 1 ? "a star" : this.count + " stars"); + } +} + +function SolarSystem(count = 1) { + this.name = "Solar System"; + + copy_defaults(this,new DefaultEntity()); + this.count = count; + this.contents = {}; + + this.contents.star = new Star(1); + + var amount = distribution(5,15,count); + this.contents.planet = new Continent(amount); + + this.describe = function(verbose = true) { + if (verbose) { + return (this.count == 1 ? "a solar system" : this.count + " solar systems") + " made up of " + describe_all(this.contents, verbose); + } else { + return (this.count == 1 ? "a solar system" : this.count + " solar systems"); + } + } +} + +function Galaxy(count = 1) { + this.name = "Galaxy"; + + copy_defaults(this,new DefaultEntity()); + this.count = count; + this.contents = {}; + + var amount = distribution(1e9,500e9,count); + this.contents.star = new Star(amount); + + var amount = distribution(1e8,500e8,count); + this.contents.solarsystem = new SolarSystem(amount); + + this.describe = function(verbose = true) { + if (verbose) { + return (this.count == 1 ? "a galaxy" : this.count + " galaxies") + " made up of " + describe_all(this.contents, verbose); + } else { + return (this.count == 1 ? "a galaxy" : this.count + " galaxies"); + } + } +}