I made a fair bit of progress on the boxing game today and implemented a major change that should make for a better built program. In short: I switched opponent behavior from a threaded timer-based system over too one which uses the WX Timer object. In long:

                When I first started designing the game, I built a system which queued up all of a round’s behaviors at one time. Each of the punches, taunts, and unblocks basically received their own alarm, and when that alarm went off, the event attached to it was triggered. While the program ran smoothly  enough, it always gave me a huge number of trace backs—or errors—every time I prematurely shut it down. Each of the separate alarms was known as a thread, and when the program was closed, any threads that hadn’t yet been executed were cut, resulting in an error message for each one. I’m not certain if this really did anything bad, but it sure looked disconcerting when it happened.

                Partially because of this, I switched the program over to a new system today. Using a module called WX, I built in support for a single recurring timer that will handle all of my event management rather than placing the responsibility on dozens—sometimes hundreds—of separate timers. This single timer runs every tenth of a second, and when it runs it makes various checks to determine whether it should throw a punch, taunt the player, adjust fatigue and health, end the round, and a whole host of other functions.

                The second benefit to this new system is that it allows for on-the-fly changes to be made, including the aforementioned behavior system that people asked for. Because all behaviors aren’t laid out at the beginning of the round, they can be changed as needed.

                In order to really test things, though, I need to go back to the opponent creator and start building in support for the new system. In fact, I think I’ll start that now.


                I guess I always knew somewhere deep down that there were going to be down sides to programming, but of late they’ve been cropping up in some very unexpected places. I expected to have to face some of the legendary heckling and complaining that almost all developers have encountered, but the community has been blessedly understanding and kind about the whole thing.

                Perhaps I’d better back up a bit here. A few weeks ago I received an email on the Audyssey list from a user who told me that Block Party wouldn’t run on his system and that he was getting error X. Having no idea what error X involved, I put out feelers, and I was told to put a specific line of code into the main module that would fix everything. I placed the line of code where I was told and uploaded the new executable to the site.

                I then went back to work on the boxing game, building in support for multiple punch types and perfecting existing sounds, only to discover that my current keyboard code didn’t support things like holding down keys. If I wanted to press up and A at the same time to throw a left hook, I could, but I couldn’t hold up and tap A at some future point and achieve the same result. Some people might argue that it makes no difference, but for some reason, the lack of being able to hold keys feels awkward to me, and I’d like to be able to fix it.

                So I started working on a solution. I went out and started researching Pygame, a Python library specifically designed for game development. (Some of you may recognize Pygame as the library used to code Sound RTS.) I figured if I imported the Pygame keyboard module, I could build in support for a lot of the keyboard-based stuff I really wanted. There’s also the added bonus that Pygame supports mice and joysticks as well. But just as I started my research, life started happening.

                First came the emails from the Audyssey list telling me that the new version of Block Party wouldn’t run on 64-bit Windows 7. I have to pause here to point out that the emails I have received thus far have been extremely cordial, and I cannot stress enough how much I appreciate that. After the emails, though, came a mountain of work at my job, and after that came some previously-made engagements which have taken up a significant chunk of my time.

                Today I finally had time to sit down and research the problem, and I came to the conclusion that I needed to roll back to the previous version and find another solution to the problem, only to receive more kind emails from people telling me that They—the emails’ authors—could now happily run Block Party’s latest version on their computers. Argh! Now I have to trouble-shoot Windows 7 64-bit!

                The most interesting and awesome thing about this whole ordeal is the response I have received from the blind gaming community. As I wrote earlier, I have received no negative emails about Block Party’s refusal to play nice with everyone’s computers. Especially given some of the epic flare-ups which have previously occurred on the Audyssey list, I was expecting to have to dawn my ceramic suit and dive for cover to escape the flaming. Instead, everyone has been very understanding and patient with me as I research and learn in an attempt to solve the problem.

                Which is probably why I feel so bad.

                You all have been waiting for months for the boxing game—almost as long as I have. I have been giving out teasers and snippets from time to time and writing about my progress in various forums, but real, tangible results of this project have not been forthcoming. I know deep down that there will be setbacks; I’ve written about them in a previous post or two, but I hate that they’re occurring at all. More than anything I want to finish this game and release it to the general public, but for some reason things just keep coming up. Maybe this is all a bit melodramatic, and maybe I’m just on edge after the whole Qwitter thing, but I keep feeling like there’s a clock hanging over my head, and when it strikes, there goes my credibility. The funny thing is: it’s not you; it’s me.

                Holy crap. I have to stop writing now before something even more cheesy comes out of my keyboard: “maybe we should just be friends.”

                Anyhow, thanks for letting me get that off my chest, and thanks for being so awesome about the whole thing. I promise I’ll make the end result worth it, and we’ll all have a lot of fun.

