Whether an Ai library should look like a game engine

  • 9 Replies
  • 3404 Views
*

Zero

  • Eve
  • ***********
  • 1287
Whether an Ai library should look like a game engine
« on: July 10, 2018, 09:47:32 am »
I was reading Crafty.js documentation, ad I thought that maybe an Ai library should look like a game engine, based on the entity-component-system paradigm. See for yourself!

*

spydaz

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 322
  • Developing Conversational AI (Natural Language/ML)
    • Spydaz_Web
Re: Whether an Ai library should look like a game engine
« Reply #1 on: July 10, 2018, 11:23:26 am »
I was reading Crafty.js documentation, ad I thought that maybe an Ai library should look like a game engine, based on the entity-component-system paradigm. See for yourself!

The engine for the AI is based around a "game loop" and a state machine.... to hold the current state from turn to turn... the AI library holds the language functions... used to create the functions for the game loop. Then UI ...the UI executes the engine displaying the results...

Engine + Library + UI

Plus external memory (database etc)..

I would say this is the standard setup....


*

Zero

  • Eve
  • ***********
  • 1287
Re: Whether an Ai library should look like a game engine
« Reply #2 on: July 10, 2018, 01:34:06 pm »
Yep, it sounds good. And the way you use Crafty, as a programmmer, is very appealing. I mean, imagine setting up a virtual mind like this, binding modules, ...etc.

*

spydaz

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 322
  • Developing Conversational AI (Natural Language/ML)
    • Spydaz_Web
Re: Whether an Ai library should look like a game engine
« Reply #3 on: July 10, 2018, 10:11:50 pm »
Yep, it sounds good. And the way you use Crafty, as a programmmer, is very appealing. I mean, imagine setting up a virtual mind like this, binding modules, ...etc.

As U.I its a good thing .... with an independent brain library. referencing the library from the crafty u.i  its also quite lightweight.... probably easy to repackage or redistribute.


*

ranch vermin

  • Not much time left.
  • Terminator
  • *********
  • 947
  • Its nearly time!
Re: Whether an Ai library should look like a game engine
« Reply #4 on: July 10, 2018, 10:37:01 pm »
game programming,  the beginning of everything for a little dude.  where all the experience stems from.

*

spydaz

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 322
  • Developing Conversational AI (Natural Language/ML)
    • Spydaz_Web
Re: Whether an Ai library should look like a game engine
« Reply #5 on: July 11, 2018, 12:39:45 am »
game programming,  the beginning of everything for a little dude.  where all the experience stems from.

Technically chat-bots are turn based games...so a game loop is a good place to begin!

After a year or so developing my AI language i had to remake the game loop! ...

Recently Jacks website haptek dissipated.... so i recompilled it and combined the Haptek AXPlayer (source-code) directly into my source-code. to maintain my UI .... As well as upgrading the haptek to have a .net 4.5 base.. as the .net 2.0 which was in use crashed the visual studio ... as well as forcing the app to have to run as administrator before actually working...i don't know why he didn't recompile ages ago... plus i always say Machine based Serial number mess up your resalability of an Application...each time you reinstall activation does not work! .... same problem with ultra-hal activation... finding a good alternative UI can be an issue... even open source UI programs fall out of scope like the haptek or ms agent ...

It seems to be an Issue with avatar creation....

*

ranch vermin

  • Not much time left.
  • Terminator
  • *********
  • 947
  • Its nearly time!
Re: Whether an Ai library should look like a game engine
« Reply #6 on: July 11, 2018, 02:01:36 am »
How about cellular automata games.   best of both worlds.

*

8pla.net

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1302
  • TV News. Pub. UAL (PhD). Robitron Mod. LPC Judge.
    • 8pla.net
Re: Whether an Ai library should look like a game engine
« Reply #7 on: July 12, 2018, 06:33:00 pm »
Politely, I think, not.

A Game Engine already has a Game A.I. Library.

But, I am willing to keep an open mind about it.

My Very Enormous Monster Just Stopped Using Nine

*

Zero

  • Eve
  • ***********
  • 1287
Re: Whether an Ai library should look like a game engine
« Reply #8 on: July 12, 2018, 10:06:00 pm »
Well, most Js game engines do not have Ai modules. I'm playing with the idea of using Crafty because it's lightweight, it has a decent entity-component-system api, and it feels sane.  My idea is to use entities to store facts about real world entities.

