collusioni.st

Tricky (for Me) Math Problem

Tuesday, February 14 2006

So I’m trying to tidy up a few things with llor.nu, and one of them is my square distribution/balancer called the Square doler. It doles out new squares when needed, and it’s never been right. I’ve spent many many hours trying to figure out how to do it right, and I’ve essentially given up. I present to you, humble and mathematically smarter, humans a problem.


First, here’s what you have, for those unfamiliar with the game.


The game “board” is an infinite loop of distinct squares that needs to grow based on some kind of trigger. The trigger may not be relevant, but right now, new squares are added (if needed) when a player buys a building. Building buying happens somewhat frequently, so this is a good way of keeping things in check. But this isn’t the problem.


You also have several different square types. You have buyable squares, squares that have a building on them, convenience store squares, bank squares, and completely empty squares. A game will be setup so that at any given time, a specific percentage of each square type will exist.


So you might get a break down like 75% buyable, 15% stores, 5% empty, 5% banks. And this is where the problem begins. When a player buys a building, it changes the total square count. So, given the right amount of total squares, 75% buyable squares might turn into 74% buyable squares, which would trigger the doler to create a new buyable square or two, enough to meet the desired 75% of total squares.


So, here’s what you know at any given moment:


  • Total number of squares

  • Total number of buyable squares

  • Total number of empty squares

  • Total number of stores

  • Total number of banks

  • Total number of built squares

  • Desired percentage of buyable squares

  • Desired percentage of empty squares

  • Desired percentage of stores

  • Desired percentage of banks
  • </p>

    </ul>


    What’s not known:


    • Number of buyable squares to build, if any

    • Number of empty squares to build, if any

    • Number of stores to build, if any

    • Number of banks to build, if any
    • </p>

      </ul>


      Hopefully I’m just numb to the solution and it’s easy. Ask me question through AIM at elbowdonkey if needed.


      Update

      This is but one of the things I’m thinking about on Valentine’s day, thank you very much.


      Clarifications


      • A buyable square can only be converted to a built square. A buyable square never becomes a store, a bank, or an empty square.

      • At least one new, buyable square, should be built when a square is converted from buyable to built.

      • Percentages can be rough, obviously, since you can’t really make 0.23 of a square.

      • The growth of the board should remain constant. No snowballing.
      • </p>

        </ul>


        Ultimately the idea is to make sure that when a person rolls the dice, their odds of landing on any particular type of square remain generally equal to the desired percentages of each type. I say generally, because I understand that getting the two to align isn’t easy. But it’s fine if it sways a few percentage points from roll to roll.