Infinite Terrain Generation - Part 2

Well, I’ve got something - but it isn’t what I’m looking for. Let’s take a look at some concepts from the previous post first. Ok, fine. I will do away with the mouse-drawn graphics and use a camera for once.

Ok, so remember this thing that didn’t work out because it doesn’t include negatives:

My camera phone is not much better than my mouse-drawings when the flash decides not to go off.

Read more...

Infinite Terrain Generation - Part 1

Ok, so I’ve gotten my terrain generator spitting out a single chunk of terrain. However, I’ve run into a problem that has had me stuck for a while. The problem is this - How do you get infinite generation of terrains, while still keeping theterrains you’ve passed by permanent? It seems pretty simple - just make an array of terrains and add on as you go, right? There’s a couple reasons this won’t work:

First, arrays are finite size, and you can’t resize them without a lot of effort (on the computer’s part, of course). Not much way getting around that.

Illustration of the problem when using arrays. Everything must be shifted over to make room for new terrains on the left.

Second, how do you manage the “origin?” Obviously, you’re going to need some way to refer to the terrains you want to display. For example, say you’re on some block of terrain 1 block right and 2 blocks up from where you started on. We’ll refer to this as terrain (1, 2). Then, you walk left 3 blocks, ending on terrain (-1, 2). Obviously, you can’t store this in array index [-1][2], because there is no such thing as a negative array index. You’d have to shift everything over before generating this new terrain at (-1, 2), causing  a lot of overhead. Additionally, you’d have to have some coordinate stored in the origin that would shift every time you go into negative coordinates, adding additional complexity. To get around this, maybe you’d say, well, make these arrays-of-terrain-blocks fixed size, say, 64x64. Keep the origin at the top left corner of the array-of-terrain-blocks going up and right, and just add another array-of-terrain-blocks when you walk to the left, so that you don’t have to shift anything. Well, then you have the same two problems all over again, just macro-sized.

Read more...

To the Moon

Ok, so there wasn’t really a Skyrim LP. Suffice to say, I’ve played the game out by now, and I didn’t feel like doing one before because of some family issues. That is also why I haven’t posted recently.

However, I haven’t just been playing Skyrim. While it took up quite a bit of my time, I also found a bit of time to play To the Moon, a small 4-hour indie game by Freebird Games. And, by god, was the story great. I very nearly - very nearly, mind you - cried at the end. I did get some sniffles.

– Minor Spoilers Below. –

“To the Moon” - very clever. You already know what the ending is going to be. There are even pictures of rockets blasting off on the homepage. But, really, the game is not about the ending. It’s the journey, the choices the characters make, the themes inside - is it really our place to change events in the past, even if it’s not the past we’re changing, just a pseudo-past, and even if everything works out OK in the end? This stuff takes a lot of rumination.

The story is absolutely moving. The “moving backward in time” mechanic was just great, and in the middle, when Dr. Rosalene does her big twist thing by removing one of the big characters and the montage plays - you know what I’m talking about if you played the game - I just sat there, took my glasses off, and put my head in my hands, listening to that song by Laura “unfairly-known-only-as-the-zombies-on-your-lawn-singer” Shigihara. (Warning - by listening to the song you agree to have your ears assaulted by small angels.) The game had some ridiculously powerful moments, that cannot be denied. I would have said it was perfect, if only one thing would have been changed…

The dialogue. Oh my god, why, why Gao Kan - or is it Kan Gao -  why would you put a character like Neil in the game? This is my biggest, hugest, bearish complaint: the dialogue in the game simply did not add up with the themes and tone presented. Neil Watts, one of the characters in the game, makes jokes at every single opportunity - none of them made me laugh, either. I simply kept thinking to myself “oh my god, shut up Dr. Watts.” Some said Neil grows on you - it was a little of the opposite for me. He was ok in the beginning. It was a little amusing when he fights a squirrel. But in the middle of the story, when you’re uncovering Johnny’s deep secrets, his soul-touching past?

I’m not saying that something serious has to be completely serious, all the way through, period. Humor has its time and place. But just about the entire way through the game, there is never a stop to the slapstick antics and wisecracks. It has a bit of Homestuck-syndrome; Homestuck, at its root, is a humorous story, made for entertainment. I mean, really, just look at the header to the MSPA website. It’s supposed to be funny. However, there are times when the story gets real serious, and more than a little bit sad. Many of those times, Andrew Hussie, the creator, screws the moment up by trying to keep the story lighthearted. Such a thing immediately detracts from the impact of the scene on the audience.