I found 3 nice reads here:
http://www.gameaipro.com/GameAIPro/GameAIPro_Chapter06_The_Behavior_Tree_Starter_Kit.pdf
http://www.gameaipro.com/GameAIPro/GameAIPro_Chapter09_An_Introduction_to_Utility_Theory.pdf
http://www.gameaipro.com/GameAIPro/GameAIPro_Chapter10_Building_Utility_Decisions_into_Your_Existing_Behavior_Tree.pdf

Around a central behavior/utility tree, Crafty could handle external IO (avatar & user input) and memory IO (entities as knowledge about the world). Compromise would do some nlp. Rivescript would then output a search request which Lunr could use to highlight a few relevant LogicJS assertions...

could/would... would/could... easy to say!
« Last Edit: July 12, 2018, 10:43:38 pm by Zero »

*

Zero

  • Eve
  • ***********
  • 1287
Re: Whether an Ai library should look like a game engine
« Reply #9 on: July 13, 2018, 09:21:42 am »
So I've setup a minimal (little rough) behavior tree structure in Js. Here is the code:

Code
    var Idle = Symbol("Idle"),
        Running = Symbol("Running"),
        Success = Symbol("Sucess"),
        Failure = Symbol("Failure");

    var b = {
        "select": function() {
            return {
                status: Idle,
                current: 0,
                children: Array.from(arguments),
                tick: function() {
                   
                    if (this.status == Idle) {
                        this.current = 0;
                        this.status = Running;
                    }

                    if (this.children[this.current].status == Success) {
                        this.children[this.current].status = Idle;
                        this.status = Success;
                        return;
                    }

                    if (this.children[this.current].status == Failure) {
                        this.children[this.current].status = Idle;
                        this.current++;
                        if (this.current == this.children.length) {
                            this.status = Failure;
                        }
                        return;
                    }

                    tick(this.children[this.current]);
                }
            };
        },
        "sequence": function() {
            return {
                status: Idle,
                current: 0,
                children: Array.from(arguments),
                tick: function() {
                   
                    if (this.status == Idle) {
                        this.current = 0;
                        this.status = Running;
                    }

                    if (this.children[this.current].status == Success) {
                        this.children[this.current].status = Idle;
                        this.current++;
                        if (this.current == this.children.length) {
                            this.status = Success;
                        }
                        return;
                    }

                    if (this.children[this.current].status == Failure) {
                        this.children[this.current].status = Idle;
                        this.status = Failure;
                        return;
                    }

                    tick(this.children[this.current]);
                }
            };
        },
        "selectMaxUtility": function() {
            return {
                status: Idle,
                children: Array.from(arguments),
                tick: function() {
                    if (this.children.length == 0) return;
                    var max = 0;
                    var best = 0;
                    for (var c=0; c<this.children.length; c++) {
                        var u = this.children[c].utility();
                        if (u > max) {
                            max = u;
                            best = c;
                        }
                    }
                    tick(this.children[best]);
                }
            };
        },
        "print": function() {
            return {
                status: Idle,
                text: Array.from(arguments).join(''),
                tick: function() {
                    console.log(this.text);
                    this.status = Success;
                }
            };
        },
        "fail": function() {
            return {
                status: Idle,
                tick: function() {
                    this.status = Failure;
                }
            };
        }
    }


    function tick(node) {
        return node.tick(node);
    }

Used like this:

Code
    var bt = b.sequence(
        b.print("1 foo"),
        b.select(
            b.fail(),
            b.fail(),
            b.print("2 foo"),
            b.fail(),
            b.print("3 foo")
        ),
        b.print("4 foo"),
        b.fail(),
        b.print("5 foo")
    );


    while ((bt.status != Success) && (bt.status != Failure)) {
        tick(bt);
        console.log(bt.status);
    }

It logs:

1 foo
Symbol(Running)
2 foo
Symbol(Running)
4 foo
Symbol(Running)
Symbol(Failure)

Which is ok.

Now I'll try and insert the utility concept, with new node types that fetch utility score from children, and make feedback to their parents.

Ed: Added, start testing now.
« Last Edit: July 13, 2018, 10:28:59 am by Zero »

 


OpenAI Speech-to-Speech Reasoning Demo
by ivan.moony (AI News )
Today at 01:31:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am
Nvidia Hype
by 8pla.net (AI News )
December 06, 2023, 10:04:52 pm
How will the OpenAI CEO being Fired affect ChatGPT?
by 8pla.net (AI News )
December 06, 2023, 09:54:25 pm
Independent AI sovereignties
by WriterOfMinds (AI News )
November 08, 2023, 04:51:21 am
LLaMA2 Meta's chatbot released
by 8pla.net (AI News )
October 18, 2023, 11:41:21 pm

Users Online

299 Guests, 0 Users

Most Online Today: 343. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles