
/*************************************************************/
/*                                                           */
/* Exemple de jeux                                           */
/*                                                           */
/*************************************************************/

game jeu_de_base =
{
    perception =
    {
        C => x b (C:t) | C\=($ _)
    },

    update =
    {
        x b (y ? Q:_) => x b y w y kif Q,
        x b (y ! P:_) => x b y b P,
        x b (y ! P:_) and x w x kif P => x b P,

        x b P => -(x b -P),

        x b (y ! P:_) => x b y b x a x kif P
    },

    generation =
    {
        -(x w _) and -(x b y w _) => $ x # 0.01
    },

    interdiction =
    {
        x b (C:T) => -C | T<t # 100
    }
}.

game question(Q) =
{
    import jeu_de_base,

    entrance = x w x kif Q,
    invariant = x w x kif Q,
    exit = x kif Q,

    generation =
    {
        x w x kif Q => x ? Q # 10
    },

    update =
    {
        x kif Q => -(x w x kif Q)
    }
}.

game reponse(Q) =
{
    import jeu_de_base,

    entrance = x b y w y kif Q and x b y a y kif Q,
    invariant = x b y w y kif Q,
    exit = x b y kif Q,

    generation =
    {
        x b Q => x ! Q # 10,
        -(x b Q) => x '!?' Q
    },

    update =
    {
        x b (P->Q) and -(x kif P) => x w x kif P,
        x b y kif Q => -(x b y w y kif Q),

        x b (x ! P:_) and x b y w y kif P => x b y b P

    }
}.

game conflit(Q) =
{
    import jeu_de_base,

    entrance = x b y b -Q and x b Q,
    invariant = x b y b -Q and x b Q,
    exit = x b y b Q or x b -Q,

    generation =
    {
        x b (P->Q) => x ! P # 100,
        x b (P->Q) => x ! (P->Q),
        x b Q => x ! Q
    },

    update =
    {
        x b y b Q => -(x b y b -Q),
        x b -Q => -(x b Q)
    }
}.

game mefiance(Q) =
{
    import jeu_de_base,

    entrance = x b y w Q and -(x b y a Q),
    invariant = x b y w Q and -(x b y a Q),
    exit = x b y a Q or -(x b y w Q),

    update =
    {
        x b (y ! P:_) and x b (P -> (y a Q)) => x b P,
        -(x b y a Q) => x w x kif y a Q
    },

    generation =
    {
        -(x b y a Q) => x ! -(y a Q)
    }
}.

agent agent_de_base(PROF) =
{
    
    start = jeu_de_base,

    games = { question(_), reponse(_) },

    depth = PROF,
    
    kb =
    {
        nonvar(Q) | x b (P->Q) and x b P then x b Q,
        nonvar(P) | x b (P->Q) and x b -Q then x b -P,

        x b (p(X)->(X a Q)),

        nonvar(P) | (x b P) or (x b -P) then x kif P
    }
}.

agent agent_evolue(PROF) =
{
    import agent_de_base(PROF),

    kb =
    {
        x b p(a1)
    }
}.

agent a1 =
{
    import agent_de_base(1),
    
    accointance = agent_de_base(1),
    
    games = { conflit(_) },

    kb =
    {
        x w x kif q,
        x b p(x)
    }
}.

agent a2 =
{
    import agent_de_base(1),

    games = { mefiance(_) },

    kb=
    {
        x b q
    }
}.

a1 and a2 are speaking.

