Some of you are wondering what's behind the weird behaviour of the small roaches, and why more of them copy that behaviours.
I've implemented an AI for the small roaches. And I'm not meaning a few lines of code with some "smart behaviour", I mean a REAL Artificial Intelligente. The technique I've used is called Genetic Algorithm.
By this way, they learn how to hit and avoid be hit by the player. They also teach the other roaches how to do it. This knowledge is stored in the game, so each time you play, they keep what they know. xD
That's why they start to do weird things, and each time you play, they do more. And if you discover a way to defeat them, they'll learn the way to counter your strategy. xD
That's the algorithm never seen before in a H-game, not even in any game.
:p
Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts
Saturday, November 26, 2011
Tuesday, October 18, 2011
Better living through algorithmic
I'm spending some days at my mom's house. The next point I wanted to do is the H-events missing in the previous release. But I can't do them when she is around me. So, when I can't do H-events, I work in the next point from my list: "Improving the depth assignation algorithm."
More than a list, it should be a diagram:
The fact is that I was examining my first depth algorithm and I discovered than it actually doesn't need to be improved, because it was quite good. That's why is good to know algorithmic. Here you have the explanation of how it works: WARNING - the next part of the entry can be really boring.
The objective of the depth algorithm I first designed is to order the sprites in game (Beth, enemies, items, rocks, trees... etc) by its Y coordinate. So, sprites with higher Y coordinate must be drawn above sprites with less Y coordinate. So, each photogram, I must re-order the array of sprites by its Y coordinate and give them the corresponding Flash's depth.
Most of people believe that the best sorting algorithm is Quicksort. They are wrong. The best sorting algorithm for a problem depends of the problem. In this case, the event of a sprite moving behing another is something that rarely happens. Thus, the array of sprites doesn't need to be sorted in most of cases, or at lest, barely sorted. And for those cases, the best sorting algorithm is Insertion, that in this case is mostly linear -> O(n).
And that's why I haven't needed to change my depth assignation algorithm.
More than a list, it should be a diagram:
The fact is that I was examining my first depth algorithm and I discovered than it actually doesn't need to be improved, because it was quite good. That's why is good to know algorithmic. Here you have the explanation of how it works: WARNING - the next part of the entry can be really boring.
The objective of the depth algorithm I first designed is to order the sprites in game (Beth, enemies, items, rocks, trees... etc) by its Y coordinate. So, sprites with higher Y coordinate must be drawn above sprites with less Y coordinate. So, each photogram, I must re-order the array of sprites by its Y coordinate and give them the corresponding Flash's depth.
Most of people believe that the best sorting algorithm is Quicksort. They are wrong. The best sorting algorithm for a problem depends of the problem. In this case, the event of a sprite moving behing another is something that rarely happens. Thus, the array of sprites doesn't need to be sorted in most of cases, or at lest, barely sorted. And for those cases, the best sorting algorithm is Insertion, that in this case is mostly linear -> O(n).
And that's why I haven't needed to change my depth assignation algorithm.
Monday, July 11, 2011
A new DB
You don't notice, but today I've done a big progress in the game. I've made an items data base that will do the creating items task easier. But when playing, you won't see any diference. But actually I'm quite proud of my work today. xD
That's how I previosly create items (sorry for the spanglish code xD):
For each item I created, I had to initialize those variables:
- superponible: mmmmm, sorry, I don't know how to translate. xD
- clase: name of the movieclip.
- descripcion: description. That wasn't hard to traslate. xD
- tipo: type
- equ: equipable - same than spanish.
- ds: distance to pick.
The fact is that I needed to add more variables to the items (Buy/selling price, increased seduction (when equipped), armour and fire resistance). So I had to wrote all this new variables in each of the more than 20 items I had. It seemed lot of boring work. And then I have the great idea:
I created an item data base with excel:
And with a couple of fixes, I can easily import this to AS2. So, adding and editing new items are now much easier for me.
:)
That's how I previosly create items (sorry for the spanglish code xD):
For each item I created, I had to initialize those variables:
- superponible: mmmmm, sorry, I don't know how to translate. xD
- clase: name of the movieclip.
- descripcion: description. That wasn't hard to traslate. xD
- tipo: type
- equ: equipable - same than spanish.
- ds: distance to pick.
The fact is that I needed to add more variables to the items (Buy/selling price, increased seduction (when equipped), armour and fire resistance). So I had to wrote all this new variables in each of the more than 20 items I had. It seemed lot of boring work. And then I have the great idea:
I created an item data base with excel:
And with a couple of fixes, I can easily import this to AS2. So, adding and editing new items are now much easier for me.
:)
Subscribe to:
Posts (Atom)



