Saturday, November 26, 2011

What is GA?

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

27 comments:

  1. Can we get a GA algorithm to fuck her different ways each time? :P

    ReplyDelete
  2. Dude..... those little things will become nightmares.

    No one likes a enemy who gets each time more and more difficult to kill, on a infinite progression.... there´s a point where it just becomes boring.

    Games are made for relaxation. With a engine like this, you will turn this enemy into a always-becoming-more-powerfull one, witch means we will never graduate from this enemy.

    It´s pleasurabable to gain a few levels and then kill easily something you had to put effort to kill before. If that doesn´t happens, if they become always better... frustration.

    Take care. Your game are becoming a hardcore-gamer style of game, and there´s just a few people ho actualy enjoy it.

    ReplyDelete
  3. oh god master race roaches O_O!

    ReplyDelete
  4. Bwahaha, apparently roaches are smarter than any human bandit. Well, until they understand that simultaneous attack from all directions is best variant, I'm fine.

    ReplyDelete
  5. OK, this sounds good. I did´nt see their behavior up till now, so i´ll keep trying. Anyway, I think if it becomes so hard as you said, it may be a way to turn off this feature or the game can become insolvable. One possibility is a way to turn off the feature or even a situation where the roaches intteligence is down some levels ? An insectcide as a weapon, maybe sold by the male elf.

    I would like to contribute with an other idea aswell... Have you ever think of the possibility of the roaches attack Beth´s clothes by biting them? I mean, after a while, she could lost an item or more of the clothes she´s wearing (and also lost it from inventory) after a serious roach attack ?

    ReplyDelete
  6. Quote "No one likes a enemy who gets each time more and more difficult to kill, on a infinite progression.... there´s a point where it just becomes boring." "Take care. Your game are becoming a hardcore-gamer style of game, and there´s just a few people ho actualy enjoy it."

    You do know about the hardcore fps players right? they aren't just a few people, its majority of gamers.

    ReplyDelete
  7. Hi Hnyarly. I must say this is quite an achievement you've reached, but as Anon1 said, you have to ponder a lot about where you're going with this.
    Here's an example, if you're willing to implement the cloth destruction later, as you said you would, you'll have to make so that the these enemies that use this algorithm destroy the clothes in several different ways, plus the h-scenes have to vary aswell to smoothen up the game and follow the realistic pattern.

    Now pick up what you have done and these thoughts and think what you'll have to do for the later enemies. I'm not saying you should stop this, not at all, but I sincerely hope you have some backup to help you on achieving all this.

    ReplyDelete
  8. Hey HNyarly,

    can you by chance post your code or send me an email with the code, to bomberman600@yahoo.com? I'm actually studying genetic algorithm, and would love to see how you used it in the game. Thanks so much!

    ReplyDelete
  9. @Anon1
    Don't worry about the small roaches. They could learn the way to bite Beth, but they only deal 1 damage. Thus, they are not so dangerous.

    Anyway, I just want to offer players different kind of enemies. If I only program melee enemies with only 1 attack, the game would be pretty boring.

    @Milten
    The genotype I've programmed for the roaches doesn't allow them to combine their actions. Anyway, adding those kind of behaviours would make them more lethal. xD

    @Brasilian guy
    There is a way to make them stupid again, but I won't tell how. xD
    About the clothes destruction, it's a feature I'll add in a future. Now it's not a priority for me.

    @Last Anon
    The game is still under development. So, I can change the difficult depending of people opinions. So, if a lot of people consider roaches pretty difficult, I can remove the AI just setting a variable from true to false.
    :)

    @Charles
    I could send it to you, but it's so spliced into the enemies code* that it's almost unreadable. I mean, the genotype translation to actions is embebed in the chasing subroutine, and the fitness function into the attack subroutine.

    If you are really interested, I could send you a small schemata of how it works.


    *: I have something like a general enemy class. So, all kind of enemies share the same code. Just some small variables change their behavior. Variables like:
    - level (most of them depends of this one, like XP, HP, damageReduction...)
    - AI
    - flanking
    - piecingDamage
    - spells
    - fastRecovering
    ...etc.

    ReplyDelete
  10. one dmg may not seem like a lot but multiply it by the number of roaches there are and its a major pain i did notice the roaches kinda weave out of the way of my attacks tho and it is indeed highly interesting to see an evolving enemy I just hope they don't become impossible to kill once you kill them every way possible which would take a long time to do but will eventually happen

    ReplyDelete
  11. Please make this available in the play game section. Ive been having trouble downloading it

    ReplyDelete
  12. sounds crazy awesome

    ReplyDelete
  13. @ an above Anonymous, Are we forgetting armor? Put on boots and it negates the roaches entirely...

    ReplyDelete
  14. @Anon2
    what kind of problems? I prefer to upload it to another donwload site rather than upload the flash. At least for the momment.

    @Anon4
    Good thought, but the problem with the roaches is that they have (and only they, for the momment) a skill called "piercing damage" that allows them to ignore Beth's armour. So, they always deal 1 damage.

    ReplyDelete
  15. As the roaches get smarter, do you increment the AI variable for them? If so, perhaps you could implement a system where you get more XP depending on how smart they are.

    Maybe something like 0.5XP*AI. This way as they get smarter and harder to kill, you get more experience to raise your level to offset the added difficulty.

    ReplyDelete
  16. Well I love it . it is harder then i thought it would be. some of the old fight games from the 80s used self learning genetic algorithms witch in the long run made the game basically unwinnable so thy stopped. but that was one on one fight games . thy use them allot these days in mass battle generated effects for the movies. kewl to see someone put it into a role-playing game.
    for all those crying the roaches will be to hard stop trying to farm them for exp and then thy will not have time to learn much.

    ReplyDelete
  17. @Anon
    It's a good idea, but the fact is that there is not a reliable way to test the lethality of a roach. I actually use the roach lethality as fitness function for the GA, but it's not 100% trustworthy.

    @Ramses
    I never heard about those 80s games, but I'd love to. :)
    About the movies' crowded battle effect, I read that the algorithm was developed by WETA for LOTR. But I think they used Agents instead of GA... not sure.

    ReplyDelete
  18. -Little Wizard, wearing- I've seen roaches punch through a concrete wall. Men emptied entire MP bars at them and his nothing but air. Yet their strength and their speed are still based in a world that is built on rules. Because of that, they will never be as strong or as fast as you can be.

    Beth: So like, what are you trying to tell me? That I can, like... dodge roaches, and junk?

    -Wizard- No, Beth. I'm trying to tell you that when you're ready, you won't have to........ can I touch your boobs?

    -Beth- Like, ewwwwwww.

    ReplyDelete
  19. Crap... that was supposed to be "little wizard wearing sunglasses."

    ReplyDelete
  20. Baby roaches with GA,great add. Can be beat tho. Attain lvl 8 and attack until only the few smart are left. Retreat & run them into obstacles forcing them to change into ur path & terminate. No problem. Great game, keep it coming.

    ReplyDelete
  21. Hey Hnyarly,

    anything you want to give me would be fantastic. and thanks in advance!

    ReplyDelete
  22. @Dex
    Good dialogue. I may use it.
    xD

    @Slyfx
    That's the kind of gaming I expect from players against smart roaches. But... will they learn to face it?

    @Charles
    Thanks!

    ReplyDelete
  23. I'm not sure about this particular thing, but there are other games where the AI has learned behaviour just for the record.


    Smash Bros Brawl's AI imitating unusual player behaviour.
    http://www.youtube.com/watch?v=YMcEUsMd9Cw
    http://www.youtube.com/watch?v=diJX703iC0A

    ReplyDelete
  24. Sorry about being anon here, I like don't google accounts, lol.
    Anyways, I think it is a great idea to use GA in games, and I wish they would use it in games like Skyrim, that would make the games last much longer.
    Just started playing your game, I really enjoy it, I know that the next part of the game after you open the metal box doesn't work on Newgrounds, and I was wondering where I would have to go to play the next part of it, or if it is a download.

    ReplyDelete
    Replies
    1. Don't worry about google accounts. xD

      The nest part is available as executable only. You can download it here:
      http://hnyarly.blogspot.com.es/p/downloads.html

      Delete