Saturday, September 17, 2011

FAAAAAIL

Well today was a colossal failure of all things considered productive...
This is to me.  I. Fail.
The first half of the day wasn't bad.  Judo and Chipotle made the morning well worth the effort... but the rest of the day was completely shot.  I lazily tried to work on my game, but, after an entire day of work, I essentially was stuck at square one despite all of my efforts.  I ended up just combing through hundreds upon hundreds of lines of code commenting and chasing minor errors (loss of accuracy issues and etc.)

Frustrated Kev is Frustrated.
And I didn't even get to any of my homework.

The following picture is unrelated.
"He's... too... beautiful!  QUICK, FIRE THE UGLY RAY!"
Nothing in my game is broken, per se, but the system just has little glitches that aren't pleasing to the eye that I wish to fix that are being a huge pain in the rear.  I'm getting sick of dealing with the spaceships, but I've got almost all of their behaviors down, I am both so very close, and so very far from finishing the game... And I have a hundred other ideas I wish to get started on.  But I'm going to finish this game, and me and David are going to finish our game... eventually.  I'm again faced with the ironic situation that my school work gets in the way of my game making.

Gah!

AND I HATE PRINTERS!
I'm three seconds away from bursting into nerd-rant, but it's 12:30, and I am all burnt out for the day.  Something needs to change or I'm going to go insane.  I spent an entire day in a room by myself wrestling with a computer.
I could use some more Judo to burn off this frustration, or to just knock myself into a nice, relaxing coma.

We're gonna need bigger glasses.
-Kev
Mr. Peanut is not going to compete with any fancy-shmancy almonds!

Monday, September 12, 2011

He's... learning!

Can it be?

First - I promised my cousin I'd put this up.  Here you are Andee!
Her first doodle on my tablet, turned out great!
Too much whitespace, because I accidentally exported the image at the wrong size.  Sorry!

Anyway, can it be?

Potentially.

So, if you all remember (or scroll down) the other day I was having compounding headaches over my pathfinding algorithms.  They worked, but they did a rather poor job of avoid collisions with other units.  Avoiding collisions isn't a necessary factor, however in my game when two ships touch they... well they go boom.


Close Enough.

So have I come up with a miraculous last-minute save?
...no.  No, I have not.  Turns out, there's been a lot of guys working on making pathfinding AI not crash and bump into each other, and, well, there's not really any one grand solution to the entire problem.  It exists, and workarounds are never solid and infallible.  Some of my choices worked well enough, for a while, but then every once and while the system would freeze up. Rather than try and devote myself wholly to fixing pathfinding once and for all as, I researched alternative options.

As happy as I am with pathfinding as a concept, it didn't actually look incredibly natural or appealing which was a slight issue for me, but I was so dedicated to pathfinding that I didn't want to give up on it.  Like I said, it was, for the most part, completely functional.  One day I'll go back to my pathfinding when it is nessecary and spruce up the code, and augment the system to do something for collision avoidance.

So.. how are my spaceships operating now?  It's only halfway complete, the original goal was for my spaceships not to crash into the planets, that I completed with ease, but I ran into issues getting my ships not to crash into each other.

Now, my ships don't crash into each other, they just fly through planets.
MAKE UP YOUR MIND!
I found a few articles on different methods of AI behavior, including one on an Emergent Steering technique called flocking, that was originally developed, if the articles are to be trusted, for animation.
For those of you interested, here's my main article of reference and then this is the site where I first saw the flocking behavior exhibited, which includes some code that I heavily based mine on, almost exact line-for-line I'm almost ashamed to admit, but I will end up making significant tweaks to factor in collision avoidance.  I'm somewhat afraid this is some debauched code-version of plagiarism, but I will and do give credit where credit is due.  I'm just not sure on the exact logistics of it.  That's not the only flocking code every written, and nobody owns the right to flocking code per se.

Regardless, its actually results in greatly improved-looking trajectories for my spaceships, it looks more natural and space-like, if that is even a concept.  I'm quite pleased with the direction flocking is moving in.

The quick rundown of flocking is each unit, referred to as boids in the above link, has a list of it's peers (which I already had implemented in the "friends/enemies" system) and adjusts it's velocity based on three factors: Separation, Alignment, and Cohesion.  In the game world they are all represented as Vectors, or rather as having both magnitude (or speed, depending) and a direction. Separation is the force that drives each unit apart from one another, and keeps them from crashing (my favorite).  Alignment is the "force" that finds the average direction among the group and adjusts each unit to try and meet that average.  And last but not least, Cohesion, which somewhat contradictory to Seperation, finds the average center of the group, and then brings all the units in closer to that location.  It simply brings in an outlier in the group.  If Separation is made stronger by a arbitrary amount (but greater than 1x) it tends to keep Cohesion from bringing anyone in too closely.