Anyway, back to To the Moon. Now, I haven’t mentioned any of the gameplay. In truth, the game would have been better served if it had been produced as a movie. The gameplay elements do not add anything. However, that is not to say they detract. They’re just simply… there. They never get real annoying. Sometimes it’s even enjoyable, such as when you get the “ideal” score on the memento flip-puzzles. I think, though, that they were simply added because the producer thought they needed to be there - it’s a game, after all.

Some people said the game made them cry. I did not quite get there. I just can’t shake the feeling that To the Moon would have been so, so much more powerful had it reconsidered some of the choices it made in dialogue. I really hope that Gao/Kan Kan/Gao will remake the game, or get a movie deal, or something, and rework the characters. I still say, though, you should give To the Moon a play, if for nothing else but to experience the pure emotional release that it gives. I suggest you play it all the way through, without stop. Lock yourself in a room for four and a half hours. If it’s close to meal time, bring food with you. Let your friends and family know you won’t be around for a little while. Put your cellphone out in the hallway, disconnect your internet, fire up the game and just… enjoy it.

Anyways, it’s winter break now, and I’ve got some time to do random stuff. Time to dive into OpenGL for real.

Bastion

Play it.

Play it play it play it play it play it play it play it play it play it play it play it.

Yeah, I know I’m late - it was released months ago. But I finished it just this week, after it was 50% off on Steam. And, by god, it was so good. I’m just speechless. The hack-and-slash gameplay, the aesthetics, the choices… I can’t even say how good it was. All I can say is:

Play it.

(And next time, the start of a Let’s Play of Skyrim, on my deaded-video-card-computer.)

Deus Ex: Human Revolution

Bought it, finished it. Was not sure what to think.

For those who do not know, Deus Ex: Human Revolution is the prequel to the first Deus Ex, what was a (apparently) groundbreaking FPS experience back when it was first made along the lines of Half-Life 1. I say apparently because I am too young to remember ever playing it, and too new-generation to be able to appreciate it in full nowadays.

However, unlike Yahtzee, I am not reviewing the original; back to Human Revolution. In the game, you are Adam Jensen, former SWAT and current director of defenses for Sarif Industries, a corporation specializing in augmentations; futuristic, sci-fi bionic implants. Lose a limb? No problem, have a synthetic one with all the functionality of the old, and more… of course, only if you can pay. That’s right, this technology is improving everyone’s lives everywhere, except for the ones who can’t afford to pay for it. Not only this, but the augmented must take a highly addictive drug, “Neuropozyne,” to force your body to accept the changes you are putting it through. If you don’t, terrible (unsaid) things happen.

So, what you would expect occurs; worldwide riots. The proletariat rises against the rich, either demanding that they also have access to this technology or simply that this technology go away, because their family and friends are all getting addicted to Neuropozyne and this cannot go on. Behind this stage, in the back, there also appears to be a, or several, puppetmaster(s) trying to influence events…

Note that I’ve said nothing of the gameplay yet. The story and setting of Human Revolution is an extremely engaging one. The game is mostly linear, but when you do get a sidequest, you want to do it. Not just because you want the upgrade points, or the credits, but because you really want to know what is going on. There is mystery upon mystery heaped upon Adam Jensen, and for each mystery, multiple ways to approach investigation. Here is where the original Deus Ex differed from all others; you actually get a choice as to how you solve your problems. Will you be a gunman, coldly using lethal means to force your way to the objective? Will you be the pacifist, only tranquilizing people to reach the target? Will you be the hacker, crawling through vents and hacking doors and turrets, gaining entrance to secret rooms? The choice is yours. Gladly, I can say that Human Revolution offers all these options.

The route I chose, that of the sneaky pacifist, was strangely reminiscent of Metal Gear Solid. There are cameras, turrets, guards, and boxes. It’s all about timing and patience; when guards move away or turn, you have to take the opportunity. When they are looking the way you need to go, you have to be able to sit tight and wait for them to move away. The guards respond dynamically when they see bodies, and when you are spotted, you are quickly taken down with almost no opportunity to retaliate - on “Give me a challenge” difficulty, I could survive about 2 shots with no “dermal armor” augmentation, but on “Give me Deus Ex” difficulty, you die on the first shot you take.

That might make gunplay seem a bit obtuse, but I think it’s the contrary. While people criticize the shooting aspect of the game, I think it’s ok. To be fair, I only killed about 10 people in the entire game - minus the bosses, we’ll get to that - but the ones I did kill were based on a lot of skill. Again, you only get one or two shots to survive, so you’d better shoot for the head and get a quick kill every time you duck out of cover or you will be gunned down.

