The principled way to do this, I believe, is as follows:How many unique combinations of two or more of the eight Winds would there be? I think it's 247 but it's been a long time since I regularly did maths with letters in it.
First, how many combinations of the 8 Winds are there total? Each Wind is either in or out, so you're making one binary choice apiece. In total, then, you have 2^8 = 256.
Second, we want only 2+. Alright, there are 8 ways to choose 1 Wind, so 256-8=248 ways to have a combination of Winds which isn't just a single wind.
...wait, 248? Didn't we just say 247?
Third, we want 2+, not just not 1! 2^8 included having "no" for every Wind, and presumably we don't need to handle that case. (I assume. I guess there's probably some sort of default way to handle that, but we don't need to make any choices in that case, at least.) Subtracting that off, we get 248-1=247, as people have been saying for pages now.
This is looking at the number of ways to choose 8 numbers, each of which is between 2 and 8 --- that is, if you have 8 blanks and want to fill them in with numbers between 2 and 8 (in order --- all the 2s, then all the 3s, and so on), how many ways you can do this. That should be... a Stars and Bars problem with 8 stars and 8-2 = 6 bars (before the first is 2s, after that one is 3s, then 4s, etc.), for a total of 14 choose 6 = 3003 possibilities. (Also interesting question, but not the one we want here.)Edit: okay I've read Stormy's post and it checks out so now I'm going to spend the next half hour trying to figure out what this site is trying to actually tell me then.
We want to be able to handle anything which we have the winds for, which means... any case where the maximum wind's spark quantity isn't more than the total number of sparks from all the other winds. (Winds were measured in sparks, right? ...yep, that's what turn 37 uses, great.) If you just use all possible winds whenever any are available, you get down to one Wind remaining after running, but that's still leaving some around, and I assume that's not desirable. Obviously, we coudl do this if we could look at the whole thing at once, but that seems like something which isn't available to enchanting. (If we could, though, we could:
1) Find the maximum-weight Wind
2) Match up packets from that Wind with anything else, one to one, until it's all gone
3) Throw every remaining spark into the remaining packets at random.
That requires storing a lot and then dumping all at once, though, which seems somewhat wrong.)
Hmm... What if you do pick randomly? You need to find a cutoff point, then... Accumulate randomly until you hit a second spark of a wind you already have, then drop that entire packet? No packet ends up with more than 8 sparks, obviously. If one wind has a density of 1/k, you expect to need k samples to hit a second spark of that wind, which means packets started with your densest wind do accumulate the right number of other winds... but there's no chance of the long positive tail, and if you hit a double on another wind, you drop immediately, and even if you didn't you couldn't pick up that spark. We do want k other sparks when the densest wind is density 1/k, though, which makes it appealing. And you don't even need the wind to be the densest, do you? As long as you drop k sparks for each spark of a density 1/k wind, you're doing it right, though at some point you need to reset. In that case, the following procedure should pretty much sort of work, with high probability of getting close to the right answer and only looking at things locally:
1) Pick a random wind spark, noting its wind as w. (Hope it's not from a wind with much lower than 1/8 density. ...that might be a problem. Oops.)
2) Pick sparks at random until you see another spark of wind w.
3) Glomp everything you can from step 3 into one packet. If there's a wind you got two sparks from, drop one of them and look for a new spark to replace it, to keep the number of sparks correct. If you can't... uh, cry? (No, just discard this packet, that means you started with a bad wind.)
4) If you got a packet after 3, send it along! This should keep the density of wind w constant, on average.
Issue: we, uh, don't actually want to keep the density of winds constant, we want to level them out. ...oops.
Alright, take 2, this time aiming for what we actually want to do!
Our actual goal is to level out the equalize the wind counts, and keep them equal --- eventually we'd be at 0 for all of them, which is where we want to end up. In other words, every packet wants to contain the current densest wind if it can (read: with high probability). Problem: we, uh, don't know which wind is densest. And, to make this hard on ourselves, we can't just check that. We could, say, check 8 random sparks andpair up the densest wind in that no, that locks us into pairs. ...Well, we can work with that, I guess? No, this is still just the previous thing but averaging over 8 rather than taking the best of 1...
Wait, we totally can take a maximum. Each wind repels all the other winds, so if you have a spark of each wind, the two which are least repelled from the average of the foundation are the ones you want. Have a blob of winds in the center of the foundation proportional to the total amount of each wind, then drop one of each spark in their own vertical tubes off the blob (and orthogonal to it or something). Whichever pair of sparks is highest up (or lowest down) get paired off and sent, then replace the sparks and repeat the process. If more than two sparks are close enough (within whatever wiggle room you give them), fine, make a packet with more than two. After sending that packet, replace the sent sparks and repeat. Each time, you should send off the maximum pair, possibly plus other sparks if the maximum and the third-to-max are close. That pushes the max down every time, sends a roughly even set if everything's pretty much balanced, and shouldn't be jumping the tech tree at all, right? ...and it needs a decently strong conductor for each wind in each waystone, but the capstones were including that anyway, and we don't need the mutual exclusivity for these that we did for the capstone. Does that work? I feel like that works, at least well enough for me to give up on trying to find a clever algorithmic solution. Still seems like one might exist, but trying to over-select the most dense wind is a headache probabilistically.
1) Find the maximum-weight Wind
2) Match up packets from that Wind with anything else, one to one, until it's all gone
3) Throw every remaining spark into the remaining packets at random.
That requires storing a lot and then dumping all at once, though, which seems somewhat wrong.)
Hmm... What if you do pick randomly? You need to find a cutoff point, then... Accumulate randomly until you hit a second spark of a wind you already have, then drop that entire packet? No packet ends up with more than 8 sparks, obviously. If one wind has a density of 1/k, you expect to need k samples to hit a second spark of that wind, which means packets started with your densest wind do accumulate the right number of other winds... but there's no chance of the long positive tail, and if you hit a double on another wind, you drop immediately, and even if you didn't you couldn't pick up that spark. We do want k other sparks when the densest wind is density 1/k, though, which makes it appealing. And you don't even need the wind to be the densest, do you? As long as you drop k sparks for each spark of a density 1/k wind, you're doing it right, though at some point you need to reset. In that case, the following procedure should pretty much sort of work, with high probability of getting close to the right answer and only looking at things locally:
1) Pick a random wind spark, noting its wind as w. (Hope it's not from a wind with much lower than 1/8 density. ...that might be a problem. Oops.)
2) Pick sparks at random until you see another spark of wind w.
3) Glomp everything you can from step 3 into one packet. If there's a wind you got two sparks from, drop one of them and look for a new spark to replace it, to keep the number of sparks correct. If you can't... uh, cry? (No, just discard this packet, that means you started with a bad wind.)
4) If you got a packet after 3, send it along! This should keep the density of wind w constant, on average.
Issue: we, uh, don't actually want to keep the density of winds constant, we want to level them out. ...oops.
Alright, take 2, this time aiming for what we actually want to do!
Our actual goal is to level out the equalize the wind counts, and keep them equal --- eventually we'd be at 0 for all of them, which is where we want to end up. In other words, every packet wants to contain the current densest wind if it can (read: with high probability). Problem: we, uh, don't know which wind is densest. And, to make this hard on ourselves, we can't just check that. We could, say, check 8 random sparks and
Wait, we totally can take a maximum. Each wind repels all the other winds, so if you have a spark of each wind, the two which are least repelled from the average of the foundation are the ones you want. Have a blob of winds in the center of the foundation proportional to the total amount of each wind, then drop one of each spark in their own vertical tubes off the blob (and orthogonal to it or something). Whichever pair of sparks is highest up (or lowest down) get paired off and sent, then replace the sparks and repeat the process. If more than two sparks are close enough (within whatever wiggle room you give them), fine, make a packet with more than two. After sending that packet, replace the sent sparks and repeat. Each time, you should send off the maximum pair, possibly plus other sparks if the maximum and the third-to-max are close. That pushes the max down every time, sends a roughly even set if everything's pretty much balanced, and shouldn't be jumping the tech tree at all, right? ...and it needs a decently strong conductor for each wind in each waystone, but the capstones were including that anyway, and we don't need the mutual exclusivity for these that we did for the capstone. Does that work? I feel like that works, at least well enough for me to give up on trying to find a clever algorithmic solution. Still seems like one might exist, but trying to over-select the most dense wind is a headache probabilistically.