Sheep Vectors and Potential Fields

Ξ October 25th, 2006 | → 0 Comments | ∇ Indie Games, Sheeplings |

Why is it so hard to find an algorithm that deals with a specific instance of a problem instead of solving everything at once? I’ve looked at various pathfinding and flocking algorithms, but nothing fits the bill so far. What I have is a bunch of sheep running around, and I would like to see them avoid corners but still move around objects gracefully. It’s a simple task, but not really simple in reality. And I really don’t want any involved path-planning in all of this, so advanced algorithms are right out.

The sheep have two modes of self-initiated transport: walking and running. When they walk, they’re intended to be pretty random and can go everywhere. Previously I added constraints that they prefer to be within a certain distance of each other - flocking behaviour - but it wasn’t really noticeable. When they run, on the other hand, they have a goal: get away from the dog’s bark. In other words, they have a destination angle and they move along this angle. That’s when they can bump into objects and get stuck in corners; and in the latter case, how should the dog get them out if the bark only makes them go farther into the corner?

So far I’ve gone through these attempts:

  1. Just let the sheep run straight ahead; who cares about avoiding objects? This version sucked.
  2. When a sheep runs forward, add vectors according to this simple algorithm:

    The red lines are vectors from the objects to the sheep; the blue line is the initial destination vector; the green line is a vague approximation of the resulting current vector.

    * Create a temporary vector of the sheep’s destination angle.
    * See if an object is close enough. If not, disregard it.
    * Add to the temporary vector a shortened version of the vector from the object to the sheep. This is in order to make the sheep move around it.
    * Do this for all objects. The final result is the current angle that the sheep will run to. This worked surprisingly well, and the sheep moved smoothly around objects. However, the sheep got stuck in corners despite this. They moved away, and then immediately walked back to the corner when they could.
  3. In my next attempt I tried to change the destination vector along with the current angle change. The destination was moved a little bit to where the current angle was pointing. I.e., in an attempt to make the sheep change running destination when they current angle was pointing away for a while. This looked very silly when it came to avoiding common objects in the way: the sheep avoided it by running in another direction instead of just moving around it.
  4. Fed up with vectors I went back to my old friend potential fields.
    The red parts show the intensity of the field; sheep will want to avoid red areas.This is the current method I’m using, but I made a very simple version of it. Basically, the sheep predict if the block that it’s going into has a potential greater than 1 (marked as the lightest tone in the image). If so, it decides that this won’t do. It checks the surrounding blocks of the destination block, selects the one with the least potential, and goes in that direction.

This last method works reasonably well for getting the sheep around stuff, and it also makes the sheep very reluctant to get into corners. It’s good enough, but I’m considering adding some vector additions to this to make things even smoother.

It’s rather ridiculous that I’m spending this much time on a simple problem like this. But I really want the sheep to run smoothly and be nice to the player!

 

Random Thoughts on Heraclitus and Anarchy

Ξ October 23rd, 2006 | → 0 Comments | ∇ Literature, Observations |

I listen to a lot of audio books these days due to a lack of more efficient means of transportation than my feet. I recently finished book 7 of Stephen King’s The Dark Tower series, so I started looking for something new to listen to. The Dark Tower was interesting, and King is a good writer, but seriously…I don’t see what all the fuss is about. The first book, The Gunslinger, was promising but it all went downhill after that. Too much was explained; too much random variation; too many haphazard twists for my taste. King himself mentions that he doesn’t write the books per se - they grow from his imagination, and he has no idea where the next book will take him. This is quite noticeable. I can’t say that I approve. So I went for something more concrete; something more strict: The Teaching Company’s Introduction to Greek Philosophy.

I like it so far. It summarizes things pretty well, and even though there are repetitions they aren’t too bad. Sometimes these repetitions are actually excellently paced: just this morning I couldn’t recall the meaning of the word doxa - and the teacher repeated it right then. And the contents are good as well; the book begins with describing myths and rapidly procedes to mention various ideas spun by early thinkers like Thales, Anaximander and Anaximenes, and eventually arrives at Socrates, Plato and Aristotle. The latter ones get a number of lectures for themselves; in fact, it’s mentioned that some believe that later - modern - philosophy just consists of footnotes to Plato.

