Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I'm obsessed. I admit it. I play pinball like a madman. hours and hours a day of it; I never stop. Sometimes, when I go away from the chatterbox and miss stuff, it's because I'm playing a game or two. More often, it's five or six. But the other day I reached a new low: I stopped playing. I made perl do it for me. To explain a little better, I own a pinball machine (Medieval Madness, Williams 1997), so I really do play an insane amount of pinball. And I've gotten fairly high scores; but not every game is a new high; not every game is exciting. So i wanted to come up with a meta-game to play over the course of many pinball games. originally, it started as just "how long can i keep getting a better score than i did the previous game?" -- but monotonic increase does not encourage playing to the best of ones ability (because a really good game can break a streak early), and i didn't like that. So I came up with a few other ideas, and i wanted to test them out -- but they'd take hundreds of games to see if they were fair and interesting. Which is, finally, where perl comes in. first, i needed to model a single game of pinball. now, my top score is 178 million, and some games come in as low as (approximately) 178 thousand, but it's not a linear scale; the average is not 89 million, or even 17.8 million, but about 10 million. and, of course, i'v emade 178 million my top score in under 2000 games; given 10000 or 100k games, there's no hard upper limit. so just using rand() was right out of the question. on the other hand, i didn't want to map out every switch on the table and figure out probabilities for everything. so a model is in order. it turns out that the score increases faster thee longer you play, with a few large jumps which also get bigger as you go. i poked and tweaked, and here is what i ended up with:
a simple "run this a million times and tell me the average" eventually revealed that it was doing pretty much what i wanted. so i wrote a few meta-games, and ended up with this as my basic game:
i usually play meta(score+score, 10, 0); .Clarification: this isn't a whole program, this is just a couple subs. if you want to see what it's doing, you need a wrapper of some sort. this one will play the meta-game as i currently play it on my real machine, and tell you some stuff: of course, if you really want to see what's going on, you can add prints into the game and meta subroutines. . In reply to Virtually Pinball by Vynce
|
|