There was an interesting conversation yesterday on the Sapiens discord, where Dave answered some questions about tulips.
majicDave Yesterday at 6:37 PM
So a tulip has 4 colors, topA, topB, botA, botB. then it has 2 mix values mixTop and mixBot. all of these values range 0-7. Hopefully someone can figure out what that adds up to
The 8 base colors, Asyc pointed out that these match up with the 8 pigment colors we have for paints & paintings:
So how many colors are there exactly?
When counting permutations we multiply the number of choices we have in each step together. So since we have 6 decisions, each with 8 possible choices, we have 8^6 or 262,144 possible colors.
majicDave Yesterday at 6:38 PM
so a mixTop of 0 gives topA, a mixTop of 7 gives topB, and somewhere in between gives somewhere in between
This means that we don’t have exactly 8^6 colors1. For mixing colors we effectively have one less choice, since (0 1) mixed with 0 is the same as (0 2) mixed with 0.
This implies we have 8^4*6^2 or 147,456 colors… but wait, some of those colors are mixed together.
This leads to the question, is (red blue) mixed with a value of 1 the same as (blue red) mixed with a value of 6?2 If they are different, then 147,456 is the correct answer. If they are the same, then we have more math to do.3
Okay, so now what? Now order doesn’t matter when choosing the two top / two bottom colors. There is certainly a way to do this with math… but I found it easier to reason about with a bit of code.
A color is defined as a 3-tuple (a, b, mix) where mix is an integer in the range
[0, 8). Two colors (a, b, c) and (d, e, f) are the same if:
a = dand
b = eand
c = f(exactly the same)
a = band
b = eand
a = e(all four colors are the same, so the mix doesn’t matter)
a = eand
b = dand
c + f = 7(mixing (blue red) with 0 is the same as mixing (red blue) with 7, also applies to other mixes adding to 7)
Thus we just need to do a triple for loop for each possible color and mix, add these all to the set, and see how many things are in the set. Since the top and bottom colors are different, there will be (number of top colors)^2 total tulip colors.
Throwing this code into a repl4, we get the final answer. There are 53,824 total tulip colors.
- There are 8^6 distinct combinations if you look at the stored data, but as a player, some are indistinguishable from each other.
- That is, is the function symmetric?
- The mix function is symmetric… so more math!
- See https://repl.it/@Bibliofile/TulipColors