Before the lecturer arrives at the important latter three, other philosophers are mentioned. Two that stuck to my mind are Heraclitus and Democritus - the weeping respectively the laughing philosopher. Oh, and a pet peeve of mine: why do English-speakers have this weird urge to change the spelling of names? Herkleitos becomes Heraclitus and so on. God damn you, it just messes up my attempts to google for info on them!

Heraclitus is known for famous sayings like “you can’t step into the same river twice” and similar eloquent similies and metaphors; all combine to form the doctrine of flux - that everything is in constant motion. This is in fact an elaboration of the state of becoming: nothing in the world is constant because everything is moving, and thus there never is a state where something is. But if we’re to trust our senses we know that things exist after all, so the logical (or well…mythical if one is to believe Plato) conclusion is that something can exist and not exist at the same time. That is essentially what becoming is; and it’s a paradox. Since it’s a paradox, it is also something that later philosophers object to: a thing that is and is not at the same time is logically faulty, and that renders the whole concept of becoming logically flawed. I.e., it doesn’t belong to reasonable thought - only is is logically valid. And something that does not belong to logos - the knowing; the reason - instead belongs to mythos - poetry; storytelling. (This is a very brief summary of Plato’s argument through Socrates’ words. Maybe this explains why I added the “mythical” comment above.)

As a footnote, it’s interesting that Heraclitus himself brings up the word logos. But to him it means the thing which all matter consists of - the arche - instead of human reason.

Back to the arguments against Heraclitus. First of all, I find Plato’s logical refutations of Heraclitus…lacking. The latter deals in relative notions, while Plato discusses absolutes. The simplest argument Plato brings up is that of self-reference: if Heraclitus is correct and everything is in flux, then even language itself must be in flux. That means that Heraclitus’ statement becomes unintelligeble since language cannot be trusted - the language loses its value and its ability to specify the doctrine of flux itself. Many other of Plato’s discussions are along those lines: he specifies premises and eventually disproves the other’s ideas by maneuvering them into a logical inconsistency. This seems fundamentally flawed to me. It’s like comparing apples and turtles. But then again, I’ve only listened to these audio lectures, so they might not have brought up some of the finer points of the arguments.

Another thing that I find lacking is the lecturer’s own interpretation of philosophers at times. While discussing Heraclitus he mentions that the philosopher brings up several possible arches throughout his writings, and that this in turn seems to indicate that Heraclitus appears to think that there is no static arche and that he is an anarchist. I.e., that he believes that there is no static foundation. I think that this conclusion is pretty far-fetched, as there are rather few examples where Heraclitus assumes a position either for or against. Read some of the old philosopher’s quotes and decide for yourself; personally, I think that this is a very premature conclusion, and one that the lecturer simply wishes to draw since it fits in with his idea of philosophy. Heraclitus seems to refuse to take a stand concerning that question and that fits in perfectly with his relativistic thinking, in my view. He refuses to name a specific arche, but he doesn’t appear to imply that this means that there is none.

I find Heraclitus’ ideas very appealing, and so do Nietzsche and Heidegger. But if there’s someone back then who really impresses me, it’s Democritus. Among many other things he completely side-stepped the question of is or becoming, and suggested that both are correct - it’s simply a question of semantics. He introduced the concept of atoms; the atom is static and indivisible, and is what all other matter consists of. In other words there is a foundation, but everything is in flux at the same time. I still recall how thunderstruck I was at this intuitive grasp of reality when I first heard about him in high school, and I’m still in awe at this theory he presented without modern means of producing empirical proof.

 

Sheeplings v0.1

Ξ October 19th, 2006 | → 0 Comments | ∇ Indie Games, Sheeplings |

I finally took my thumb out of the place where no man has gone before, and released a demo version of Sheeplings at a couple of message boards. This is what I call iteration 1, or version 0.1. If you’re interested, here are some screenshots and the download link:

http://www.sheeplings.com/sheeplings1.jpg
http://www.sheeplings.com/sheeplings2.jpg
http://www.sheeplings.com/sheeplings3.jpg
http://www.sheeplings.com/sheeplings4.jpg
http://www.sheeplings.com/sheeplings5.jpg
http://www.sheeplings.com/sheeplings6.jpg

http://www.sheeplings.com/Sheeplings.exe  (~5 MB, Windows 2K/XP. Maybe 98/Me.)