There are a few other elements to flocking that I am implementing out of blind faith, almost.  Unlike pathfinding I did not find a tutorial or ample resource for flocking/Emergent Steering, I copied what code I could find and adopted it.  Once I understand the logistics of flocking more, I may elaborate upon them later.

Long story short, I practically scrapped all of my work on pathfinding in favor of flocking, and once I get the units to avoid planets, paddles and, you know, the asteroid in my game, I will be wholly satisfied with the result (fingers crossed though)

Flocking, keep in mind, is not meant to find a path from A to B, but if all my units need to watch out for are two planets and a fast-moving asteroid, finding the shortest path isn't necessarily... well, necessary.  Regardless, I am thinking of a combination of the two techniques for later games, it's an interesting thought.

Annnnnnnnd doodles.
I save the best for last, so at least you all scroll down and kinda-sorta-maybe-not-really read this.

Peace,

-Kev

Saturday, September 10, 2011

FILLER!

Nobody ever said getting shot by Cupid was an enjoyable experience...

Thursday, September 8, 2011

One step forward, Two steps back.

Today is a sad day, my friends.  After wrestling with a problem in my pathfinding code I have come to a conclusion:

I know where the problem is, but I have no clue how to fix it.

Well, that's not entirely true, that's just the more dramatic and depressing way to say it, which I'll go with for now.

Exactly how I feel right now
That's on top of starting school again too.  So much programming ahead of me... and that doesn't even include my own projects I want to do.  I hope I don't become a shut-in this quarter for all the programming required of me.

Anyway, the problem with my pathfinding, if any of you care (raise your hands.... oh... nobody?) actually had to do with my "genius" implementation of influence modifiers.  If you remember from a few posts back, influence modifying is adding on points to the scores of individual nodes, to make them more costly to go through, effectively marking the node as a "no-no" during a path search.

YOU SHALL NOT PASS!

On it's own, this practice is perfectly fine, but I, in my infinite wisdom (sarcasm) used influence modifiers to try and keep ships from crashing into each other.  A ship would spawn, and then it would mark it's path with artificially high costs.  Not a problem, initially.  When a whole bunch of little ships start spawning however, and they are all going to generally the same spot, the most-efficient-path method of A* gets really screwed up if all of the best path's are marked with artificially high costs, and it ends up spitting back a failed path search.

Now in some implementations of A* it will just end up searching EVERY SINGLE NODE in an effort to find a route, but mine doesn't go that far.  I'm not entirely sure if this means that the pathfinding method I implemented isn't A* still because it doesn't but the fact of the matter is I'm going to have to make some fundamental changes to the system yet again because I didn't used my head earlier on in the process.


This is me.  Yes, my nose is that big.
Seeing a trend here, are we?  Me too.  Hopefully I learn to think before I code.

Anyway, this doesn't necessarily mean I need to change how I operate my influence modifications, but... yes.  I realize now I can't just add on scores to the score designed to find the fastest route.  If all the nodes around the end node have too high of artificial scores, then the end node won't be found.  I either adjust the implementation, or re-work how the influence scores actually influence or I adjust my A* algorithm to search every last node to find the target.  Which would end up just taking the system longer and in the end would be lazy programming on my part, and I would probably end up learning less from it.

...Like I'm learning anything at all from all of this?

Yeah I'm with Stupid here.  I also have Schizophrenia. ...wait... crap.
So... I'm stuck re-working my pathfinding probably for the next few days.

You know it.
On the bright side... wait, there is no bright side.  Not that I can see initially, anyway.  I've got class starting, they won't be easy.  Lots of programming ahead, and like I said, my game work will all be on my own costly time now.

My academic adviser, possibly one of the most awesome professors on the planet, much less the North American continent, has given me a position grading for him, as well as a position as a lab moderator.  And Sensei wants me to try to ready up for the next tournament.  These things can be taken in a negative light, more work and more Judo, but work equates to food, and I love Judo, as well as the physical activity that I'm desperately going to need after sitting around on my fat butt all day.

And so it beings.
I think it's a zombie.  Who knows.

WHAAAAAAAAAAAAAAAT?!

See?  Not everything I draw is repulsive... I hope.

Hopefully the next update finds me in a better mood.

Until then, denizens of the world wide tangled mess of interwebs,

-Kev

Saturday, September 3, 2011