#!sdl_chomik

let please print all possible actions of the person 1=value code
{
    <print (ACTION_NUMBER:range 1..<my amount of possible actions the person 1 can perform>) <name of person 1>
        "can" <my possible action (ACTION_NUMBER:range 1..<my amount of possible actions the person 1 can perform>) the person 1 can perform>>;
};


let please add the possible action for the person (CODE:code)=value code
{
    let my how to do it = value code [(CODE:code)];

    <add "integer" <my amount of possible actions the person <my person id> can perform> 1>;
    let my amount of possible actions the person <my person id> can perform = <the add result "integer">;

    let my possible action <the add result "integer"> the person <my person id> can perform = <my possible action>;
    let my how to do the action <the add result "integer"> the person <my person id> can perform = value code [(CODE:code)];

    let my possible action index = <the add result "integer">;
    #<print "how to do" <my possible action> "=" <my how to do the action <the add result "integer"> the person <my person id> can perform>>;
};


let please print all perceived informations of the person 1=value code
{
    let my amount of perceived informations = <my amount of perceived informations the person 1 believes in>;
    <print "the person 1 believes in" <my amount of perceived informations> "perceived informations">;

    <print <my perceived information (A:range 1..<my amount of perceived informations>) the person 1 believes in>>;
};


let please add the perceived information for the person=value code
{
    <add "integer" <my amount of perceived informations the person <my person id> believes in> 1>;
    let my amount of perceived informations the person <my person id> believes in = <the add result "integer">;

    let my perceived information <the add result "integer"> the person <my person id> believes in = <my perceived information>;
};



let assign the perception whether he has the key on lower = value code {}; # this would be a lie!
let assign the perception whether he has the key on greater = value code {}; # this would be a lie!
let assign the perception whether he has the key on equal = value code
{
    let my perceived information = value information person <my person id> has key <my key id>;
    <please add the perceived information for the person>;
    <print "person" <my person id> "has the key" <my key id>>;
};

let assign the perception whether he can see the key on lower = value code {}; # this would be a lie!
let assign the perception whether he can see the key on greater = value code {}; # this would be a lie!
let assign the perception whether he can see the key on equal = value code
{
    let my perceived information = value information person <my person id> can see key <my key id>;
    <please add the perceived information for the person>;
    <print "person" <my person id> "can see key" <my key id>>;

    # if he can see it, he can pick it up!
    let my possible action = value action pick up the key <my key id>;
    <please add the possible action for the person { <perform action pick up the key>; }>;
    let my possible action <my possible action index> for the person <my person id> the key = <my key id>;
};

let assign the perception whether he has the key (KEY:integer)=value code
{
    let my key id = value integer [(KEY:integer)];
    #<print "check whether he can see the key" <my key id>>;
    let my pocket item location = value item_location in persons <my person id> pocket;
    let my actual key location = <my location of the key <my key id>>;

    <compare "item_location" <my actual key location> <my pocket item location>>;
    #<print "the actual key location for the key" <my key id> "is" <the compare result>>;
    <assign the perception whether he has the key on <the compare result>>;

    let my place item location = value item_location in place <my place of the person <my person id>>;
    <compare "item_location" <my actual key location> <my place item location>>;
    <assign the perception whether he can see the key on <the compare result>>;

};

let consider giving the person the key on lower = value code {};
let consider giving the person the key on greater = value code {};
let consider giving the person the key on equal = value code
{
    let my possible action = value action give person <my person 2 id> the key <my key id>;
    <please add the possible action for the person {<perform action give the key to someone else>; }>;

    let my possible action <my possible action index> for the person <my person id> the key = <my key id>;
    let my possible action <my possible action index> for the person <my person id> the target person = <my person 2 id>;
};


let consider giving the person any of your keys (KEY:integer)=value code
{
    let my key id = value integer [(KEY:integer)];

    #<print "consider giving him the key" <my key id>>;
    let my pocket item location = value item_location in persons <my person id> pocket;
    let my actual key location = <my location of the key <my key id>>;

    <compare "item_location" <my actual key location> <my pocket item location>>;
    <consider giving the person the key on <the compare result>>;
};