A Worthy Challenge

                When you start out programming, people tell you it’s a good idea to start with something small. It’s why almost all program tutorials start you out with printing “Hello world!” to the screen. In the case of games they tell you to produce Guess the Number or a Space Invaders clone or something equally unsatisfying from a gamer’s prospective. But in spite of this good advice, the starry-eyed gamers want to produce something exciting, something revolutionary, and they either wind up failing or producing something ugly. I’m a big believer that you only truly fail when you give up, so I don’t believe I have failed to produce a great game. I do think, though, that the current incarnation of boxing is pretty unattractive.

                A big part of the reason behind this ugliness is that I started with an extremely limited skillset. I could only conceptualize how to produce the kinds of things I wanted with some very limited tools, and my code and design reflect this fact. It’s why I’ve been writing on the Twitter feed recently about how I’ve been going back through all of my modules and stripping out/refactoring a lot of the detritus that has collected there.

                But as my knowledge has been evolving, so has my vision for the direction I’d like to take the boxing game in, spurred on in no small part thanks to some bona-fide geniuses on the Python tutor list. When I look at their code examples, their suggestions for different work-arounds, their ideas for alternative—and better implementation—I realize that I’ve only been scratching the surface of what this game is truly capable of. I don’t, for example, have to stop at four basic punches, especially when boxing offers a whole host of new ones. I don’t have to limit the game to blocking and not blocking when I can easily build in slipping, bobbing and weaving, stepping in, and so much more. Did you know that a classic boxing combination is to throw an uppercut with the power hand, then follow it up with a devastating hook with the other hand? Apparently the first punch lifts the jaw into prime position, and the follow-up punch lays the opponent out. I didn’t know that before yesterday, but now that I do, I want to build it in! Now that I have more tools at my disposal, I can do that—and what’s more, I can do it with relative ease.

                This probably comes as a bit of a disappointment to people who were hoping I would release the game yesterday, but I promise that the mechanic change will make the game a lot more fun for all involved. Instead of just mashing a particular button repeatedly and getting away with it, players will have to make strategic decisions and play off of their opponents. They’ll have to learn which punches to lead with and when to throw a proper combination, and the opponent will be learning right back. If they throw the old one-two too many times, the opponent will start to anticipate it.

                While I think future players will really appreciate these changes, I’m also making them for my own sake. Nothing is more frustrating than spending lots of time on a project that is no longer of interest, and I don’t want to become frustrated with the boxing game. I want this to be an exciting journey for all involved, but since I’m steering the ship right now, I need to make sure I don’t fall asleep at the wheel. Thankfully, we’re bound for Tahiti.

                And I’d better stop with the nautical metaphors.

                Oh hey—random thing: Did you know that coffee gives you super powers? No, really. I use it all the time when coding to help me stay strong. In fact, I might go have some right now!

Rewriting the Future

                One of the biggest stumbling blocks I tripped over when the boxing game came to a screeching halt was the opponent creator. I know people are really excited about that feature; I am too. When I tried to conceptualize a system, though, I found that it kept getting progressively bigger and uglier, and after a while I didn’t even want to deal with it.

                The problem, I think, lay in the design of the program. When I conceptualized the opponent creator, I had a continuous timeline in mind. Users would jump into the timeline, place their events, tweak everything so that it was just the way they wanted, save the character, and share it with whomever they chose. I quickly found, though, that people didn’t like this approach. They wanted to be able to create their own combos, build in AI, and perform lots of other functions that I had never even considered. Many of these ideas were good ones, and I thought it would be fun to implement them. In trying to do so atop my existing code, however, I created a Frankenstein mess that quickly became untenable. I had built the system for single events, not combos or AI or anything of the sort, so the system couldn’t easily handle the new suggestions.

                So I’ve decided to do a bit of a rewrite, and it’s going to require messing with some of the existing engine. Here’s what I’m changing and what you can expect.

                The current setup provides for two opponent conditions: blocking and not blocking. (Eloquent, I know.) When the opponent is blocking, you can’t hit him; when he’s not, you can. Sounds complicated, right? Well … kind of, yeah. One of the things people asked for was the ability to create different opponent behaviors depending on how well or poorly the opponent is doing. If the opponent is winning, perhaps he’d like to go in for the knockout. If he’s losing, he might put up his guard, and therein lies the problem. If the opponent blocking means he can’t be hit, then when the opponent goes on the defense, he is nearly invincible. Using the current system, the only way to avoid this problem would be to have the opponent come out from behind his guard to throw punches from time to time, a behavior that would be at odds with his defensive nature.

                In the current system there are three ways to land a punch on an opponent:

  1. Hit him while he’s swinging at you.
  2. Hit him after you dodge one of his punches.
  3. Wait for him to drop his block, then sneak in a few punches. (more on this later)

