Wednesday, 4 January 2012

Basic, but too basic...

I managed to get some preliminary AI code working . Here is a short video of a single "zombie" attempting to track the "player". I am controlling the Green player, the zombie is controlling itself ;)

Note that I haven't written any collision detection routines yet.


Based on this routine, I tweaked it a little and it handles up to 1000 zombies now! Unfortunately, that just looks like one huge red blob and you can't see the Green player at all. So here is the routine with a few more entities...


So the basics are there, or so I thought...

After messing around with the code, it's become apparent that I am approaching this from the wrong angle. The tracking code is so simplistic on these demo's that I shouldn't really have the nerve to call it AI. I've been doing some research, and I think I need to create the zombies as completely independent entities. That is, at the moment they are independent in a way, but their co-ordinates and paths are held in the same variable array, albeit multidimensional. I need to create them as completely standalone entities if they are to have any kind of semblance of a sentient character.

So I've got a scratchpad to work with, and that is basic but good enough for now. I'm going to completely strip out the existing zombie control routine and (try to) replace it with some sort of... well, I don't know what. But whatever it turns out to be, I want each zombie to react completely independently of each other. For example, if the player comes within a certain distance of a zombie I want that zombie to react, but zombies further away would just trundle on regardless.

I might not even be able to do this, but I will try. I think it might be a while until my next blog update, I have a feeling this next step will be my biggest challenge so far. (Including that Java thing...)

Monday, 2 January 2012

First day of coding

I had quite a busy day today which included (but was not limited to).. getting called into work on my day off, taking my dog for a walk up a mountain (I'm not kidding), colouring my wife's hair (again, not kidding), colouring my oldest daughter's hair (I shit you not), and generally getting caught up in all sorts of non-programming stuff.

But I did manage to get a few hours in this evening. And in those hours I have managed to get a bare bones scratchpad working. I loosely threw together some test code in order to check out object sizes, camera heights, a couple of automated calculations etc, and it looked like this...


...and then after food and a shower managed to get another hour or so on it, and it now looks like this...


...and I know it doesn't look like much, but...
  • The player character (Green square) can be controlled by the user in 8 directions
  • Travelling diagonally moves the same speed as vertically or horizontally (quite tricky to achieve)
  • The player cannot move outside of set boundaries (by mathematical checking, rather than collision detection)
  • The base is easily scalable - change two parameters and everything else adjusts automagically
So this will be the play area for the AI routine. I know it's basic but it's only a baby :)

Next, I intend to introduce a single NPC entity and see if I can get it chasing the Green square, er, I mean "Player". Alas, I'm back to work tomorrow so much like today, daytime coding is not happening. Just this minute I had an idea for something, so I'm off to make a note of it. Until next time, I bid you farewell.

Or something. 


Edit: Yes, I noticed the spelling mistake in the program. The question is, did you?  ;)


Sunday, 1 January 2012

New year, new project

Well I didn't seem to get much coding in over the Christmas holidays, there was simply too much going on around me. Family stuff, multiplayer gaming, a huge attic sort-out...

If you read this blog, you'll know I had a crack at Java which if I'm honest, is above me. I have no doubt that if I devoted enough time and energy to it, I could get a reasonable grip on it, but the whole idea of me getting back into coding was to create things, and I don't really want to put myself through learning a whole new language (again) to do that. Making a windows application in itself wasn't too hard - I did make an app where the user could click a button which would generate two random numbers, add them together, then display the result (all in a fancy window) - but when it comes to graphics and animation, it's a whole different ball game altogther.

So I'm back on familiar territory with my DBPro GUI. I want to look into AI (artificial intelligence) coding, but I'm not going to kid myself that I'm capable of making anything mind blowing. Just a simple 'target acquisition - tracking - movement' style thing will do me to start with. But I also want it to take the form of something I love, and that means a game of some sort. So I have an idea for my first test program.

It will involve a user-controlled character and a number of computer-controlled ones. The idea (at first) will be to avoid the NPC's (non-player characters) by moving away from them. Don't get me wrong, when I say "character" I mean "coloured square" or something. Start with the basics I say. I hope to get the NPC's to track and move towards the player, but at the same time, not move over each other. I think that's more than enough to be getting on with!

I also have some ideas that can be thrown into the mix later on, and for that reason, I am calling this project...

Zommers! (Cue theatrical soundbite)*



*If you're an internet geek like me, take this soundbite as being the music from Dramatic Hamster..


Monday, 26 December 2011

Complicated? Why yes, yes it is...

Well after tinkering with Java for a little while I have come to somewhat of a conclusion. (This might seem a little premature, but hey, I'm not getting any younger..)

Unless you have been tutored professionally, or have bucketloads of time to throw at it, Java is one hell of a mind-boggling beast! I've done a fair bit of reading and my usual amount of tinkering and messing about (I've never known such an unforgiving language!) but it seems that you have to jump through hoops just to get even the most basic of tasks accomplished.

