Whether an Ai library should look like a game engine

  • 9 Replies
  • 611 Views
*

Zero

  • Trusty Member
  • ********
  • Replicant
  • *
  • 695
    • Thinkbots are free
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!
Thinkbots are free, as in 'free will'.

*

spydaz

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 309
  • Developing Conversational AI (Natural Language/ML)
    • SpydazWeb
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

  • Trusty Member
  • ********
  • Replicant
  • *
  • 695
    • Thinkbots are free
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.
Thinkbots are free, as in 'free will'.

*

spydaz

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 309
  • Developing Conversational AI (Natural Language/ML)
    • SpydazWeb
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
  • *********
  • 901
  • 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
  • *
  • 309
  • Developing Conversational AI (Natural Language/ML)
    • SpydazWeb
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
  • *********
  • 901
  • 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
  • **********
  • Millennium Man
  • *
  • 1017
    • 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

  • Trusty Member
  • ********
  • Replicant
  • *
  • 695
    • Thinkbots are free
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 »
Thinkbots are free, as in 'free will'.

*

Zero

  • Trusty Member
  • ********
  • Replicant
  • *
  • 695
    • Thinkbots are free
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: [Select]
    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: [Select]
    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 »
Thinkbots are free, as in 'free will'.

 


A.G.I drugs [not a joke]
by WriterOfMinds (General AI Discussion)
Today at 05:27:41 pm
Good language for metaprogramming?
by Zero (General Chat)
Today at 02:24:58 pm
An execution model inspired from thought stacks
by Zero (General Project Discussion)
September 17, 2018, 08:40:35 pm
We can't prove or disprove some sentences
by Zero (General Chat)
September 17, 2018, 03:19:52 pm
Thetaball
by Art (Gaming)
September 17, 2018, 01:45:57 pm
XKCD Comic : Beverages
by Tyler (XKCD Comic)
September 17, 2018, 12:00:48 pm
What's everyone up to ?
by Ultron (General Chat)
September 16, 2018, 04:58:38 pm
ANSI charactors
by Ultron (General Chat)
September 16, 2018, 03:51:57 pm

Users Online

33 Guests, 1 User
Users active in past 15 minutes:
ivan.moony
[Trusty Member]

Most Online Today: 51. Most Online Ever: 208 (August 27, 2008, 09:36:30 am)

Articles