Archive for April, 2009
General news and status
Frankly, I’m bored. Really bored. I’m just kind of wasting time till I have to start my GSoC job, which I’m tempted to start early.
I made some changes to the settings recently, one of which was to require users to register before being able to post. I realize now that my email settings don’t work and I don’t know why. So if you registered to post, I apologize for the screw up there. I’ve removed that requirement now.
Now, what I have been doing is working on the combat mechanics for a roleplay MUD me and my friend are writing. She’s the creative expert, I’m the programmer and mathematician, and we work cooperatively on the design issues. Because we’re both very strong Explorer-type players, there’s going to be a lot of depth, from the combat system, to the varied races, to the continent and city you can explore. Plenty of in-character jobs; craft-your-own-spell magic system; trainable, breedable, raiseable animal pets/mounts/combat partners; learning and migrating NPC and animal mobs; and a complex ecology are just a few of the massively in-depth systems we plan to implement.
You know what I’ve learned? Writing equations and formulas for combat mechanics is HARD, and frustrating. You have to balance the initial character growth, against late-game character growth, and because me and my friend both hate combat being just a matter of whose stats are higher, I have to factor that in as well into the formulas. The damage equation is particularly tough, because with our design and playability goals, we want to avoid even the highest level character being able to OHKO noobs every time. One particular thing I’ve learned is that when you have four variables, and you end up multiplying them together, amidst divisions and additions, you have quickly exponential values. However, when there are just 3 variables, it is very easy to make it a linear growth equation. Anyone know why, or is my math-fu still weak?
2 commentsPython Tricks: Advanced String Formatting
I ran across this a long time ago, never really used it till more recently, but it really shows the power and capability of Python.
So, say you have a big set of local variables which need to go into the string you are building, say for a YAPWF(Yet Another Python Web Framework).
Thats means you have this messy looking code:
s="%d%f" % (car, calc)
Its messy, because you’ve separated contextual information from the actual place that it matters, and if the string is very long and confusing, it gets messy, and opens you up to errors down the road. In addition, you are tied to having those variables exist locally.
However, there is a much, much nicer way to do this.
d={"number":100, "float":4.2, "status":"okay", "ph":8665782} s="%(number)d%(float)f%(status)s%(ph)d" % d print s 1004.2okay8665782
What this means is now you can throw in each of the relevant possible variables into the key that matters into a single dictionary object, and pass that around easily. The only thing you’re tied to now are the keys of the dictionary, giving you a bit of Adapter action.
Just one note, the format goes like this:
"%({key name}){format modifier}" % dictionary
As well, you can name the keys relevant names, like status, phone, etc, and your string formatting becomes a lot easier to read.
Comments are off for this postSummer of Code: Start!
So, I have been selected to work for the Google Summer of Code event, through Pygame/Python.
My project, while simple, will be a lot of fun. I will be wrapping ffmpeg for use as a movie module within Pygame. Ideally, the movie module will be usable outside of pygame. It’ll be a lot of work, 40 hours a week minimum, for three months, but it’ll be so much fun!
I’ll be using this blog to post regular updates on the progress of the code, alpha and beta releases, as well as calls for api suggestions.
1 commentConclusion of Herding Cats
So, it is Wednesday now. The two group projects are now done. The results are kind of interesting.
The game project was fun, if exhausting. Some unfortunate problems though. One member was just way too inexperienced. So it was like there was only two people in our team. He tried! He very definitely tried. But he needed to communicate his skills better. But even with his strengths, it still took far too much time. But nevertheless, we have mostly finished the game.
Its a spiritual descendant of metal gear solid, but because we have no capability to make our own art resources, we had to use the provided stock resources that comes with the Neverwinter Nights Aurora toolset, all medieval. So… a medieval gear solid. Its okay. It definitely has its bugs. It has some limitations. It is possible to circumvent 40 or so minutes of effort, and finish the game quickly, thereby missing 90% of the story.
I hate putting out something that has bugs. I absolutely hate it. One more week, and we could fix these issues. Just one. If we had worked harder in the beginning, we’d be much farther along. But the amount of work required is a lot. Games require a lot of work, and most of it is spent on aesthetic issues. Crafting items, making a good level, balancing monsters, these all take a lot of time and sweat and blood and effort.
Everyone’s game had something different that really differentiated them. We had our absolutely awesome, five minute cut-scene created by Josh. One team had a neat branching story, another had a real intro cutscene and had voice overs. And the last group had the best humor and entertainment factor.
The AI project, I think, was where the real fun was. (Quick background: We had to do it in Java and play the Game of Amazons) Despite the fact we lost a team member for 13 days, and he lost all his code, we… won the AI tournament this week. The tourny was only within the class, but we won. We worked like dogs for 4-5 days, lots of editing, and dealing with suicide, but our overall score was 4 wins, 2 losses. Our AI initially was at times suicidal, in that it would make, very rarely, a move that kills itself. So we had to rush today to find out why it was killing itself. And the fix turns out to be a missing set of five lines that did not set the initial conditions properly. For most of the time, the move generators would work properly, but sometimes when a queen was at the top of the board, it would fail early, and not generate all the moves.
Finding the bug was an odyssey in itself.
Our first clue was the observation that the move generators were only generating 1632 moves compared to the 2175 opening moves of Amazons. Obviously something was wrong. We quickly whipped up a comparison of a working generator, which generates all the moves at once, versus the defective generators, which generate a move one at a time(significantly less memory overhead, and with pruning game trees, this results in a significant runtime reduction. The proof is left to the reader.)
So we wait till the 1632nd move, and see why the generator fails at this point. And lo and behold, it was a missing set of initialization lines, so the conditionals in the subsequent loops were subtly wrong. So much effort to find the error, and such a simple cause. We fixed it, and the generators worked properly.
In addition, during other classes this morning, I found a way to make our heuristic function significantly faster, by breaking up a bunch of big loops, so that they were much smaller, and some loops would be executed less. This allowed us to evaluate on average at the start of the game 10% more nodes, which is a huge number! With these two modifications, our next four games turned out startlingly well, all of them victories. We crushed the opposition. Our only two losses were while the program was still suicidal. So… we rule.
Links:
- You will need Neverwinter Nights patched to 1.69
- Unfortunately, it needs a couple of packages to work properly. One of those is the nanoxml package. Use Google. The other is one specifically for our course, and the only file that needs that is Network.java. Otherwise, it should work well.
Further Tales of Herding Cats
So I’ve got a little story here.
Two team members, one in math, one in engineering. We’re in a rush, because we lost almost two weeks worth of possible effort when one person got sick, and his computer had issues during the same period. We have to participate in the AI tournament on Monday. MONDAY. That is four days from the day I make this post. Pretty stressful.
One team member however seems to be not enjoying her role in the team. Because of the crimp in our plans, I was trying to shrink our plans, and re-check what we all wanted/had to do. Immediately, she fires back, “Well, wait, what did I miss here?”
“Nothing. Just going over what we need to do.”
Basically, she wanted to stick rigidly back with what we’d divided our jobs up as, over two weeks ago.
But this isn’t a story to complain about recalcitrant team members.
My point here is I was trying to adjust, adapt to a bad emergency. I didn’t communicate my goals well enough, and I’m fairly certain she’s upset with us. But we have four days left, so the really hard question is do I try to fix things? The team is going apart, and I likely won’t work with her again. Should I make her happy, despite the limited amount of time left? For different people, this answer will vary greatly, and it all depends on your personal perspective. Theres a good chance we won’t work together again, so that isn’t a worry, but having someone upset at us, for good or bad reasons is still something to be aware of.
Or, do I just learn a lesson from this ill-fated team on how to handle people, and apply it in the future?
Comments are off for this post