This gives me even more respect for people who code fluently in this language.

I have managed to open a window, and render some rudimentary graphics but they really are basic. And I do mean basic. I started with this...


...and after some messing around, managed to persuade it to evolve to this...


...but it was far, far from straightforward. I also found that unless you dig really deeply, a lot of the language syntax can be confusing. For example a loop will execute the first line if you don't encase it in braces (and the compiler won't notify you that you have omitted said braces). So when you add a second line to the loop, the whole thing throws a wobbly and returns some totally unrelated error message - both in NetBeans and Eclipse. 

Believe it or not, here is a snippet of code I wrote to create that second image above. (Yes, I realise it's called "zombies", there is a story behind that which isn't worth going into here)...


...confused? So was I. And a single upper case letter where a lower case one should have been and, well, let's just say it didn't like it much.

When I first decided to have a look at this language, I had the idea of making a (really) simple game, maybe in an Applet that could run in a web browser. As soon as I started reading about graphics animation, I pretty  much changed my mind there and then. I might give this another look after I've had some sleep, but I think I'll be jumping back aboard HMS DBPro, where I feel more at home and it doesn't take 20 lines of code to draw a pattern in a window.

I think I'll leave Java to the professionals. And the young people :)

Sunday, 18 December 2011

First steps...

I know it's only been a day or so, but I have taken some tentative first steps and I want to log them here :)

The first thing I had to decide on was which GUI (Graphical User Interface) Environment to use with my Java experiment. As I don't know the first thing about this language, I'm not really qualified to make an informed choice about this, so after a little sniffing around I found the two most popular front-end tools seem to be Eclipse and Netbeans.

This is Eclipse...


... and this is NetBeans...


I know they look very similar, and as far as I can tell they pretty much do the same thing, so for the moment I'm leaving them both installed, hoping that if I've made the "wrong" decision as to which platform to use, I can change my mind later. If it even works like that, who knows?

Anyway, having browsed around java.com for a while, it seems that NetBeans is the GUI of choice, so that's what I'll stick with for now. If you're interested, Eclipse can be grabbed from HERE and NetBeans from HERE .

I don't know if you noticed on those pictures (which you can click on to enlarge, by the way), but my first Java code is in there. A fully working program! I have got a handle on how the structure of the language works (sort of, it's early days) and it looks a bit daunting, but manageable. Anyway, here's the code...


... and here's the resulting output...


Awesome or what ?! Now it's time to do some research...

Friday, 16 December 2011

Long time, no post :(

With the arrival of Battlefield 3 and a number of social events, it turns out that I have been neglecting my blog somewhat. However, with the excitement of BF3 dying down a little, and the upcoming potential free time due to Christmas holidays, I'm starting to get the creative itch again.

The EasyMatrix project is a fully working and usable application, and I do intend to use it at some point when I try and learn more about AI (Artificial Intelligence) programming, but at the moment I feel the urge to learn something new. I'm one of those people who can't stick with something for any length of time before being attracted to something new and shiny, but then I usually end up returning to the "old faithful" environments I'm comfy with.

I pretty much know my way around the DarkBasic language now, and finding solutions to programming problems is more a matter of "what to code" rather than "how to code it". If you're a programmer then that will make some kind of sense to you, I hope :)

So during the holidays I'm going to try and learn yet another programming language, namely Java. I have a few friends who already know Java reasonably well, and another couple of friends who have been meaning to take a look at it, but never got round to it. So I think I'm going to dip my toes in the water, and see what it's like. The only thing I do know for sure is that everything I need to learn the language is available for free online, so that's a huge plus in my book!

I'm going to try and keep this blog updated with my progress again, if only for historical reference so I can look back one day (while smoking my pipe and admiring my slippers) and think to myself - "remember when I tried to learn Java...."

It might turn out that after a bit of sniffing around, I decide that the language isn't for me, but right now my intentions are clear. I'll let you know how I get on.

Friday, 1 July 2011

Video Demo

Just a really quick blog update this time. (Yes, I've said that before, but this time I mean it...)

I have made a short video demo of EasyMatrix at it's final Alpha stage. It's pretty much finished apart from a front-end which I am working on now.

Before you watch the video, I need to explain a couple of things. Firstly, I used some free software to grab this video, and the colour rendering isn't brilliant, so towards the end - at the bit where I flood-fill the matrix with "grass" - the colour looks really weird. The program renders it perfectly, it's the video grabber that is distorting it. Also, the mouse pointer is visible throughout the video. It isn't there when you are actually using the software.

So that's it. Enjoy the video and I'll see you soon. Next stop planet Beta!