Now, the bosses. The sore spot of the entire game. Most reviews I’ve read on the game criticize this. What the hell were they thinking, to include mandatory shoot-to-kill boss fights in a game that’s all about choices? Well, honestly, I think it fits with Jensen’s character.

SPOILERS AHEAD.

The bosses are the ones who attempted to kill not only you, but also your love interest. To those who have already finished the game: believing something is true makes it as good as true in your mind. No matter how much you might wish Jensen to  play calm, I don’t think he would be able to repress the tons and tons of rage directed at them from the incident those six months ago. It may be incongruous to the game, but I believe that it is definitely within reason to have Jensen forced to kill the bosses. During my pacifist run, when Malik is about to be killed, I just pulled out my gun and started shooting. Sure, I was doing a pacifist run. But there was no way that I could let the baddies kill a friend. It’s the same thing for the bosses.

SPOILERS ENDED.

All in all, it’s a great game. My brother keeps telling me that the ending - which I won’t say anything about - just completely ruins the experience, but I don’t believe so. I do think it’s a shame that it’s so rushed, and that there’s not much closure, but it doesn’t make a recommendation into a total turn-off.

Consensus: Play it

Hiatus

There was one. Now it’s over.

Hopefully I’ll get around to posting on here more often. I’ve been busy with getting a job and starting school; this blog, while interesting, has really been low priority for me. So, expect a post about something soon.

Adventures in OpenGL

I finally started learning SDL. Then I found out there were no primitives. Then I went to OpenGL. Then I found out you have to specify every single vertex you want to draw.

Well, hell.

I also found out that there’s a real dearth of OpenGL-SDL tutorials. There’s not that many OpenGL tutorials alone, for that matter. And on that subject, so you don’t have to (like I did) go “Ok, I should learn some OpenGL. Let’s look up some tutorials… Can’t find any. Going back to Dwarf Fortress,” about 50 times, here’s a good series of tutorials on OpenGL using GLUT that is pretty easily adaptable to SDL.

However, there may be a few things out of date - I just found an error with the tutorial on lighting. You can’t light faces colored with glColor3f and expect it to work. Here’s a good explanation on why, and how to fix the issue.

Overall, my experience with the library has been good - it’s just extremely noob-unfriendly. I don’t want to have to specify every single vertex of the three triangles that make up a pentagon - but really, that does give you a lot of flexibility. If you want to just make games, instead of programming them, stick with an engine. However, as my previous adventures in the Source Engine showed, my destiny is not to be a game designer, architect or someone who tries to build a virtual reality from scratch, placing bushes and sidewalks to simulate real locations - I’m to be the monkey that codes the stuff in the background.

F'n Dwarves, how do they work

I’ve been engrossed in a game called Dwarf Fortress lately. It’s a kind of single player exploration game within a runtime-generated world. I’m sure that sounds familiar; a lot like Minecraft, right? Well, it’s not quite.  Just take one look at the screenshot, and I’m sure you can tell why.

Yes, that’s right - ASCII graphics, in the manner of a roguelike. It’s similar to Minecraft in many ways. The goals are similar -  build as much cool stuff as you can without dying. You dig a lot, for precious metals, and forge them into weapons and other cool stuff. But that’s where the similarity ends.

In Dwarf Fortress, you control a group of dwarves, setting out to found a new fortress in the name of some civilization or another. To accomplish this, you must dig. Dwarves, after all, live underground; many dwarves will get nauseated when they contact the sun. After you dig a nice home, you must worry about food. Your first goal in the game is to survive the winter. There are several ways to get food; you can order your dwarves to hunt. You can grow crops, both aboveground and below ground. You can train some fishermen. “Whether by plow, bolt, or hook, provide for your dwarves,” the game says, and this you must do to ensure a successful fortress. After that, you must build. You can order construction of anything from rock crafts to adamantite statues; whatever keeps the dwarves happy. The complexity of running a smooth fortress is absolutely daunting.

But that’s not where the game ends. Once you have a fortress running, stocked well with drinks, food, statues and happy dwarves, you will be attacked. Goblins, kobolds, and macaque monkeys are just a few of the things you might encounter. You will have to build traps, train a militia and construct weapons to protect your fortress. The danger won’t only come from aboveground, it will also come from belowground. At some point, you might encounter the undead, and finally, maybe even demons and other strange monsters. I don’t want to spoil it for you, like I did unknowingly for some people when I asked for help about a mysterious sword found underground - that story is still continuing here, now spoiler-tagged. After all, Dwarf Fortress, is all about mystery and fun. And by fun, I mean losing.