let please add the perceived information for the person if not obvious on lower = value code
{
    <please add the perceived information for the person>;
    <print "person" <my person id> "can see person" <my person 2 id>>;

    let my possible action = value action attack person <my person 2 id>;
    <please add the possible action for the person { <perform action attack someone else>; }>;
    let my possible action <my possible action index> for the person <my person id> the target person = <my person 2 id>;

    <consider giving the person any of your keys (KEY:key_id)>;
};

let please add the perceived information for the person if not obvious on greater = value code
{
    <please add the perceived information for the person>;
    <print "person" <my person id> "can see person" <my person 2 id>>;

    let my possible action = value action attack person <my person 2 id>;
    <please add the possible action for the person { <perform action attack someone else>; }>;
    let my possible action <my possible action index> for the person <my person id> the target person = <my person 2 id>;

    <consider giving the person any of your keys (KEY:key_id)>;
};
let please add the perceived information for the person if not obvious on equal = value code {};



let assign the perception whether he can see the person on lower = value code {}; # this would be a lie!
let assign the perception whether he can see the person on greater = value code {}; # this would be a lie!
let assign the perception whether he can see the person on equal = value code
{
    let my perceived information = value information person <my person id> can see person <my person 2 id>;
    let my obvious information = value information person <my person id> can see person <my person id>;
    <compare "information" <my perceived information> <my obvious information>>;
    <please add the perceived information for the person if not obvious on <the compare result>>;
};

let assign the perception whether he can see the person (PERSON2:integer)=value code
{
    let my person 2 id = value integer [(PERSON2:integer)];
    #<print "check whether he can see the person" <my person 2 id>>;
    let my place = <my place of the person <my person id>>;
    let his place = <my place of the person <my person 2 id>>;

    <compare "integer" <my place> <his place>>;
    <assign the perception whether he can see the person on <the compare result>>;
};

let consider going to the place if possible on lower = value code
{
    let my possible action = value action go to place <my place id>;
    <please add the possible action for the person { <perform action go to place>; }>;
    let my possible action <my possible action index> for the person <my person id> the target place = <my place id>;
};

let consider going to the place if possible on greater = value code
{
    let my possible action = value action go to place <my place id>;
    <please add the possible action for the person { <perform action go to place>; }>;
    let my possible action <my possible action index> for the person <my person id> the target place = <my place id>;
};

let consider going to the place if possible on equal = value code
{
    # you cannot go to Wyzima if you are already there!
};


let consider going to place (PLACE:integer)=value code
{
    let my place id = value integer [(PLACE:integer)];

    #<print "my place id" <my place id>>;
    #<print "my place of the person" <my person id> "=" <my place of the person <my person id>>>;

    <compare "integer" <my place id> <my place of the person <my person id>>>;
    <consider going to the place if possible on <the compare result>>;
};


let assign the perception for the person (PERSON:integer)=value code
{
    let my person id = value integer [(PERSON:integer)];
    let my amount of perceived informations the person <my person id> believes in = value integer 0;
    let my amount of possible actions the person <my person id> can perform = value integer 0;

    let my possible action = value action wait;
    <please add the possible action for the person { <perform action wait>; }>;

    <consider going to place (PLACE:place_id)>;

    <print "assign the perception for the person" <my person id>>;
    <print <name of person <my person id>> "is in" <name of place <my place of the person <my person id>>>>;

    let my perceived information = value information person <my person id> is in place <my place of the person <my person id>>;

    <please add the perceived information for the person>;

    <print "he can see" <my perceived information>>;

    <assign the perception whether he has the key (KEY:key_id)>;
    <assign the perception whether he can see the person (PERSON2:person_id)>;
};

let assign the perception=value code
{
    <assign the perception for the person (PERSON:person_id)>;
};