All of the above factors conspire to create a game where the player is completely dependent on the opponent for his or her openings, which ostensibly makes this game a rich, detailed Bop It. Not cool!

                The other issue that currently exists is one of stamina. Like the original Punch-Out! from which this game draws much of its inspiration, I had programmed the player so that he would lose fatigue for punching at a blocking opponent, but he would not lose any fatigue for landing a successful hit. Why? When I look back on this setup, it doesn’t really make sense. You can get just as tired hammering nails as you can from swinging a hammer at nothing, so why do you not lose stamina for successfully landing a punch? If I wanted to fix blocking, I realized, I needed to fix this too.

                After banging my head against these issues for a while, I finally decided that the root of the problem lay in the opponents’ ability to become instantly invincible. If the opponent couldn’t block every single punch thrown at him, I reasoned, he could start adapting to different emotional situations without the unfair advantage of becoming a walking tank. With this in mind, and drawing inspiration from many of the mainstream games of today, I’ve started working on high and low blocks as an alternative. If an opponent is blocking high, he can still be hit low. The reverse is true if the opponent is blocking low. This will enable players and opponents alike to adjust play styles depending on how aggressive or defensive they are at any given moment.

                But then comes the issue of stamina. Since it’s now possible to land many more punches, there needs to be a check in place that will keep the player from simply unleashing a torrent of key presses and battering the opponent into the ground. Thus, the new system will subtract stamina for both successful and unsuccessful hits, meaning that it won’t be advantageous to just slug away …

                Or will it?

                That’s all going to depend on the third major facet currently in the planning stages, statistics. Perhaps you’d like to be a bruiser with a take no prisoners attitude. Or maybe you’d rather be a calculating, careful fighter, using your mind and your reflexes to solve the sweet science. Perhaps you’re just a glutton for punishment and can’t avoid getting punched in the face to save your life—or at least your career. With customizable stats in place, all of these should be possible.

                My current plan is to have four trainable stats: strength, speed, stamina, and vitality. The player will have the ability to train a few stats at the start of the game, and will gain additional points for participating in fights. This means that if you find yourself getting too tired during fights, you can use your training to improve your stamina in order to stay on your feet longer. If you know the next opponent is going to dish out some serious damage, you might consider dropping a few points into your vitality as a precautionary measure.

                Finally, there’s the opponent creator I mentioned at the top of the post. People want combos, and they want the ability to create situation-based events. I want to give them these things, so here’s what I have in mind.

                Instead of having a timeline to cover the entirety of the match, complete with too much scripting, opponents’ behavior will be based solely on combos. The game will choose from a set list of combos depending on the current situation—offensive, defensive, normal, etc.—and one will be chosen and executed. The nice part of this system is that it can create as much or as little complexity as the creator chooses. If you want to create a completely predictable opponent, only design a few combos for each situation. If you want someone harder to predict, you can design dozens—even hundreds—of combos, and the game will just choose from a larger set. Combine this with the already-existing ability to create punches of random height and side, and you have an extremely flexible system.

                Many of these features are still in the design phase, but I firmly believe that, once implemented, they will combine to create a much richer, more satisfying game with greater replay value. By giving people a more detailed fighting system and a thorough opponent creation utility, I hope I can create something that many of you will be excited to play.

                Before I can make any of this happen, though, I need to look through the old code, find out what needs to be kept and what needs to be scrapped, and make the necessary changes to the underlying infrastructure. It’s going to take a lot of refactoring, a lot of proofreading, and a lot of coding. I know. I’m excited too!

