Scaling information unit size

Let say I have 15 bits to use and I want to send only pings

How would I implement 1 line of code that would deploy as many pings as I can afford

The simplest way I’ve found:

while game_state.can_spawn(PING, [0, 13]):
    game_state.attempt_spawn(PING, [0, 13])
1 Like

There is another simple way:

count = game_state.number_affordable(PING)
if game_state.can_spawn(PING, [0, 13], count):
game_state.attempt_spawn(PING, [0, 13], count)

That’s a good point. And if you weren’t concerned with raising warnings (they can be suppressed), you could combine that to become:

game_state.attempt_spawn(PING, [0, 13], game_state.number_affordable(PING))

Edit: It’s worth mentioning that warnings would only be raised if your assumptions were wrong, such as having zero bits to spend.

game_state.py shows the validation it does that could raise a warning.