Some feedback has been gathered from this, and here’s a brief summary:

The Good

  • A few people actually like it (gasp!) and suggest that it could work decently for casual gamers. Others seem to think that it could work for children at least.
  • Except for some issue with the particles in one instance, there don’t seem to be any major bugs.
  • The graphics and sound appear to be passable - this is something that I didn’t really expect.
  • This demo is finally out the door, so I can concentrate on improving and eventually finishing the game.

The Bad

  • The game isn’t varied enough.
  • The art styles clash; there’s inconcistencies between the pixel art and the hand-sketched art. And some of the art ought to be re-done.
  • A few people found the mouse control bad.
  • The gameplay gets frustrating if the sheep get stuck against the wall and such.
  • A storyline would be good to add.
  • Some features of the game ought to be explained better.

The Ugly

  • Nah, nothing really ugly. Just wanted to make the trio complete.

So, what will I do about this? These unnumbered points work well, so I’ll continue to use them.

Results

  • I’ll add keyboard/gamepad control, so that people get a choice of how to move the dog.
  • If I can get the art, I’ll add other animals to be herded around. Different types of sheep, or - as was kindly suggested - flamingoes and such. That just cracks me up. Imagine a herd of flamingoes jumping around. That even beats my Hot Chocolate mode that I wanted to include: the sheep would run around sheared and buck naked.
  • I’ll ponder if a storyline can be added, to gradually be revealed when playing.
  • More explanatory screens, but preferably ones that can be disabled.
  • Improve the sheep-avoid-static-objects algorithm.

This should work for starters at least. Then we’ll see if I can tweak things even further! All in all, Sheeplings doesn’t seem to be a complete waste of time at least.

Feel free to comment and suggest other improvements! Feedback is extremely welcome, even if it’s just a “don’t quit your day job” comment.

 

Beauty and the Beast

Ξ October 17th, 2006 | → 0 Comments | ∇ Observations |

I’m bored! Seriously, I hate this. I’m stuck at home, sick and bored to death. I’ve been up since half past six - bored, coughing and feeling like crap. I’m almost considering going to work anyway, locking myself in my office so that no-one gets contaminated by my nasty germses. I don’t have the codebase available at home, so I can’t even work on some small improvements to keep myself busy. And I really want to work on some session/idle timeout issues right now. Argh, I’m going insane from boredom!

So I dug up some pics of Vincent from the old TV show Beauty and the Beast to keep myself busy. Remember this one? I loved it as a kiddo. I thought Vincent was the coolest thing ever. Then I grew up. But maybe something lingered in my subconscious:


Vincent?


Sick and bored Karja?

I wonder if I could get a job as a mascot for Lionhead if I put on some makeup. I guess I’d have to get a perm as well.

 

Dynamic In-Game Music Experiment

Ξ October 15th, 2006 | → 4 Comments | ∇ Indie Games, Music |

For quite some time now I’ve been fascinated with dynamically changing in-game music. One brilliant example of a dynamic music system is Lucasarts’ IMUSE (part of SCUMM) that was used in their adventure games. Other, fresher, examples are apparently Rez and Lumines. I can’t say for sure, though - I’ve never played either of them. I know, I suck. I just don’t play that many new games if they’re not sim or strategy games! And barely even then.

Anyway, I have this game idea, and I’d love to make music a more integral part of the gameplay. One way would be to feature sound effects that act like instruments in the music, and make sure that they play in the correct places. But that wouldn’t really fit in well with the current idea, so I thought about dynamically changing background music instead. A common way to do this is to have context-sensitive music in the game - for example, increase intensity when there’s danger nearby. That’s is a way of using music to convey an emotional message; give feedback that will increase the intensity of the current emotion. Personally, I’m more interesting in using dynamic music for variation and to convey information instead - I intend to not weight in any emotional content into the variations.

I put together a quick test to see if this would work practically:

http://www.cynicalstuff.com/files/CruxTest.zip
(1 MB, 800×600 windowed application that plays music according to the mouse position. See below for more information)

Here’s a screenshot of how it looks in action. Impressive, ne?

http://www.cynicalstuff.com/files/cruxtest.jpg

This is the basic idea:

