01 February 2008

Command n Conquer. Cookies n Code.

Parentheses (Is that how the plural form is spelled? It looks weird.) are destroying me today! It's like Left Parenthesis said, "Yo, Right Parenthesis, wanna screw with nfinite today?"

And Right Parenthesis replied, "Hell yeah!"

Ok, so they only screwed with me twice. They even had the nerve to call up Mr. Semicolon to aid them in giving me grief. What's all this about you may be wondering? I had a bad time coding today. I needed to change an implementation of a linked list into a circular buffer. (For those who know programming, you don't need those links, so I'm not trying to be condescending; just trying to educate). We started having memory leaks due to allocation and deallocation of each node. We knew exactly what was happening and why the leaks where occuring, but there was nothing we could do without restructuring a lot. To protect my employer's intellectual property, I shall now generate an extended analogy to the issue we were having - with COOKIES!

Let's say we have a queue of cookies. If we create this queue as a linked list, each time we add a cookie to this queue, we have to make a box to hold it. It's then placed on the conveyor belt and sent on it's way to YOU (yes, you, this is getting personal now. You are getting fed cookies, you should be happy!). Everytime you eat a cookie, you dispose of the box by means of recycling.

Now, sometimes you need to stop this conveyor belt for various reason (maybe you're too full and need a break from cookies... weakling). When this happens, a GIGANTIC MONSTRUOUS EPIC PENDULUM OF COOKIE STOPPING swings down and blocks the cookies. The problem now is that this GIGANTIC MONSTRUOUS EPIC PENDULUM OF COOKIE STOPPING occasionally swipes a box of cookies - resulting in the box to go flying into the depths of nowhere, never to be found. THIS IS BAD! We do not want cookies to get lost! (This was the memory leak that was occuring).

So instead, it was my task to go in and create a circular buffer. You can think of a circular buffer as an escalator (the linked list was the conveyor belt with boxes). For our purposes, the escalator is extremely sanitary. Each step of the escalator is a platform for a cookie. In this way, we don't need to make boxes for the cookies anymore. You are at the top eating the cookies as they come up, and the cookies are getting placed on each step starting at the bottom. The steps can be reused after they are cleaned of their cookies by you. Now, when the GIGANTIC MONSTRUOUS EPIC PENDULUM OF COOKIE STOPPING comes down, the cookie is small enough to avoid being swatted away. (See, the box was getting hit before, but since the cookie was in the box... ok my analogy is starting to break down here... but whatever! just know that there are no more memory/cookie leak problems with this approach).

Now that you understand the importance of ensuring no cookies are lost, I move on to coding the escalator - which is where Mr. and Mrs. Parenthesis start to toy with me. (They must not like cookies...). I hope I don't lose any of you at this point. It's gonna get a little more technical than eating cookies. Again, I am simply going to tailor this code to the cookie example. Take the following code:

That's basically the pertinent stuff. That should be straightforward except for (add_cookie_step+1)&COOKIES_MODULO. Each step is numbered 0 through 511 (for a total of 512 steps). This snippet says, if we go up one step and it's 512, the number will wrap down to 0. Basically it repeats counting 0-511 for us. So I compiled the thing and BOOM Right Parenthesis has an issue with me.

line 12: error: expected a ")"

I could not find a problem with it for the longest time. ALL THE PARENTHESES ARE MATCHED! There are the same number of left as right parentheses! I went to a fellow cookie-meister and he took a look at it and thought it was screwy too! What was the problem? If you found it right away, congrats. It's a lot harder when the code is ~1000 lines long. Apparently, Mrs. Right Parenthesis was having an affair with Mr. Semicolon. COOKIES_MODULO was defined as (MAX_COOKIES-1); This means that, to the compiler, line 12 said:

while ( (add_cookie_step+1)&(MAX_COOKIES-1); == remove_cookie_step )

That semicolon in there is a big no-no. It seems it didn't care about the following line though.

remove_cookie_step = (remove_cookie_step+1)&(MAX_COOKIES-1);;

Fine, fine, whatever. Problem solved.

I was going to explain the second problem that I had, but I would need to extend my analogy even more. I don't want to do that anymore. Just know that the code did not do what I expected it to do. I forgot to add that there can be multiple escalators. What happened, however, was that you ate only cookies on Escalator #0, but none of the others! "WHYYYY WERE YOU ACTING UP!" I asked myself.

if ( (Cookie->EscalatorNumber)&Escalators_To_Eat_From != 0 )

This line basically asks if the cookie is edible by looking at a designator of EdibleCookies (We can't eat bad cookies. We don't want to eat bad cookies.) Basically some order of operations mumbo jumbo happened. This line needed to be

if ( ((Cookie->EscalatorNumber)&Escalators_To_Eat_From) != 0 )

So when I didn't need parentheses, the compiler complained at me. But when I needed them, it didn't say a single thing.

I Hate You Mr. and Mrs. Parenthesis. Oh and Mr. Semicolon too (because I always seem to forget to add you to the end of lines, and then Mr. Compiler throws fifty million errors for the lines that proceed /rant).

Ok, I'm done, I hope you want cookies now. I sure do, but I don't have any. Sad day. Well, maybe Rainy has some cookies. She better, it's like a house-warming party. Since her blog is "reopening" (or something) she needs to give us cookies.

I know I said there would be pictures this post, but this post has gotten long. So I guess ya'll will just have to wait until next time! Stay tuned for sexy video cards, sexy keyboards, and sexy cars.
Stay sexy!

27 January 2008

BOOBIES!

I'm not dead yet, honest. I've just been lazy. Those are two different things you know! Unless, you're so lazy that you might as well be dead - but that's not me. I feel bad for not updating, but I'm too lazy to sit down for 45mins to flesh out the things on my mind.

When I first heard about the whole Mass Effect controversy on Fox news, I was going to go into a rant on the matter. I was going to take the entire debate with Fox vs. Keighly and break apart each and every claim and "rebuttal" that Fox offered. Everything they said was flawed, all of their evidence was skewed, and they had no idea what they were talking about. I was going to take each line and show why and how it was completely wrong. But, while I'm still perturbed by Fox, I'm too lazy to do it. Plus, the "expert" they hired to argue with Keighly offered an apology for her incompetence - er, I mean, lack of research. I'm not sure whether she was being sincere about it, or just trying to cover her butt - in either case, I'm just mad that there are people who watch this stuff and believe it to be true. If Mass Effect has full frontal nudity, then all beaches in the entire world should be off limits.

I've played the game; and I've seen both scenes in question. The first, I would never have encountered because it required following the "evil" track. The second was only through "hard work" of completing the love story with one of the other characters. To be honest, it's a very cinematic (in the plot sense) progression. You get to know the said love affection-character throughout the game, fight with them, and talk to endless NPCs with them. It's only reasonable that before the finale - the final battle - that your character and their love interest get a little something... But wait, what's all this fuss about! Mass Effect is rated M. The equivalent in movies is R. Both are for ages 17+. Take the movie 300. Just before the King goes to battle, he and his wife have at it - OMG BOOBIES! -- Mass Effect: NO BOOBIES! OMG THIS IS BAD!

I will venture to say that it is harder to play a game through to get to the "sex scene" (a very mild one in comparison to movies and even TV these days) than pop in a comparably rated movie just to get at some nudity. I guess I couldn't help ranting about the ordeal despite saying I was lazy. There's more to be said, but there is one point that completely shuts down any possible intelligent argument. Mass Effect is rated M. "but but! kids are seeing this!" ... Your point? Are they supposed to? Porn is meant for 18+. I don't have statistics, but with the advent of the internet... Hell, even movies depict kids with porn mags as if it's daily life. My favorite quote is, "I went on the website today. I clicked on a lot of different trailers. I tried to learn as much about it as I could before we did this... It's interesting: when you click on it, it asks you your age. It says you must go through a scanning process. So I though, ugh, this is going to take forever. Ok, so I put in my age; and then Boom you're in, no problem. So that is a pretty screen to get past."

Wait, was she trying to make a point of something? Wait, is she trying to say that a 10 year old could do this? Wait, let's up that age to 13. Wait, oh my god! Wait, she's saying that a minor could be getting into a restricted site! Wait, they're getting access to potential nudity?! Refer to one of my older posts about this age verification subject. I felt pretty good that I had already made her look stupid, before she put out the idea. There's free porn on the internet that's much worse than a video game site.

Anyway, I'm done with that. I got a new keyboard today; I'll probably share pictures next post. I also went to the Wash. DC auto show yesterday with some friends yesterday too. So stay tuned for those as well. Nothing too exciting though. I'm sorry there were no pictures in this post and it was just a long string of text. Tomorrow is Monday! Enjoy the new week. *cough*

14 January 2008

little green man

I know this is so last week, but I was too lazy to blog the moment I found out.

YODA IS GOING TO BE IN SOULCALIBUR IV FOR XBOX 360!

Now that I'm done sounding like a complete marketing advertisement, I'd just like to reiterate how ecstatic I am about the wicked green short guy doin' his thang in ソウルキャリバー IV. Doesn't he look badass? You know how you smiled the first time Yoda whipped out his lightsaber in Episode III? Yeah, this may not be a rehash of that moment, but it is still smile-invoking nonetheless. Oh yeah, Vader is on the PS3. But honestly, envision the fight between Yoda and Vader; it wouldn't last very long: Yoda would school him all while taunting him with anastrophes like "Suck, you do." and "Slow you are; Catch me, you cannot." So since I'm an owner of a 360 and I like to dish out the PS3 hate:

Yoda > Vader :: 360 > PS3.

Hopefully Project Soul manages to incorporate these characters into the game and maintain balance. (Because let's face it, if it were my choice I'd just say: Yoda enters match. Yoda automatically wins because he's Yoda). That aspect aside, another thing that bothers me at the moment is: Lightsaber vs. Metal Sword. I haven't followed the Calibur series nor have I played any of them, so if I'm wrong about the fighters' weapons being made of metal, I'm sorry.


I don't know about you, but that picture looks unrealistic. (Ignoring the fact that there's a Vader and lightsabers exist). I've read a few Star Wars books in my time, and from what I can recall, no material resisted a lightsaber. Sure there were huge thick doors and walls and things; those just took more time for a lightsaber to cut through. So, how are these fighters are going fight against lightsabers?

... Maybe their swords are made of mirrors. Or they're "mirror-plated" metals. Because, mirrors reflect light right? I just had a revelation. Why don't these futuristic people wear armor made of mirrors? It'd be like chain mirror-metal armor or something. That way, laser guns would ricochet and lightsabers would reflect off! Genius!

Moving on to the next subject without any sort of transition at all; and completely leaving no conclusions to the Yoda-SoulCalibur train of thought... I finally got around to playing Call of Duty 4. Got it Saturday afternoon and I beat the single player campaign today. Overall, an enjoyable experience though I was slightly unnerved by the disconnected empathetic atmosphere of the game. They tried to get the point across that war is a major pile of suck through random deaths of squad mates who you really don't get a chance to be attached to. I suppose that's the trade-off in having a short but intense game. If it was a longer game with more character development/interaction, the intensity would have faltered.

Returning to my point of disjoint empathy, this game is paradoxically humanistic. War should teach us to value lives, but this game throws so many enemies at you that you end up mowing them down without a second thought. "Man that mini-gun!" "Grab the detonators on the second floor!" The best example of this is the mission where you man the guns in an AC-130 gunship. The enemies show up on your monitor as small specks (in a sense), and the larger guns you fire send these buggers flying. The 25mm gun obliterates the enemies in a shower of black and white pixelated blood and dirt. The comments by some dude in the plane make it even worse. He has a very lazy manner of commenting. "kaboom." "Good kill, good kill." "Light him up." It just isn't right. Here's a link to a video on gametrailers to see what I mean.

It's a fun game. There's no doubt about that; but it unnerved me morally. The reason I was originally going to talk about Call of Duty 4 was that I was surprised at the number of invincible monitor screens in that game. I went around shooting LCD panels and none of them died. It just left a huge bullet hole in an otherwise unchanged still image. With so much attention to detail in other places, I wonder why they didn't short out the monitors when you shot at them. I took a picture of what I'm talking about, but I can't find it anymore...


I think I'm done yapping.

Enjoy hump day tomorrow!
-nfinite