Oh yes, didn’t I mention? Dwarf Fortress’ tagline is “Losing is Fun,” because you will lose. Whether by starvation, tantrum spirals, or forgotten beasts, you have to lose. There is no winning Dwarf Fortress, no ultimate goal save the one you set for yourself. You might challenge yourself to use no wood, or to start your fortress in a desert or tundra, or to never brew alcohol for your dwarves - Dwarves get very unhappy without booze. Completing your own challenges is the only objective in the game.

Your first challenge is to download it and get started.

wxWidgets

… Is awesome.

No, seriously wxWidgets, thank you for saving me from the hell that was Agar. Even if your libraries suck to compile, even if prebuilt libraries exist only for older versions, thank you. You are shiny and all that a cross-platform GUI API for C++ hopes to be.

In all seriousness, wxWidgets isn’t terribly easier to learn than Agar was. In case you aren’t familiar with my situation, I am tasked with developing a GUI/graphing frontend for a program that some physics guy at MIT wrote. If you are wondering how Computer Science student got into such a situation, it was a combination of late internship applications, no job offers and a particularly good final project in CMPSC 122. Oh, and a particularly favorable professor for that class.

Anyway, for the last month or so I have been puzzling over Agar and its math library. As I’ve said, I needed to graph things in real-time, and agar seemed to fit that with its “plotter” widget. However, an error (specifically, unresolved external symbol __imp__hypot) in its libraries and a profound lack of support forced me to consider alternatives. I tried out FLTK, and found it not to my liking. I then turned upon wxWidgets, a library that I can’t remember why I overlooked. I downloaded it, and groaned when I saw that there was only source included.

I’m a big fan of prebuilt libraries. As a freshman sophmore computer science student, I have not yet had to deal with cross-platform compatibility issues and the like, so I like my third-party libraries neatly packaged for Windows and MSVC++ 2010. Maybe that’s a bad thing; I’ll have to deal with those sort of issues sooner or later, so I probably should start early. Long story short, though, I tried compiling the libraries and it threw a bunch of errors and I said screw it and went to look for prebuilt libraries. I found them, but they were out of date, but good enough for me. I wanted something that worked, so I could try wxWidgets out first, and not end up having to trash everything and go back like I did with Agar.

So, I downloaded them, and gave wxWidgets a shot, and man am I glad I did. Unlike the two libraries that I used (FLTK, Agar) it is entirely object-oriented, which is an absolute godsend. With the other two APIs, I’d try to pack my interface into classes, only to find that I couldn’t because the callbacks for button presses and other widget events couldn’t take member functions as parameters. There were workarounds, but none that let me use any of the members of the class. So when I’d go to program the button to store a ton of values from the textboxes into variables, I’d find it was impossible. There was a way around it in Agar that involved binding the values inside the boxes to variables, so that when the boxes changed so immediately did the variables, but as I mentioned there were other problems with the API.

Not to belittle small-but-still-useful libraries, but the other thing is that wxWidgets is simply more popular than Agar. It is much easier to get help, since wxWidgets has a larger community. This might be a direct consequence of it being easier to use; I’m not sure, but let that be a lesson to me; your libraries and programs are nothing if they do not have good communities.

Molecular Dynamics Hard-Sphere Simulation

I won’t claim that I know anything about Molecular Dynamics, or even Physics - I scraped an A last semester in Physics Mechanics - but here I am, doing an independent study involving Sonoluminescence. I’m not even entirely clear on what that is. It’s about gas bubbles, and producing sound and light which may have applications in generating energy.

What I’m doing right now is easy enough, I suppose: simulate an n-body system of hard-sphere collisions with a bubble wall, assigning a velocity to each atom according to the Maxwell distribution and calculating collisions according to an elastic collision model. In layman’s terms, a bunch of balls bouncing around in a bigger ball with no gravity. For this project, it’s back to Dark GDK for me, for the reasons mentioned in the very first post in the blog.

My other assignment is to make an interface to complement a program that already does what I mentioned in the paragraph above. This program, however, is extremely slow and inefficient at lower numbers of atoms, “lower” being 50000 vs. “higher” being billions. Yay Big O notation! For this, I’m using SDL and Agar.

I haven’t had time to post, but I guess it doesn’t really matter; no one follows this, anyway. Oh well. Need to keep an account of things, for posterity.

MD Simulation Project Page Link