Thursday, 24 April 2008
Its been slow going...
I have some basic images in the game now, Little Sheverons for the units, and an Illustrator house for the buildings. The units in the squad that is currently sellected changes colour to represent their health.
I've ran into a dilema. I want to have stacking behaviours. I have the code. It works. But its kinda pointless and making it far more complicated than it really should be. Having to code in the exact same stuff for each beheviour is not very good coding wise. Thus i think i'll take out behaviours as the are at the moment and start again. :( what i think i'll do is comment out all the code that is currently in all the behaviour classes and the unit and squad class and start again from scratch.
I'm thinking of each uni having 1 of each behaviour, but only having IDLE to start with. Then using some "Fuzzy Logic" to decide what behaviours to call etc. sigh should really be past here by now and on to the writing. I have 10/11 days to get my first draft done so I can show Euan. That shouldn't be too hard, but have maths as well. I think its tea time then i'll start on the raping of my current code and all that jazz.. :( woooo :D
Sunday, 13 April 2008
Fuzzy Logic
Waypoints were indeed broken, but have now been fixed
multi-objects works now, it didn't, but it has been added and thus fixed :P
What i need to do now is figure out what behaviours a unit should have... sounds thought might have to be done.
Saturday, 12 April 2008
A* Finished
There is now two methods of using the A* pathfinding.
- Creating nodes of equal distance appart in a "grid" accross the screen, any impassable objects created will delete any nodes that are totaly obscured by the object and re-align the surrounding nodes to not point at it.
- Any new impassable object that is created will also create nodes on the corner of that object and will connect to other nodes in line of sight* and should reduce the cpu/memory overheads and allow more units on the screen
Still to do: Add in an option to the options menu to allow the user to change the number of nodes wide and high that will be used for Method 1. of A* this number will effect the speed and accuracy of the pathfinding :)
*oh btw, i would check to see if multi-objects work
Started doing the outline of the write-up, looking good, now just need to start filling it in. Between that and the AI essay
Next thing to do is implement fuzzy logic.
Sunday, 30 March 2008
Pathfinding Day v000.002
First things first. I am going to be using A* Pathfinding. But before generating the route using the A* algorithm, check to see if there is a direct "Line Of Sight" path between the starting position and the target position. This was implemented first by the use of c#'s Ray, BoundingBox and their .Intercetced methods... These all handle 3D calculations, which is good for 3D, but since this app is only in 2D it does not really make sense to use it... also it wasn't giving the correct results. The only (and best) answer was to write it myself, this was good because it teaches me how to do do thinks like RayBox intersection, and other line of sight algorithm... thing-ys.
A Unit class was created in order to controll the moving of the Units on the screen. This included ablity to select a "Target Position" where the Unit will move towards at a constant speed until it reaches that position.
Once this had been completed, a new sprite was added to act as a in game object that will block the units Line Of Site thus stopping the unit from moving (The Cursor will change to represent this error) ... And now it does heehee! It was during the creating of the line of sight and navigation around the in game "Obstruction" that the idea of including waypoints in the game would be a nice addition. Thus they were added. By clicking with the mouse the first "Unit" will move to the location as long as it is within Line Of Sight, if the user holds the [Shift] key while clicking, it will create waypoint and queue up the movments. Each new waypoint must be in Line Of Sight from the last created waypoint in order to be created. If the user clicks without holding [Shift] any waypoints will be destroyed and the "Unit" will move towards this new TargetPosition.
Proper Starting now...
I then set about importing the work that was done previously. Since the layout of the code was so different it was decided that starting from scratch with the sprite class would be the right thing to do. The sprite class created included the ability to animate sprites from a tilesheet of images of any size and frame count, as well as controlling the frames per second of the animation.
Once the sprite was implemented it was time to call it a night.
Last Few Weeks
Done my progress report, even though it was pointless. Wrote a very good abstract for it before finding out that an abstract was not needed for the progress report... oh well lest I half have one for the final submission. I wonder if we will ever get feedback on the progress report... no, but i'll ask
Kinda realated on the 12th and 13th of March went down to Pourtsmouth and then up to Cambridge for interviews at Climax then Frontier respectivly. The Climax interview was going quite well even though it seamed especialy demmanding for a graduate position but was a bit stuck on a question and it went downhill quickly.
Fortunatly the Frontier interview went much better, so much so that i'm going back down on the Tuesday 1st of April wooo so fingers crossed, sounds like a good place to work :)
Monday 17th March, 07:31, Started coding again, this time in XNA wooo
07:48 finished coding for the day lol. Got a sprite moving about the screen using the mouse to set a way point.
Wooo Thats a start at least. Then had a meeting with my supervisor at 11:00. Said that I would have the intro and background reserch sections of the writeup done for the 10th April as well as having the majority of the programming completed.
Tuesday 25th Interview at Cohort Studios, Dundee. Went quite well I think. Just have to wait and see, Nail is having an interview on Thursday so it is unlikely i will get a response before then, and even then, Nail will probably get it since he has quite impressive demos... oh well.
Tuesday, 4 March 2008
Progress Meeting - 4th March
Progress report was supposed to be due for tomorrow, but has been moved back to Friday! woo
Planning on doing some work on it today... not going to happen! lol well maybe after the Sega thing thats at 3! Damn, has to be done today, cause tomorrow will only have a few hours in the morning, and will have to work on Thursday :( grrr oh well, better make a start :( boo! lol
Wednesday, 27 February 2008
Lecture
Have to use a (standard?) template from a website and in the introduction we have to write about what we are going to cover in each section "In Section 1, the theory behind the dissertation will be discused with the following topics being covered: pathfinding..." etc
Switch To XNA
Tuesday 26th February - Progress meeting with Euan. Talked about using XNA, he seemed happy with the change. Added some interesting things... Having multiple arrays (or array of structs makes more sence) for the pathfinding/fuzzy logic. 1 array for the terrain and the difficulty of transversing it, a second for line of sight of the enemy (for use depending on how brave the units are feeling i.e. if 100% health, full squad, full ammo: being in the line of sight of the enemy is not a big reason to avoid a tile), a third for the amount of frendlies killed/hurt in that tile (more likely to avoid tiles that have frendly dead bodies), perhaps a forth for where cover is around the map (more injured the units the more likely they will head for cover) etc.
He said something else I was going to include but I completly forgot after leaving the room :( hopefuly it will come back to me.
Wednesday 27th February - Just updating the blog before going to the lecture on... No idea, I think he probably just give the "Progress Reporting" lecture again... or talk about time management... joy! We will soon see.
looking at watching more videos after the lecture until 12 (when i have a meeting with some fokes about doing Dare To Be Digital in the summer) then will spend all Thursday watching them too, hopefuly get a fair chunk of them watched by the weekend and can get started on the programming... oh no wait! I have to do a progress report... why?!? we have progress meetings every week *sigh* also have a maths exam on Monday the 3rd *sigh* lol oh well needs to get done. So probably no progress this week, hopefuly have some actual code done for the next time I meet Euan, unless Bob springs upon us some other pointless activity to "manage our time/project" or whatever.
Wednesday, 20 February 2008
Project Completion Lecture
Least it gave me the time to start this blogg-y thing-y which is kinda useful :) wooo
Progress Report
Ok, so this should have been started at the beginning of term, before I had started anything so it was all documented... oh well, better late than never?
First of, what the hell am I doing? Well... my dissertation title goes something like:
"Can a Realistic Squad Based AI be Simulated using Advanced AI Techniques in Real Time?"
Sexy eh?
Now what does that mean? If you've ever played the game Cannon Fodder, then you'll understand my ultimate aim, to make a sexy realistic version of that. Although, to be honest, I’ve not really played it much, just love the idea.
My idea is to have a very polished looking game at the end, one that I will be happy to show people and one that will get me at least a B (as getting a 2:1 looks most likely now... unless I get an A for maths...) So with that in mind, I want.
- A squad of units that the player can control and order about a battlefield
- Each Unit is its own entity, with its own stats, health etc. and can operate completely on its own (or an Agent in AI speak)
- Each unit will have full A* pathfinding allowing transversing of the battlefield.
- Line of sight might be used first to speed up the pathfinding in a low obstacle environment.
- The squad as a whole will have a basic flocking algorithm:
- Cohesion for keeping the squad together and moving as one
- Avoidance to stop the units bumping into each other, or occupying the same position
- With Fuzzy Cognitive Maps controlling all the AI
First thing I did was head to the library and pick up a load of books. "Fuzzy Thinking" was the first of these that I started reading and was a fairly useful book. It taught me the basics of Fuzzy Logic but appeared to repeat the first several pages over and over for the first 100 pages, so instead of reading all that I switched onto another book, "Understanding Neural Networks and Fuzzy Logic: Basic Concepts and Applications". I have never seen so much maths in a programming book so it was quickly put to one side and onto the next book, which was by far the most useful book I've read on AI, "AI for Game Developers"
Fuzzy Cognitive Maps is where the "Realistic" part comes in. FCMs are a branch of Fuzzy Logic, which itself is a branch of Finite State Machines. FCMs take in lots of distinct inputs and by using various weightings on these inputs together with the current state of the FCM, "fuzzifys" the numbers and generates a fuzzy output. This fuzzy output is "Defuzzified" into a distinct output for use within the Finite State Machine part of the FCM system.
All this good stuff was detailed within that awesome book :D
"AI for Game Developers" also had a great chapter on A* pathfinding as well as one on flocking, so is pretty complete for what I want to do.
On Saturday the 16th February I started coding the project, probably about 2 months behind the schedule I had to make up for the Dissertation Proposal, but creating the Gantt chart was a pointless exercise at the time as there was not enough information and an accurate one for me would have looked very bad... Perhaps that’s due to my interesting working style and maybe that’s what should change, but it seams to be working so far :P
So far, after only that 1/2 day of programming, I have a basic framework set up (in C# woo feel the <3) with a Unit, Squad and Terrain class, with the terrain class loading in my amazing programmer art and being able to scroll about the screen. The next thing to do is get a Unit on the screen and get A* pathfinding working based around this terrain.
Tuesday 19th February
Progress Meeting with bob (Súhyl):
Fairly useless as always, things he wants me to do in the next two weeks:
Implement A*
Progress Report
GUI
First Blog
So, I used to blog when I used MySpace but since that’s old and is annoying as anything to use, Bebo became my best-ist friend, although not really suited to blogging, thus the blogging stopped. I decided to start the blogging back up but with a more sinister motive, to document my progress in my dissertation as well as my working life. This will, hopefully, make it easier for me to remember what I did and when I did it so when it comes to writing my dissertation I will have a detailed account of what I have been up to. Also this blog will hopefully encourage me to actually do more work as I will feel guilty about not adding an entry to here! heehee
So here goes...