The Art of Improv

                This is just a quick note to let everyone know that the official Grey Matter Productions website is still coming, albeit in a few days instead of … yesterday. Both Randi and I are working a lot at the moment, and since Randi is my head web developer—okay only web developer—we haven’t been able to make the progress we would like. On the other hand, though, we are making money and paying off bills, and that’s never a bad thing.

                In the meantime, thanks to everyone who has downloaded Block Party so far. Your support and kind words mean a lot to both of us. I appreciate the outpouring of kind emails and positive feedback the game has garnered so far, and I’m already hard at work finishing the boxing title as a nice, juicy follow-up.

Thanks for putting up with our duct tape and string. We’ll be putting in a more elegant solution shortly.

Block Party 1.0

                Block Party is here! It’s been four weeks, and there have been a few setbacks, but the game is finally released. Block Party is a strategic puzzle game which will challenge your mind to develop complex strategies as you work to break your previous high score.

In previous posts I referred to the game as Jawbreaker, borrowing from the Windows Mobile game of the same name, but it occurred to me as I developed the game that since we’re working in an audio environment, the playing pieces look and sound nothing like spherical candies. They remind me more of blocks: marble, stone, wood, etc. Thus, Block Party.

I’ll tell the story later. For now, you’re probably looking for the download link.

Enjoy, and thanks for playing!

An Overdue Update

                I had planned to write a long, whiny-yet-justified post about how life has been so busy these past few weeks, but my being busy has kept me from that. I had thought to write about the Minnesota state government shut-down and the work we at BLIND Inc. have had to do to prepare for it, about the work involved in getting ready for convention, about recording an audio version of a textbook, and about my general lack of programming time, but I decided not to. In fact this post will not contain references to any of those things.

                Woops …

                Instead, let’s talk about something happy; let’s talk about Jawbreaker.

For those of you who own or have owned a Pac-Mate, you may be familiar with Jawbreaker. It’s a grid-based puzzle game that can be made “accessible” by labeling the graphics which make up the playing squares. The problem, though, is that for some reason the Pac-Mate liked to introduce random numbers and elements that you the labeler never implemented, and it liked to introduce random spacing that you the player had trouble understanding. In a game with pieces labeled “1” to “5,” it was rather jarring and off-putting to encounter a “6” or a “0” among the squares. Likewise it was confusing to scroll up and down through the lines and find that column 8 was on the right side of the Braille display on one line and in the middle on the next. More often than not I would simply tap the pieces randomly just to pop a few bubbles and see how high a score I could get, and I used the game mainly to keep myself awake.

Last Sunday, after finishing the bulk of my work, I sat down to the boxing game again, only to discover that the problem I was having trouble with when I had to put the game on hold was far too difficult to solve after over two weeks away from coding. As a result, I decided to tackle a quick, simple project to reactivate my brain cells. That project was programming an interactive Spy vs. Spy comic strip. No. Wait. It wasn’t.

                I had two other reasons for wanting to code Jawbreaker: First, I wanted to play a version that wasn’t all screwed up and barely accessible. Second, and more importantly, I wanted to pick up a project that I had envisioned, conceptualize it through from start to finish, and hammer it out as quickly as possible just because I could. I started working on Jawbreaker last Sunday morning, and as of midnight today, the game is nearly complete. All I have left to do is create a few sounds, implement a starting menu, and build in a high score system. After that I’ll be done.

                Before I can complete those things, however, I’ll be attending the NFB convention from July 2 through 9. As might be expected, the time I’ll be able to spend programming my games will be nearly non-existent, and I own no laptop besides. I had pondered releasing the game, warts and all, before I left, but the thought of throwing an untested project to the wolves and not being there to answer questions or make bug fixes stayed my hand. You will be happy to note, though, that the game will be completed likely within a week of my return. I have two days off when I get home, and I intend to make full use of them.

                And—oh yeah—since the concept, idea, and even the title of the game aren’t mine, I can’t very well charge for Jawbreaker, so after I get back, everyone will have a fun, addictive, and—above all—free game to play.

                See you in a week!

