Watched constants, in Python
Games need lots of magic constant value to set creature spawn rates, movement
speeds, acceleration, rates of fire, random chance, etc etc. Finding values for
all these numbers that work well is usually a lot of guesswork and good luck.
And, unless you have some very sophisticated value-tweaking engine built into
your game, a lot of recompilation and restarting as well.
I stumbled upon this neat trick on Molly Rocket
for automatically updating
hard-coded constants in source code as the game is running.
Here's my quick hacked-up version for Python:
# Name of this function
stack = traceback.extract_stack()
func_name = stack[-1]
# Pattern to locate the new value
pattern = re.compile('.*[^a-zA-Z0-9]%s\(([^\)]+)\).*' % func_name)
# Filename and line number where this function was called
filename, lineno = stack[-2][:2]
# See what that line looks like at the moment
line = list(open(filename))[lineno - 1]
match = pattern.match(line)
Import this into your code, then whenever you have some constant you're not sure
of, instead of writing:
self.x += 0.5
self.x += TWEAK(0.5)
Then run your game. The change is reflected in the game as it runs, as soon as
you save the source file. As is it won't work for values that are used to
intialise, say, a particle emitter; it can probably be improved with some clever
use of __getattribute__ and small changes to the way you write your code like
that. Another improvement that wouldn't be impossible is supporting multiple
TWEAK values on one line.
When did this become the hip new word for "conclusion"? It irks me.
"Our opponent is an alien starship packed with atomic bombs," I said.
"We have a protractor."
Apple C header licenses
Seen in the prelude of the Kernel.framework/Versions/A/Headers/IOKit/hid/*.h
"[...] APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
QUIET ENJOYMENT OR NON-INFRINGEMENT. [...]"
Not fit for quiet enjoyment? Oh, my.
What slows down development...
... Vista bluescreening every time I terminate a hung Python process that has a
lock ("Process has locked pages"). Yep, I can trigger it consistently
Makes.. me.. angry!