I have nine different sound clips:

  • Background music (piano)
  • Drums (two intensities)
  • Bass (two intensities)
  • Oboe (two intensities)
  • Synthish dooh-sound (two intensities)

There are five clips playing at the same time. The background never changes, but if you look at the screenshot you’ll note that there are floating-point values for axis 1 and 2. This determines the intensity and volume of the other sound clips.

Axis 1:

This is the x-axis, and the rythm axis. To the far left you have low-intensity drums but high-intensity bass, and the bass are the loudest. The reverse is true to the far right.

Axis 2:

This is the y-axis, and the melody axis. In the upper part you have the synthish dooh melody, and in the bottom, you have the oboe melody. If the dooh or oboe is at low intensity, they simply play notes to follow the chords instead of the melody.

The music loops every 10 seconds, and the clip types are updated then. It’s a relatively long time, but I thought that it’d be too annoying with rapid changes. If you wish to speed things up and restart the loop with the current axis settings, simply press the mouse button.

Now, I think that this works pretty well. Of course, 10 second clips won’t do! More variation in the music is definitely necessary, but this illustrates the basic dynamics idea. If the game has two clearly visible attributes that change to and fro over time, this will hopefully give both visual and audial feedback. My hope is that the player will become more immersed with a system like this; especially if the four corners of the music are even more diverse. For example, there could be more separated themes to the different corners: woodwind/guitar/bass/drums. Or even flute/distorted guitar/techno drums/”real” drums, that refer to four different visual themes in the game. A kind of “natural versus electronical” battle, where the goal is to make them all co-exist in harmony; to find the balancing point. Thus the name Crux for this project.

I think that this could work pretty well. But am I barking up the wrong tree here? Is there some more common method that’s normally used? Am I re-inventing the wheel completely?

 

Motivation and Overhead Cost

Ξ October 12th, 2006 | → 0 Comments | ∇ Observations |

When I was a wee kiddo our family had a system where we took turns doing the dishes or cleaning up. I thoroughly hated those chores - just like I still do. In fact, I’m starting to consider hiring some poor student to do that for me. When I was a kid I didn’t have those options, however, and whining and begging didn’t work with my mother; so all that was left was trying to reason logically with her. I think my best defense was where I realized that there was a lot of overhead involved in - for example - doing the dishes. The water has to be tapped, dishes sorted and so on. So I reasoned that by waiting with the dishes we would actually save time in the long run: less time would be spent on the extraneous tasks.

“You lazy bastard! Go do the dishes right now,” was her reply to that, of course.

This little anecdote may or may not shed some light over my reasoning, as follows.

I seem to be linking to Gameproducer.net quite a bit, but I can’t help it; there’s just something about the blog that tends to make me want to respond. Today it’s because of a post called Game Production and the Art of Making Sit-ups. Quite thoroughly summarized, the message is that you need to get started with whatever it is you want to do; don’t think that your little effort isn’t worth anything, because it all adds up. Sit-ups is used as an example. Even one sit-up improves your fitness, if it’s followed by more; the thought “what will happen if I keep doing this for 5 years” is mentioned as an inspirational motivational idea. (Yes, I deliberately used that silly sentence structure: I’m experimenting with repetition.)

Personally, I think that I care too much about overhead to think like that. To use the example with sit-ups: if I were to make a single sit-up I wouldn’t be motivated. The long-term gain is nothing that motivates me since I want instant gratification and (short-time) effective use of my time. Sure, no amount of sit-ups will have effect immediately, but I want to know that I’ve made a significant leap forward. Starting with less than 20 sit-ups is equal to a waste of time in my view; it barely makes a difference in the short run and the overhead of actually doing them is too great, per cent wise, compared to the actual effort. Starting with 50 is probably decent for out-of-shape ol’ me.

I reasoned the same way with schoolwork: I wouldn’t go to the university if there weren’t enough lectures that day, and I piled up work toward the end of the semester where I could focus exclusively on it. At one time I thought that this behaviour would change with time, but if anything I’m becoming more and more annoyed at unnecessary overhead and long-term planning without visible results. I want thought-out plans as much as the next person, but they should move briskly forward; progress should be visible.