Changing the Rules

                Years ago I used to run around the neighborhood with the local kids and play some variant of “guns:” cowboys and Indians (we weren’t racially sensitive), cops and robbers, spacemen versus other spacemen. Even though most of us were on board, there was always that one kid who just had to bend the rules a bit.

                “Hey,” you’d yell, blowing imaginary smoke off the barrel of your plastic revolver. “I shot you!”

                “Nuh-uh,” he would always return. “I was wearing a bullet proof vest.”

                I understand now, after a hasty Wikipedia search, that bulletproof armor did in fact exist during the 19th century—at least as far as Wikipedia claims. According to the article, it existed some 300 years before the Civil War. But as kids, we and the bulletproof wannabe thought of ballistic vests in the more widely recognized, modern sense. As far as we were concerned, he was cheating, arbitrarily changing the rules when the game was already in progress.

                I always look back on my body armor memories and smirk when something completely new and unexpected comes along to shake things up. (By the way, My Body Armor Memories would make a great band name. Feel free to use it.) In the case of programming that game-changer was decimal numbers, referred to in computer parlance as floating point numbers. As far as your computer is concerned, writing floating point numbers is hard. The mechanics of why this is the case are a bit obnoxious, but suffice it to say that when you see 0.1 on your computer screen, the computer isn’t thinking of the same number. If I assign the number 0.1 to the letter x, then tell Python to print x, I’ll get a nice, pretty 0.1. If I tell it to print 0.1 to 25 decimal places, though, I get 0.1000000000000000055511151. This difference of numbers can cause major trouble in coding if you’re not aware of it, and just like my cheating neighbor, it caught me completely off guard.

                In trying to program the opponent creator, I designed a system that checks the time an event is scheduled to occur against the user’s current time. If the two numbers match, a sound is played, and the user can edit events. When I tried to move a tenth of a second at a time, however, I found that my comparisons weren’t matching up. I tried to debug the code with print statements, and things looked like they should have worked.

position 2.8
position 2.9
position 3.0
position 3.1
Event placed!

Even when I pressed the right arrow, then pressed the left arrow to return to 3.1, things looked like they were working.

position 3.2
position 3.1

                But at 3.1, I should have received a message that said “sound method called.” I didn’t, and the reason, as I discovered after 8 days of struggling with the code and obtaining tips from experienced programmers, was those blasted floating point numbers. A simple print-out of the three punches I had entered shows why.

{3.1000000000000014: {‘punch’: {‘strength’: 0, ‘height’: ‘head’, ‘can_stun’: False, ‘can_break’: False, ‘speed’: 1, ‘side’: ‘left’}},
2.1000000000000005: {‘punch’: {‘strength’: 0, ‘height’: ‘head’, ‘can_stun’: False, ‘can_break’: False, ‘speed’: 1, ‘side’: ‘left’}},
1.0999999999999999: {‘punch’: {‘strength’: 0, ‘height ‘: ‘head’, ‘can_stun’: False, ‘can_break’: False, ‘speed’: 1, ‘side’: ‘left’}}}

                When I enter a check between the time of an event and the user’s current time, they will never match up, because in no world is 3.1 equal to 3.1000000000000014. But completely unaware of this oddity in computer programming, I scanned through my code perhaps a dozen times, grew incredibly frustrated, and even considered a complete re-write. As Christopher Toth later told me, “This is the kind of thing that makes perfectly sane programmers gibber in fear.” How right he is.

                The code is working properly now. I found I could overcome the problem by rounding the floating point numbers I encounter, but the solution was a long time in coming. I never realized when I started out that some of the hurdles I would face in learning to program would require a grappling hook and a spotter to overcome. (This situation also shows why I do not give release dates or accept pre-orders.) Even so, the trial is passed, and I have some talented programmers to thank for it.

Tangling with Inertia

                I didn’t know it could happen, but it appears it has: I am at a point in my code where I cannot independently think of any way to fix what is wrong with the creator. No matter how often I look through the code, no matter how much tweaking and debugging I do, I am absolutely stuck. I am waiting to hear back from people with much greater experience in Python than I, but in the meantime, I cannot go forward.

                Strictly from a personal standpoint, this doesn’t bother me. I understand that this is just one more hurdle to overcome in the grand scheme of learning to program. But from a development angle, it means I’m not working while I wait for feedback, and since I’m not working, it comes as no surprise that no progress is being made.

                I have pondered the idea of working on secondary projects as many developers do, but I’m not sure if this is a wise idea in my situation. Many of the developers I know design and code for several hours a week, whereas I do this in my spare time after a full day of work. That’s not to prop either practice, but it does mean that if I split the two hours a day I have to code amongst many different projects, the little time I do have will be spread rather thin. Perhaps that’s a good thing, as it will keep me from getting bored or frustrated with a single undertaking. On the other hand, though, it waters down my focus in a time when I have too little focus to give in the first place.

                What would you all do? Would you work on more than one project at once or would you bang your efforts against a particular obstacle until you manage to break through? All opinions welcome!