Math, Testing, More Math, and Getting Useful Data

So I had a bit of a brainstorm for how to make my randomized puzzles and decided to use a new method. But then I started to wonder how the distribution of moves on the play area would be. Would they clump in one spot? Would they clump according to some rule or at random? Or would I get a good spread? This is a bit of how I figured that out.

I have already been using the debug log for lots of data gathering but unfortunately with a sample size of 800-80,000 or more the Log system in Unity is simply not robust enough for my purposes (Turns out latter it could have been but I still prefer the way I ended up using). Namely I needed a better find function that could tell my: “how many toggles in this column/row” or “how many toggles for this specific button”. So I had the output placed in a txt file before copy pasting that into a Word file and putting the data in an Excel file for ease of viewing. After doing this once (for a sample size of 100 puzzle generations) I figured I could do more of the work in the programming. I then had a txt file with the toggles for the specific buttons. But I realized fairly quickly that this data, while helpful, was a bit hard to understand. So I made it instead output the average number of toggles per puzzle over the 10,000 simulated puzzles. And since this new method allowed me to control exactly the number of toggles per puzzle I could figure out the number of average button presses per button if it were an ideally even spread. This was better but still a bit hard to read. Then I finally figured out what I was looking for was who far off the ideal average the actual averages were. so once I started to also output the deviation I saw the pattern clearly. And yep, as I feared it was clumping in almost the exact place I thought it would. Time to tweak some more numbers and see if I can smooth it out.

Random Number Programming and Magic the Gathering

I have been making progress on my Lights out game, coming up with new ideas, scaling back old ideas, putting some things to the side for latter, completely changing the user interface, and generally pulling my hair out at things that should “just work” seam to work on my machine and then just… don’t. So programming in a nutshell.

Now, what is that title about and how does it relate to my game?

Well for my game I have a section that generates random puzzles. As you can imagine this utilizes a random number generator, but it also uses a bunch of seed numbers (random between X and Y, target number, etc.) and I just recently realized a few mistakes I made when deciding these seed numbers. The most recent discovery was that for difficulty I was messing with entirely the wrong number and needed to change a different seed number to get the results I wanted, but more importantly I figured out that I was using the wrong scale of numbers. I had been using numbers in the 5-12 range and figured out I needed to use numbers in the 200-300 range. Why? Well lets get to one of the oldest design problems of Magic the Gathering to illustrate the problem.

In Magic both players start with 20 life, can generally generate one mana per turn of the game (dependent on deck and draw this can go way up or down but I digress), and start with 7 cards drawing one per turn by default. Those are the basic resources a player has to work with. In the first set of Magic they printed a card called Lightning Bolt, it cost one mana and dealt 3 damage to anything… and is widely considered one of the strongest direct damage cards in the game even 27 years latter with  about 4 sets per year. Latter they printed the card Shock, It was exactly like Lightning Bolt except it dealt 2 damage instead. Shock is considered a mediocre card, useful sometimes but your not excited to play with it. So why the giant disparity between reactions with the difference of 1 damage? Well the designers have said the ideal one mana direct damage spell would deal 2.5 damage, but they can only deal with whole numbers so it is either 2 damage or 3 damage. But imagine a world where all damage and life numbers were doubled. suddenly Lightning Bolt deals 6, Shock deals 4, and a new card could deal the new ideal of 5 damage. But because the resources they have to work with were set in stone 27 years ago they can’t actually tweak any of those numbers. Starting to see how this loops back?

By at first dealing with small numbers the number of changes I could make to the system was highly limited. But by dealing with giant numbers I can make much smaller changes for more precise control. Ironically Larger numbers allow for smaller changes.

This is a lesson I keep relearning, but as long as I don’t set things in stone and catch myself early enough I can afford to keep relearning it.