This led me to consider what motivates different people. I think that some thrive on knowing that they have a firm foundation. They want their spot in the garden where they know that they’ll get water and nourishment so that they can grow and bloom safely. Others strive toward bettering themselves through long-term goals and a sure idea of what they want to reach. These people might be compared to tall trees arching upward; they aim for the sky and grow there. It will take time, but they’re working their way up there.

Myself, I’m a tumbleweed. A cactus tumbleweed. With vines and some weird flowers and a branch here or there. But mostly a tumbleweed.

 

The Right Job for the Tool, Unfinished Projects, and Tainted

Ξ October 10th, 2006 | → 0 Comments | ∇ Music, Observations |

When I was younger I had a hard time finding an appropriate level for my projects and ambitions; with youthful enthusiasm and self-conceit I wanted to create big and wonderful things. In one way this is a good thing: if you reach for the stars you won’t let your talents - to what extent you may have them - go to waste by setting the aim too low. On the other hand, this also means that you rarely will accomplish your goal; you will have a resume of unfinished half-baked projects. A finished piece is always more impressive than a brilliant concept.

If you’re not familiar with gamedev.net, take a look at the Help Wanted forum for many examples of youthful enthusiasm. I find it tragic that there’s a need for a sticky Teams That Can thread, to show the teams that actually produce a finished game. While I still have a decent amount of hubris and self-conceit, I think that I’m beginning to aim suitably low/high with my hobby projects these days. Of course, this mostly applies to art and programming. Writing is still unknown territory for me; I never know if I can produce high enough quality, or how long it will take me. Music is another area like that. At times I receive the urge to fire up Sibelius (a gorgeous MIDI-based program where you work with music sheets instead of a sequencer layout; too bad that their website sucks worse than a Thai hooker) and attempt to produce a pseudo-baroque ensemble piece. Let’s just say that my harmonies and melodies are decent, but the overall composition is generally atrocious.

Yesterday I speed-watched some episodes of Swedish Idol. (This means that I fast forwarded through all the talking, and listened to each performance for a few seconds before I listened to what the jury had to say.) This was pretty educational, and one thing in particular struck me as interesting: a timid girl sang Forever Young; her tone was weak, but it was clear and perfect company to the piano’s soft notes. The jury commented that she had made an excellent choice: by choosing a slow and sombre song, her weak voice dominated the song instead of being drowned as it might have been otherwise.

This made me consider some of the songs I’ve recorded and the importance of not only aiming suitably high, but also trying to find the best job for your tools. I’ve always had a fascination for metal and punk, and I think I’ve always preferred to record relatively hard music. Combined with the fact that I have a high and pretty weak voice, this is not optimal.

After listening to a few old songs of mine, I’ve come to realize that the best utilization of my voice is probably in two songs: a pretty emotional goth-pop-rock song called Tainted, and a humorous song called Heartbeat. The latter is just a simple recording, but the concept with a guitar and a lone singer works akin to the girl in Idol.

Download Tainted (4 MB)
http://www.cynicalstuff.com/files/Karja_-_Tainted.mp3

Download Heartbeat (4,5 MB)
http://www.cynicalstuff.com/files/Karja_-_Heartbeat.mp3

Note that I’m not saying that the songs are good; just that my voice fits better with these kinds of songs. I think I’ll attempt another goth-inspired song and see if it works better for me than my metal/punk songs.

Lyrics, for the ones interested:

Tainted (Miro Karjalainen 2000)

A silence echoes through the dark
Where twisted shadows leave their marks
I stand alone, I have no sight
My tears fall silent in the night

One time I thought I saw a man
I saw his footsteps in the sand
He shimmered and vanished from my sight
My tears fell silent in the night

The loneliness grows everyday
No-one is here to lead the way
I cannot see, my eyes are blind
Tainted souls are left behind

An endless mourning, silent dance
Where no-one gets another chance
The day it dawns without a light
Eternal tears - eternal night

The loneliness grows everyday
No-one is here to lead the way
I cannot see, my eyes are blind
Tainted souls are left behind

The loneliness grows everyday
No-one is here to lead the way
I cannot see, my eyes are blind
Tainted souls are left behind
They say that sinners go to hell
If this is true I cannot tell
Eternal torment would be kind
But tainted souls are left behind

Heartbeat (Miro Karjalainen/Pätr 1999)

I don’t wanna feel your heart beat
I don’t wanna feel your pain
I don’t wanna be right next to you
After what you did to me

