[Question]
  [
**Intro**
This is based on an actual problem I recently faced while making a computer game and I thought it would make for a nice round of [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'").
There are seven main [spectral classes](https://en.wikipedia.org/wiki/Stellar_classification) of star which put out varying amounts of heat. The geology of planets around a star are greatly influenced by the amount of heat received from the star, which is a factor of spectral class and distance from the star. Hence Mercury is practically molten, Neptune frozen.
The galaxy in my game is procedurally generated and randomly selecting planet types for given stars turned out to be a real 'if statement hell'!
**The challenge**
Your method should select one planet from a list of planet types appropriate for the class of star, based on a minimum heat threshold, a maximum heat threshold and a random number.
For simplicity this challenge will only use a class G star, just like our sun.
**Inputs**
An integer `heat` in the range 4 to 11 representing the amount of heat received by the planet from the star.
**Variables**
This table shows the possible planets based on `heat`. Your method should first narrow the available choices based on the heat min and heat max, `heat` should fall on or between the two. E.g. with a heat of 10 passed in the only choices would be Desert, Iron and Lava.
```
Planet type    Heat min   Heat max   Random Chance
Gas Giant         4          9            15
Ice               4          6            10
Ice Giant         4          6            10
Gaia class        5          7            10
Dense Atmosphere  7          9            10
Desert            7          10           25
Iron              7          10           14
Lava             10          11           6
```
Next, the probability of a planet (in the remaining choices) being chosen is its random chances divided by the sum of the random chances of all the choices.
In the above example, the probability of Iron being chosen is `14/(25+14+6)`.
**Output**
Return the planet type as a string.
Do the best you can to avoid logic arrowheads. Shortest code wins, points all round for creativity. Happy golfing!
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~78~~ 75 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
“'ĖøÆḳƙ’ḃ7ṣ6Ä+3r/ċ€×“½½½½©ÐÇı‘
“ŀỊẋ8ƒ³ẈRɼƈñqẋẏȧɱḌ<ṄỴḳ⁾ÆʋeẒĊ'@ƬØƓƝ}ḟ¬»Ỵx'ÇX
```
A monadic link accepting an integer (in **[4,11]**) which returns a list of characters.
**[Try it online!](https://tio.run/##y0rNyan8//9Rwxz1I9MO7zjc9nDH5mMzHzXMfLij2fzhzsVm2jHaxkX6R7ofNa05PB2o7NBeKFx5eMLh9iMbHzXM4AIKH214uLvr4a5ui2OTDm1@uKsj6OSeYx2HNxYChR7u6j@x/OTGhzt6bB7ubHm4ewvQikeN@w63nepOfbhr0pEudYdjaw7PODb52NzahzvmH1pzaDdQUYX64faI////mwIA "Jelly – Try It Online")**
### How?
Creates the heat ranges of the planets as a list of lists and counts the occurrences of the input heat in those lists to get a list of zeros and ones representing which planet types are possible, then multiplies by the likelihood numbers of the eight planet types to get the distribution. The distribution is used to repeat the planet type names, and finally, a uniform random choice is made.
```
“'ĖøÆḳƙ’ḃ7ṣ6+\+3r/ċ€×“½½½½©ÐÇı‘ - Link 1, getDistribution: integer
“'ĖøÆḳƙ’                        - base 250 integer = 39824688429662
        ḃ7                      - to bijective-base 7 = [1,1,2,4,7,1,4,4,6,2,2,2,2,1,5,3,3]
          ṣ6                    - split at sixes = [[1,1,2,4,7,1,4,4],[2,2,2,2,1,5,3,3]]
            +\                  - reduce by addition = [[1,1,2,4,7,1,4,4],[3,3,4,6,8,6,7,7]]
              +3                - add three = [[4,4,5,7,10,4,7,7],[6,6,7,9,11,9,10,10]]
                r/              - reduce by inclusive range = [[4,5,6],[4,5,6],[5,6,7],[7,8,9],[10,11],[4,5,6,7,8,9],[7,8,9,10],[7,8,9,10]]
                  ċ€            - count (input) in €ach e.g. for 5: [1, 1, 1, 0,0, 1, 0, 0]
                     “½½½½©ÐÇı‘ - list of code-page indices        [10,10,10,10,6,15,14,25]
                    ×           - multiply                         [10,10,10, 0,0,15, 0, 0]
“ ... »Ỵx'ÇX - Main link: integer
“ ... »      - compressed string = "Ice\nIce Giant\nGaia class\nDense Atmosphere\nLava\nGas Giant\nIron\nDesert"
       Ỵ     - split at new lines = ["Ice","Ice Giant","Gaia class","Dense Atmosphere","Lava","Gas Giant","Iron","Desert"]
          Ç  - call last link (1) as a monad e.g. for 5: [10,10,10,0,0,15,0,0]
         '   - spawn:
        x    -   times e.g. for 5: ["Ice","Ice","Ice","Ice","Ice","Ice","Ice","Ice","Ice","Ice","Ice Giant","Ice Giant","Ice Giant","Ice Giant","Ice Giant","Ice Giant","Ice Giant","Ice Giant","Ice Giant","Ice Giant"]
           X - a random choice from that list
```
[Answer]
# [R](https://www.r-project.org/), ~~225~~ ~~223~~ 183 bytes
Thanks to Giuseppe for clever refactoring to take it down to 188 bytes; the remaining five were shaved off by using less redundant number representations.
```
i=scan()-4
sample(c("Gas Giant","Ice","Ice Giant","Gaia class","Dense Atmosphere","Desert","Iron","Lava")[l<-c(0,0,0,1,3,3,3,6)<=i&c(5,2,2,3,5,6,6,7)>=i],1,,c(3,2,2,2,2,5,2.8,1.2)[l])
```
[Try it online!](https://tio.run/##PYzbCsIwDIZfZfRCWsjGDm4KboIgDME3kF2EErDQdaMZvn7tKsgHCfkP8SGYgTU6qfLjhXFeLUktxYicjQbdJkA8NP3mXxnRYKYtMsfjTo4pu23zwuubPCWJyaeqX1xcT/ygUC/b51qWsFNBk@hUP5iDli3UkQZa6CIndR3MFEOgZZOcnZgpzlAVdfw0qVCV4Qs "R – Try It Online")
[Answer]
# JavaScript 212
**Edit** 6 bytes save thx Jonathan Allan
```
h=>[963,640,640,649,667,1628,924,437].map((z,i)=>(z/8&7)+4>h|z%8+6<h?0:t=r.push(...Array(z>>6).fill(i)),r=[])&&"Gas Giant,Ice,Ice Giant,Gaia class,Dense Atmosphere,Desert,Iron,Lava".split`,`[r[t*Math.random()|0]]
```
*less golfed*
```
h=>( 
   r = [],
   // heat min,max and chance encoded in base 8 with offsets
   // min range 4 to 10, with offset 4, 0 to 6
   // max range 6 to 11, with offset 6, 0 to 5
   [(4-4)*8 + 9-6 + 15*64,
    (4-4)*8 + 6-6 + 10*64,
    (4-4)*8 + 6-6 + 10*64,
    (5-4)*8 + 7-6 + 10*64,
    (7-4)*8 + 9-6 + 10*64,
    (7-4)*8 + 10-6+ 25*64,
    (7-4)*8 + 10-6+ 14*64,
    (10-4)*8+ 11-6+  6*64]
   .forEach( (z,i) => (
      min = (z / 8 & 7) + 4, 
      max = z % 8 + 6,
      chance = z >> 6,
      min > h || max < h 
      ? 0 // out of range
      // add current position i repeated 'chance' times
      // array size in t
      : t = r.push(...Array(chance).fill(i))
   ),
   pos = r[t * Math.random() | 0],
   ["Gas Giant", "Ice", "Ice Giant", "Gaia class", "Dense Atmosphere", "Desert", "Iron", "Lava"][pos]
)
```
*Test*
```
var F=
h=>[963,640,640,649,667,1628,924,437].map((z,i)=>(z/8&7)+4>h|z%8+6<h?0:t=r.push(...Array(z>>6).fill(i)),r=[])&&"Gas Giant,Ice,Ice Giant,Gaia class,Dense Atmosphere,Desert,Iron,Lava".split`,`[r[t*Math.random()|0]]
function test()
{
   var heat=+H.value
   var i,result,hashtable={},rep=1e5
   for (i=0;i<rep;i++)
     result = F(heat),
     hashtable[result] = -~hashtable[result]
 
   console.log('Input',heat)
   for (i in hashtable)
   {
     console.log(i,(hashtable[i]/rep*100).toFixed(2),'%')
   }
}
```
```
<input id=H type=number min=1 max =15 value=10>
<button onclick='test()'>Test</button>
```
[Answer]
# [Coconut](http://coconut-lang.org/), ~~214~~ 195 bytes
```
t->choice..sum([[n]*g(p)*(g(a)<t<g(b))for*n,a,b,p in'Gas Giant3AF_Ice37A_Ice Giant37A_Gaia class48A_Dense Atmosphere6AA_Desert6BP_Iron6BE_Lava9C6'.split('_')],[])
from random import*
g=int$(?,36)
```
[Try it online!](https://tio.run/##fVA7a8MwGNz9K74hIMkogtbBbSF2cfowgQ7ZXWMUVXZkYklIXzr1v7tOKXTrdA/uODjllLMXnPvifcZ1qU7OKC1EvEy0aWybDtSzlA5Usi1uB3pkrHchtVzyI/dgLKllhNpIi1n12u2Vzu6qK/x6i6ilkaDOMsbNfdU9axs1VDi56E866Ly6elEHzHeHbh@czXcv3Zv8lA9PORHRnw1S0hHW8qZlSR/cBEHajwXM5F3ANBkKY3FFH3mWs3mEAggRozM2WXKDphsON7cMvkqYpF9RhHUJFDmMQvQU2T@E/bV8WDZ@5HLXco6evwE "Coconut – Try It Online")
A Python port would be ~~203~~ 200 bytes long:
```
lambda t:choice(sum([[n]*int(p,36)*(int(a)<t<int(b,36))for*n,a,b,p in'Gas Giant3AF_Ice37A_Ice Giant37A_Gaia class48A_Dense Atmosphere6AA_Desert6BP_Iron6BE_Lava9C6'.split('_')],[]))
from random import*
```
[Try it online!](https://tio.run/##LY/LasMwEEX3@YrZ6YEItDZua5KF00cIdNG9a8zYkWsVayQktdCvdy3I6tw5qzP@L82OinU6fq4L2uGKkOpxdmbUPP5Y3rbUSUOJe1VUQvI8URzSIY8hOzG5IEmhGpQHQ@yMEc4GKRXNW38ZdfHQZNzcdpzRIIwLxlg@Nv2LpqihSdZFP@ugqya7qEOqTh/9JTiqTq/9O/7i03PF9tEvJnHWM9GpthNiNwVnISBdNxjrXUhy3YrAbC3Zf2leKri7F/UOwIecbRRIi57f/qWasf23M8QnTkIoaE0ny41R@yNTwMT6Dw "Python 3 – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~115~~ 111 bytes
```
≔Ｉ⁻Ｎ³θＦ⁸«≔§⪪”↷＆∧⬤.YLφκ¦(⁼；σ≕]✂↙ζＣ” ιη¿›θη¿‹θ§η¹ＦＩ✂η²⊞υι»§⪪”↓(″1↨▷]Ｕ,&ζ^iＩ″ＲＳＹ≡´⍘'#﹪υＶw5Ｖu>D<U5r6⁰Ｑ▷Ｚ◨⌕⁸ΣεCＺ”¶‽υ
```
[Try it online!](https://tio.run/##XY/BasMwEETP8VcsPsnggpXESYpPoQVjSEtorr5sHaUW2GtHK4VC6be7kttcetCDHbEzs02Lphmwm6Y9s/4g8YRsxYsmx6Ki0dlX178rI5IUVonHNSmiy2BA7BL4ihZ/S3tb0Vl9itPYaSvibCtzyNYy@4XMPVbbgN0y95Br2Dxu4hRiiL2n9q/1vgt9AVEahdYHXoOWQJAOijnM95Q2BZn4v7nH3PfU6UYFfRn0o@NWuOBbRN/R0Wiy/xuWyFBqJFtT1agZ97lEjdB0yFzTsyJWPrcfeGyVUUFhZcKWGaimA97Q31BTOOMN6Tz0wvkKxTTJbHq4dT8 "Charcoal – Try It Online") Link is to verbose version of code. Edit: Saved 4 bytes thanks to @ASCII-only. Explanation:
```
≔Ｉ⁻Ｎ³θ
```
Subtract 3 from the input so that it can be compared against single digits.
```
Ｆ⁸«≔§⪪”↷＆∧⬤.YLφκ¦(⁼；σ≕]✂↙ζＣ” ιη
```
Split the string `0715 0410 0410 1510 3710 3825 3814 696` on spaces (spaces seem to compress better than commas but I didn't try any other characters) and loop over each portion.
```
¿›θη¿‹θ§η¹ＦＩ✂η²⊞υι»
```
Compare the input against the first and second digits and if it's between then push the loop index the given number of times to the predefined empty list, thus populating it.
```
§⪪”↓(″1↨▷]Ｕ,&ζ^iＩ″ＲＳＹ≡´⍘'#﹪υＶw5Ｖu>D<U5r6⁰Ｑ▷Ｚ◨⌕⁸ΣεCＺ”¶‽υ
```
Split the list of planets on newlines (again, better than commas for some reason) and select the element corresponding to a index chosen randomly from the list.
[Answer]
# [R](https://www.r-project.org/), ~~196~~ ~~193~~ ~~190~~ ~~175~~ 171 bytes
```
sample(readLines(,8),1,,c(3,2,2,2,2,5,2.8,1.2)*((x=scan()-3)>c(0,0,0,1,3,3,3,6)&x<c(7,4,4,5,7,8,8,9)))
Gas Giant
Ice
Ice Giant
Gaia class
Dense Atmosphere
Desert
Iron
Lava
```
[Try it online!](https://tio.run/##LcvdCoJAEAXg@30Kr2ImJsmf0qCCIJDAlxi2gQRdZUfCt9/WkI9zcQ4cH4LyMPUCXvjddk4UqEbKiCwUlG9OlKc1ZWmOe4DlppYd4KHAu4UjrTIq/s64W64WKiqjE1VURxdENA1r0nTsZvOysmZrDXec2J5VzVOcSvKYh1Gnj3iJg4qPBz860/KXQxl@ "R – Try It Online")
Initially inspired by [this](https://codegolf.stackexchange.com/a/156683/78274) solution by @rturnbull, however as both submissions have significantly evolved, this is now essentially a mix of ideas of the original author, @Giuseppe who has been very helpful in comments, and mine. Here is a summary of key points that helped to bring the byte count down:
* ~~Encoding planet data as CSV~~ Collecting names with `readLines` to avoid the large number of quotation characters around strings.
* Tweaking the heat params so that we could use `<` and `>` signs
instead of `<=` and `>=`.
* ~~Changing the heat data format from `Heat min, Heat max` to `Heat min,
Heat Delta` to get rid of double digit numbers.~~  
Replaced by shifting all numbers by -3
* Dividing all planet probabilities by 5 which also results in a few less digits.
* Multiplying the vector of planet probabilities with the vector of Booleans (indicating whether our input satisfies the heat requirements) to nullify the probabilities of unsuitable planets.
~~Probably, a few more bytes could be gained by applying some sort of data compression.~~  
I think, not anymore.
[Answer]
# [Octave](https://www.gnu.org/software/octave/) with Statistics Package, ~~178~~ ~~176~~ ~~174~~ 158 bytes
```
@(h)randsample(strsplit('Gas Giant,Ice,Ice Giant,Gaia class,Dense Atmosphere,Desert,Iron,Lava',','),1,1,('UPPPP_TL'-70).*(h>'IIIJLLLO'-70&h<'PMMNPQQR'-70)){1}
```
The code defines an anonymous function that inputs a number and outputs a string.
[**Try it online!**](https://tio.run/##LYvBCsIwEETvfkVOJpFYzEEEsaIglErUKnqWpW5poSYlG72I316jOI85zDDjygBP7Ks0SZJ@JWrpwd4I7l2LgoKnrm2C4BkQyxqwQeUlfv1PGTTAyhaI1AYtIVuHu6OuRo@xIPTx4J1VBp7AVUQqHRH8UkRdz4aPZxOZjES95Hmeb40xh281rBe82O32xfF4@k3kS7/7ynlWuocNLGV6rqeDSuiJHKC99R8)
### Explanation
The code
```
@(h)
```
defines an anonymous function with input `h`.
The string
```
'Gas Giant,Ice,Ice Giant,Gaia class,Dense Atmosphere,Desert,Iron,Lava'
```
is split at commas using
```
strsplit(...,',')
```
The result is a cell array of strings, where each string is a planet class.
The code
```
'IIIJLLLO'-70
```
defines the shown string and subtracts `70` from the code points of its chars. This gives the array of minimum heat values *minus 1*, that is, `[3 3 3 4 6 6 6 9]`.
Similarly,
```
'PMMNPQQR'-70
```
produces the array of maximum heat values *plus 1*, that is, `[10 7 7 8 10 11 11 12]`.
The comparisons
```
h>...&h<...
```
give an array containing `true` or `false` indicating which planet classes are possible.
On the other hand,
```
'UPPPP_TL'-70
```
defines the array of random chance values, `[15 10 10 10 10 25 14 6]`.
The operation
```
(...).*(...)
```
is the element-wise multiplication of the latter two arrays (`true` and `false` behave like `0` and `1` respectively). This gives an array where each planet class has either its random chance, or `0` if that class is not possible based on the input. This array will be used as weights in the random sampling
The function call
```
randsample(...,1,1,...)
```
selects one of the cells from the cell array of strings (first input argument), using the computed array of weights (fourth input argument). Specifically, the function `randsample` automatically normalizes the weights to probabilities, and then does the random selection with those probabilities. The result is a cell array containing a string. The code
```
{1}
```
is used to extract that string, which constitutes the function output.
[Answer]
# [Python 3](https://docs.python.org/3/), 263 bytes
```
from random import*
P=lambda h:"Gas Giant|Ice|Ice Giant|Gaia class|Dense Atmosphere|Desert|Iron|Lava".split("|")[choices(*list(zip(*filter(lambda x:h in range(*x[2:]),zip(*[[int(x,32)for x in"0f4a1a472a473a584a7a5p7b6e7b76ac"][a::4]for a in(0,1,2,3)]))))[:2])[0]]
```
[Try it online!](https://tio.run/##TY5Pa8MwDMXv/RTGJzsLo/nTZhh2GAzKYIfejRlq6iyCxDa2GdmafvbMKYVN8BCS3uMn9x17a6pl6bwdiQdzTg1HZ33MNsfnAcbTGUgv6AECOSCYOL@1etV9OgACaQcIYX7VJmjyEkcbXK@9TougfQp4a@Z3@AL6GNyAkdGZctn2FlsdWDZgiOwHHcs6HKL27A6dRE/QrD99apZNshSK5zeflGgim/Kq5J31ZEo2uu1qKKBuyqQKdk81NLBzzWmvm1Ozh5YqCULUag1ACrBtXuRlXnHFU0lRKi63Si3rHf@4dV4UDwUXG0KcX6kdveCVCHKRR4Y3/Mc/N1dXypdf "Python 3 – Try It Online")
[Answer]
# Python 3, ~~199~~ 194 bytes
```
from random import*
lambda n:choices("Ice|Ice Giant|Gas Giant|Gaia class|Dense Atmosphere|Desert|Iron|Lava".split('|'),[(0x33b2a53d4a>>5*i&31)*(0xc07878380e3f0707>>8*i+n-4&1)for i in range(8)])
```
Splitting `h` into separate bit masks and random chance values (see explanation) saves a few bytes by eliminating an assignment to `h` and simplifying the `range()` in the list comprehension.
### Previous solution
```
from random import*
h=0xc033c39e3270a0e51fbc1d40ea
lambda n:choices("Ice|Ice Giant|Gas Giant|Gaia class|Dense Atmosphere|Desert|Iron|Lava".split('|'),[(h>>i&31)*(h>>i+n+1&1)for i in range(0,104,13)])
```
Defines an anonymous function that takes an int and returns the planet type.
For each planet type, a 13-bit value was calculated. The top 8 bits define a bit mask of valid heat values for that planet type. The bottom 5 bits are the random chance for that planet type. For example, "Gaia class" is a valid type for heat values 4 to 7, so it has a mask of `0b00001111`. It has a random chance of 10, or `0b01010`. Combining them results it the 13-bit value `0b0000111101010` for the "Gaia class" type. The 13-bit values for each planet type are concatenated to get the value for `h` (the lowest 13 bits are for the "Ice" planet type). (The newer answer doesn't combine these values).
The list comprehension iterates over the 13-bit values to create a list of weights, where the weight is the random chance if the planet type is a valid choice for the given heat value, and zero otherwise. For each planet type, `(h>>i&31)` extracts the random chance for that planet type. `(h>>i+n+1&1)` evaluates to 1 if the planet type is a valid choice for the heat value `n` and evaluates to 0 otherwise.
The library function `random.choices(choices, weights)` selects an item from the list of choices based on the list of weights.
[Answer]
# Python, ~~282 Bytes~~, 261 Bytes:
```
from random import*
i,p,l=input(),[('Gas Giant',3,11,15),("Ice",3,7,10),("Ice Giant",3,7,10),("Gaia Class",4,8,10),("Dense Atmosphere",6,10,10),("Desert",6,11,25),("Iron",6,11,14),("Lava",9,12,6)],[]
for x in p:exec"l+=x[0],;"*(x[1]<i<x[2])*x[3]
print choice(l)
```
Pretty simple - fairly sure it could be golfed more - Still looking for a better way to represent the planet range and probability data.
If i is in range of the planet type, appends it to the list according to the probability, then randomly prints one.
EDIT: With credit to Jonathan Frech - redid the for loop to knock a few bytes off. Better way of appending items to the list
[Answer]
# [Perl 5](https://www.perl.org/) (`-p`), 230 bytes
```
@a=(['Gas Giant',4,9,15],[Ice,4,6,10],['Ice Giant',4,6,10],['Gaia class',5,7,10],['Dense Atmosphere',7,9,10],[Desert,7,10,25],[Iron,7,10,14],[Lava,10,11,6]);//;map{push@b,($$_[0])x($$_[3]*($$_[1]<=$'&&$'<=$$_[2]))}@a;$_=$b[rand@b]
```
[Try it online!](https://tio.run/##Rc3RCsIwDAXQX9lDsU6ituoUmYMJwhD0C0YZmRYcaFfaKYL469ZSFZ9uTnIhWppz4lyOWb@kBdqoaFB1FGawBJ4IKLcH6TEHzjyo17/xWxbYYHQ4o7UUElh8txuprIzW3aW1@iSNpP6y/Nw20krThSZMwhPTqg/5zHOHNwzgMBdxOh6nF9QPfbWnvIY@IVXJRHwPw1QMQnKxygjt9Qj16T0RcfzMMSVVRurSoDrmtXCOs1eru6ZV1g33yYhx5ob6DQ "Perl 5 – Try It Online")
[Answer]
# [Nim](https://nim-lang.org/), ~~~~314~~ 298~~ 294 bytes
```
import random,sequtils
proc c(h:int)=
 var a= @[""]
 a.del 0
 for n in[("Gas Giant",4,9,15),("Ice",4,6,10),("Ice Giant",4,6,10),("Gaia Class",5,7,10),("Dense Atmosphere",7,9,10),("Desert",7,10,25),("Iron",7,10,14),("Lava",10,11,6)]:(if h>=n[1]and h<=n[2]:a.add repeat(n[0],n[3]))
 echo random a
```
For loop now in one line, no return, less bytes to implicit type
4 spaces removed (thanks [Kevin](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen))
[Try it online!](https://tio.run/##RZDBasMwEETv/opFJwlEsFMnoaYuLS2YQP7A@LBYGyywV66k5NCfd@3Yobedp9lZNGyHabLD6HwEj2zcoAP93KLtQzJ610Iru8JyVGUCd/SAJXzUQjQJ4M5QD2kCV@eBwXItRYUBKoschc71q84OSktxbmmRR52lm/z3PGGFFuGrxxCEPujTRr@JA8FnHFwYO/JzzGlJ3d4C@SgeXr1fD3nHG8jyBVzwjuIhM31UTSHtFbr3kuusmb8K3ds87psCd2gMeBoJo@Q6bTTXL41SCVDbua0WwGdNIfq1n54i8G2AEkb0gc4cpSc0F8skQzSW54h12f6SVEkrZ7ea8j8 "Nim – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~78~~ 76 bytes
```
”Œï²°™Ä²° Gaia classêÎ·•™Äµ‰Ÿ± Lava”#8äðýā<•ŒEŽuS,•2ô×•9èÁnÇ∞Λ•SÌ2ôεŸIå}ÏSΩè
```
[Try it online!](https://tio.run/##MzBNTDJM/f//UcPco5MOrz@06dCGRy2LDreAGAruiZmJCsk5icXFh1cd7ju0/VHDIojk1kcNG47uOLRRwSexLBGoVdni8JLDGw7vPdJoA1RzdJLr0b2lwTpAptHhLYenA2nLwysON@Ydbn/UMe/cbCA/@HAPUOrc1qM7PA8vrT3cH3xu5eEV//@bAQA "05AB1E – Try It Online\"")
**Explanation**
`”Œï²°™Ä²° Gaia classêÎ·•™Äµ‰Ÿ± Lava”`  
pushes the string `Gas Giant Ice Giant Gaia class Dense Atmosphere Ice Desert Iron Lava`
```
#                                          # split on spaces
 8ä                                        # divide into 8 parts
   ðý                                      # join each by spaces
     ā<                                    # push the range [0 ... 7]
       •ŒEŽuS,•                            # push 151010101025146
               2ô                          # split into pieces of 2
                                           # results in [15, 10, 10, 10, 10, 25, 14, 6]
                 ×                         # repeat each number in the range by these amounts
                                           # results in ['000000000000000', '1111111111', '2222222222', '3333333333', '4444444444', '5555555555555555555555555', '66666666666666', '777777']
                  •9èÁnÇ∞Λ•                # push 2724355724585889
                           S               # split to list of digits
                            Ì              # decrement each twice
                                           # results in [4,9,4,6,5,7,7,9,4,6,7,10,7,10,10,11]
                             2ô            # split into pieces of 2
                                           # results in [[4, 9], [4, 6], [5, 7], [7, 9], [4, 6], [7, 10], [7, 10], [10, 11]]
                               εŸIå}       # apply to each pair
                                Ÿ          # range [a ... b]
                                 Iå        # check if input is contained in the range
                                           # ex, for input 10: [0, 0, 0, 0, 0, 1, 1, 1]
                                    Ï      # keep only the indices which are true
                                           # ex, for input 10: ['5555555555555555555555555', '66666666666666', '777777']
                                     S     # split to list of digits
                                      Ω    # pick one at random
                                       è   # index into the list of strings with this
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~214 193~~ 189 bytes
```
->h{'Gas Giant,Desert,Iron,Lava,Ice,Ice Giant,Gaia class,Dense Atmosphere'.split(?,).zip(31006330.digits,75449887.digits,[15,25,14,6]).flat_map{|n,m,x,r|m<h-3&&x>h-3?[n]*(r||10):[]}.sample}
```
[Try it online!](https://tio.run/##NYrrqoJAFEZfxV@lsRs0tcvhVASBBL2BiOxqzAFnHGbvoos9uxWc8@NjsVifuxzufbXsx6v6OcyQvEyhYdhKko5h51oDe7wi7I7yu7@coULv2CDR52lIehvWLdlaOjkUZBvF/hoC8VDWj6MwnMZxKE7qrJhglibJYj6f/XsepTBJIUpgWgSiapBLjfbZGdBwA9fp33ocDwa31Qfr3BQj33VdFAY/efEShNo28tVbpwx7VX6WTILbUhV9@gY "Ruby – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~377~~ ~~364~~ ~~358~~ ~~318~~ ~~312~~ ~~270~~ ~~265~~ ~~262~~ ~~256~~ 251 bytes
```
import System.Random
f h|x<-[n|(n,(a,b,c))<-zip(lines"Gas Giant\nIce\nIce Giant\nGaia class\nDense Atmosphere\n
Desert\nIron\nLava")$zip3[4,4,4,5,7,7,7,10][9,6,6,7,9,10,10,11][15,10,10,10,10,25,14,6],h<=
b,h>=a,_<-[1..c]]=(x!!)<$>randomRIO(0,length x-1)
```
(I've added linebreaks for nicer printout). The task says "return", not "print", so `f` is a function which returns the randomly selected planet name into the `IO` monad, `f :: Int -> IO String`.
The `main` is `main = do {f 10 >>= print}` ([Haskell golfing tips](https://codegolf.stackexchange.com/a/107238/5021) says it doesn't count). Prints
> 
> 
> ```
> "Iron"     -- or "Desert", or "Lava"
> 
> ```
> 
> 
(edits: removed `&`'s base case; moved `main` out; changed to quadruples and `unzip`, and switched to pattern guards and `>>=` following [suggestions](https://codegolf.stackexchange.com/questions/156666/create-a-solar-system/156788?noredirect=1#comment382046_156788) [from](https://codegolf.stackexchange.com/questions/156666/create-a-solar-system/156788#comment382062_156788) [Laikoni](https://codegolf.stackexchange.com/users/56433/laikoni), thanks!; implemented the approach from the [Jelly solution](https://codegolf.stackexchange.com/a/156674/5021) instead, repeating the names; explicit type is no longer needed; another advice by Laikoni saves 3 more bytes; made it an `IO` function; implemented [advice](https://chat.stackexchange.com/transcript/message/43111195#43111195) from the chat room).
[Try it online!](https://tio.run/##NY9va4MwEIff71OkpS8MnGK2/qGgwmAghcGge6lSrjZdwswpSRhu6z67U6E8Pw6egzvuFLpP2TTDoE3XWs/ev52XJjoiXVrzcGXq1idhQbeAIEA4Q815Ev7oLmg0SbfM0bFcI/mSDrWcy91z1MjqBp0r6UWSk@zZm9Z1Slo5dZy005RtqaRX/MIlX417n4o1TGxgNyPiqtjDdmQH@9HmiKoQm7vMeRx1DdsKVJKeQWUpwmm8W0RRXVVp0C8WPFlldv7qeHgLYmgkfXjF@lDwwaCm9NKy3ysTMcuylHVWk/8b/gE "Haskell – Try It Online")
[Answer]
# Java 8, ~~398~~ 384 bytes
```
n->{String r="",a[];for(String x:"456789~Gas Giant~15;456~Ice~10;456~Ice Giant~10;567~Gaia class~10;789~Dense Atmosphere~10;78910~Desert~25;78910~Iron~14;1011~Lava~6".split(";"))if(x.split("~")[0].contains(n))r+=x+";";long t=0,u=0;for(String x:(a=r.split(";")))t+=new Long(x.split("~")[2]);t*=Math.random();for(String x:a)if((u+=new Long((a=x.split("~"))[2]))>t)return a[1];return"";}
```
It can definitely be golfed some more, but the probability in combination with the Strings isn't very easy in Java.
**Explanation:**
[Try it online.](https://tio.run/##VVJNa@MwEL33Vww6WXVjrJL0S6vAQqEU2l72GHxQHWWrrCMZadzNUqK/no4Tm01AQjPzZp5m9LTWn3riW@PWyz/7utExwqu27usCwDo0YaVrA2@9C/ALg3W/oc4Gw3FJ8R1tWhE12hrewIGCvZvMv4asoBi70otKrnwYK7cPbDq7ub27T086wpPVDpOYSYql59okUY7miJWS0inZajg02Uf68kfjooGfuPGx/TDBDHFREhJNwHQ9G/zn4F0SUylKIdILTZ1uWBHbxmLGJOPcrrLt6CfGF2VV1N4hvUXMHOchV9ucEmXjqX9U5VWnyvORMq3CKSPHXDnzF16o4pz7uuISL9Wrxo8iaLf0m4yfc@m@n6w7ISD2U44DCZ8jDwa74EAvRCWPNmNyt5dHVdruvSFVBnE@vV3ChkYaLlpUoPlR2/52EhysmkqwP5QQdOQ5P4D/4bWaSVhPJvNSwojRx/gX0WwK32HREi82LrM5ewCWu6LuTer3@FV2@28)
```
n->{                // Method with String as both parameter and return-type
  String r="",      //  Temp-String, starting empty
         a[];       //  Temp String-array
  for(String x:"456789~Gas Giant~15;456~Ice~10;456~Ice Giant~10;567~Gaia class~10;789~Dense Atmosphere~10;78910~Desert~25;78910~Iron~14;1011~Lava~6".split(";"))
                    //  Loop over the String-parts in the format "heats~type~probability"
    if(x.split("~")[0].contains(n))
                    //   If the heats contains the input
      r+=x+";";     //    Append this entire String-part to the temp-String `r`
  long t=0,u=0;     //  Temp numbers, both starting empty
  for(String x:(a=r.split(";")))
                    //  Loop over the temp-String parts:
    t+=new Long(x.split("~")[2]);
                    //   Sum their probabilities
  t*=Math.random(); //  Get a random number in the range [0,sum_of_probabilities)
  for(String x:a)   //  Loop over the temp-String parts again
    if((u+=new Long((a=x.split("~"))[2]))>t)
                    //   The moment the current probability-sum is > the random number
      return a[1];  //    Return the Type of planet
  return"";}        //  Mandatory return we won't encounter (which returns nothing)
```
[Answer]
# [Min](https://min-lang.org), ~~280~~ 277 bytes
```
:a ' =b (("Gas Giant" 4 9 15) ("Ice" 4 6 10) ("Ice Giant" 4 6 10) ("Gaia Class" 5 7 10) ("Dense Atmosphere" 7 9 10) ("Desert" 7 10 25) ("Iron" 7 10 14) ("Lava" 10 11 6)) (=n (a n 1 get >= a n 2 get <= and) ((n 0 get b append #b) n 3 get times) when) foreach b b size random get
```
Starts with heat on the stack, leaves a string on the stack. Same general process as Python 2 answer.
### Explanation
Note that min is concatenative
```
:a ' =b                               ;Set the value on the stack (heat) to a, set empty quot to b
(("Gas Giant" 4 9 15) ("Ice" 4 6 10) ("Ice Giant" 4 6 10) ("Gaia Class" 5 7 10) ("Dense Atmosphere" 7 9 10) ("Desert" 7 10 25) ("Iron" 7 10 14) ("Lava" 10 11 6)) ;Data to be iterated over
(=n                                   ;  set n to current item
 (a n 1 get >= a n 2 get <= and)      ;    check if n is between the min (2nd elment of n) and max (3rd element of n) heat
 (
  (n 0 get b append #b) n 3 get times ;      insert the name(1st element of n) into the quot of names (b) a number of times corresponding to the 4th element of n
 ) when                               ;    when the previous check is true
) foreach                             ;  for every quot in previous data
b b size random get                   ;choose a random element from the list of names
```
[Answer]
# PowerShell, 56 + 135 (CSV file) + 1 (file name) = 192 bytes
```
param($z)ipcsv a|?{$z-in$_.m..$_.x}|%{,$_.p*$_.r}|Random
```
[Try it online!](https://tio.run/##PYxdC4IwFIbv9yuGGFScpIVa3hRBIEEX0R@Igw0U3BybmPjx29dU6ObleZ9zeFX15drkvCytVahRrP1uQ7wnCGhBkxQNTQuUNYSQAIvIPeMOY2D7Cf@3WaRYIM1KNAYiOE7mxqXh9FqLyqica@5ssnjDdT3/wMGN6kouhYXkgQ3OyCD2zkgKlZmG4nDp/W5XSP8diCBw2Y7DqgcHautCj8ML5acS1trTDw "PowerShell – Try It Online") (this is a slightly modified version that creates the temporary CSV file described below)
Imports a CSV file using `ipcsv` (short for `Import-CSV`) named `a` in the local directory that contains the following:
```
P,m,x,r
Gas Giant,4,9,15
Ice,4,6,10
Ice Giant,4,6,10
Gaia class,5,7,10
Dense Atmosphere,7,9,10
Desert,7,10,25
Iron,7,10,14
Lava,10,11,6
```
That automatically creates an iterable hashtable of things like the following:
```
@{P=Gas Giant; m=4; x=9; r=15}
@{P=Ice; m=4; x=6; r=10}
...
```
We then use `Where-Object` (`?`) to pull out those entries where our input integer `$z` is `-in` the range `$_.m` to `$_.x` (i.e., it's in the heat range). We then pump those into a `Foreach-Object` loop (`%`) that creates an array of strings of names based on the random chance of those names. For example, this will create an array of `15` `"Gas Giant"` strings if that heat matches. We then put those into `Get-Random` which will pull out the appropriate string with the appropriate weighting.
]