I was getting home for supper
You were lying in our bed
You were sleeping with another
Now I wanna see you dead

Oh, my darling, why did you have to lie
Oh, my darling, I can’t stop cry
Oh, my darling, why did you have to lie
Now you’re gonna have to die

I wanna cut you up in pieces
I wanna smear you on the wall
I wanna do all those things to you
We couldn’t do when we were small

Oh, darling, have you noticed
That axe behind my back
I wanna introduce you
To my black plastic sack

Oh, my darling, why did you have to lie
Oh, my darling, I can’t stop cry
Oh, my darling, why did you have to lie
Now you’re gonna have to die

 

Second Life, Advertising and Open Source

Ξ October 4th, 2006 | → 0 Comments | ∇ Observations, Software Development |

One thing I like about writing is the opportunity to discuss wildly different topics, but still try to semi-coherently bind them together. It’s like pattern matching: there is always a common denominator in the articles I read; I just have to find it. This time it all started with the latest issue of Edge, in which there’s an article about how Wells Fargo has bought an island in Second Life.

Wells Fargo was just an example in the Edge article; it really discussed advertising - online advertising in particular, and how different methods is required to placate and interest the online population. People are used to in-your-face advertising in real life: commercial breaks, large ads everywhere and so on. Online, the same thing is true when it comes to popups and ads on larger sites; it’s a necessary evil to pay for the bandwidth. But when advertising rears its ugly head in online communitites, people say stop.

“We ain’t havin’ any o’ that here! This is our private space!”

Apparently, the first experiments with advertising in Second Life met protests akin to that - quite understandably. What I find annoying is that in-your-face advertising is so accepted in other situations; personally I think that the same outcry ought to be presented over ads on buses and buildings, and commercial breaks. I don’t watch TV; commercials is only a tiny bit of the reason for that, but it’s certainly a reason nonetheless. I try to boycott sites that use popups or unnecessary signup for services. But alas! I’m just a single person in a world full of sheep. And I have to agree that advertising inside a community is a bit different compared to TV commercials: it’s more personal; an invasion of a private meeting place.

Wells Fargo noticed this and took care when they started their Second Life campaign: they didn’t push information to people. Instead they made an invite-only island where young people can learn about economic responsibility. (Well, to be honest, the advertising company that Wells Fargo hired did.) I have to applaud this. They provide a good service, and they also made it private. The last bit ought to attract people like dung attracts flies: if there’s something people want, it’s what’s denied to them.

In addition to this, it seems that American Apparel has opened an online store in Second Life, as well. This is another case of bringing a service to the people instead of pushing unwanted information into their faces; I like these kinds of things. And Second Life seems to lean in that direction as well.

A problem with this, however, is how to make people aware of the services in the first place. Quite a catch 22 of sorts. Almost at least. At Gameproducer.net there have been a few experiments with offline promotion, and I like the comment at the bottom of this post:

“I suppose easier strategy for offline promotion would be to contact local news paper or talk with some local seminars rather than just sending flyers.”

Local seminars sounds like an amazing idea, if it can be acheived: it’s promotion and advertising, while still providing a service. Giving something for the opportunity to present oneself. In a similar manner, a friend of mine has started up a set of seminars; he, and through him his consulting firm, offers valuable information to students in exchange for their awareness of his company. An excellent idea.

Then comes my final bit of stretched imagination: thinking about these companies providing services made me think of them in comparison with open source communities. Wells Fargo and American Apparel have the resources to build prettier and more advanced structures in Second Life, compared to a regular Joe. In a similar fashion, a well-funded company can always provide better quality assurance, support and feature fulfillment than unfunded individuals. Note can; I’m not saying that they always do - just that they have the resources to make it so if they desire. This is one of the reasons that I can’t support FOSS fully: I believe that commercial interests are needed and fill a function.

And of course, this is also the reason that I could never support Swedish political sentiments like The Pirate Party. I don’t support the RIAA and MPAA and whatever all of these organizations might be called - but the solution is not to go to the other extreme.

 

About

    Pretentious! Miro Karjalainen is a pretentious bastard with a background in punk rock, computer science, linguistics, embedded systems, game development and the noble art of drinking beer. E-mail: info@karjasoft.com

Admin Stuff