亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? basicjessbehaviour.java

?? JADE(JAVA Agent開發(fā)框架)是一個完全由JAVA語言開發(fā)的軟件,它簡化了多Agent系統(tǒng)的實現(xiàn)。
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*****************************************************************
JADE - Java Agent DEvelopment Framework is a framework to develop multi-agent systems in compliance with the FIPA specifications.
Copyright (C) 2000 CSELT S.p.A.

GNU Lesser General Public License

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation,
version 2.1 of the License.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA  02111-1307, USA.
*****************************************************************/
//////////////////////////////////////////////////////////////
//Kaveh Kamyab - Imperial College - 30/10/00
//General Changes
//
//* Replaced all 'ReteException' with 'JessException'
//* Instantiate Rete with 'new Rete()' instead of 'new Rete(NullDisplay ...)'
//* Line 193 - replaced 'FileInputStream fis = new FileInputStream(jessFile);'
//			with 'FileReader fr = new FileReader(jessFile);'
//* Line 196 - replaced 'Jesp j = new Jesp(fis, jess);'
//			with 'Jesp j = new Jesp(fr, jess);'
//* Replaced all 'stringValue()' with 'stringValue(context)'
//* Replaced '(jess.display()).stderr()'
//			with 'System.err'
//* Updated getAIDListFromCache to take a ValueVector as parameter. It also requires Context as a parameter to
//	resolve JESS variables
//////////////////////////////////////////////////////////////
//Kaveh Kamyab - Imperial College - 30/10/00
//Changes In JessSend
//
//* Replaced 'name()' with 'getName()'
//* Replaced 'engine()' with 'getEngine()'
//* Modified Method 'JessFact2ACL(jess.ValueVector vv)'
//			changed to 'JessFact2ACL(Context context, jess.ValueVector vv)'
//* Replaced method call accordingly 'JessFact2ACL(vv)' with 'JessFact2ACL(context, vv)'
//* Replaced 'FunCall.TRUE()' with 'FunCall.TRUE'
//
//* Check for two cases, i.e. if send has a RU.VARIABLE as its first parameter (send ?m) and secondly if
//send has an RU.FUNCALL as its first parameter (send (assert (ACLMessage ...))).
//1) The first case is straight forward. Get the first parameter of the ValueVector, extract the Fact Id and find the fact
//by looking up the Fact Id. Pass the resulting ValueVector to JessFact2ACL(Context context, jess.ValueVector vv).
//2) The second case is a little more tricky. Get the first parameter of the ValueVector, extract the function call
//(assert). Get the first parameter again and extract the ACLMessage. Jess variables must be resolved with calls to
//Value.stringValue(context), Value.listValue(context), etc.
package examples.jess;

import jade.core.*;

import jade.core.behaviours.*;

import jade.lang.acl.ACLMessage;

import jess.*;

import java.io.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;


/**
Javadoc documentation for the file
@author Fabio Bellifemine - CSELT S.p.A
@author Kaveh Kamyab - Imperial College of London (upgrade to JESS 5.1)
@version $Date: 2004-09-22 15:08:42 +0200 (mer, 22 set 2004) $ $Revision: 5374 $
*/
/**
 * This is the basic class that implements a behaviour of JADE that allows
 * to embed a Jess engine inside the agent code.
 * <p>
 * <a href="http://herzberg.ca.sandia.gov/jess">Jess</a>
 * supports the development of rule-based expert systems.
 * <p>
 * This JADE implementation has been tested with version 6.0 of JESS.
 * <p>
 * The programmer can override this class.
 * In particular, its methods <code>ACL2JessString</code> and
 * <code>JessFact2ACL</code> to convert between ACLMessage JADE structure and
 * Jess facts. Also the method <code>ACLJessTemplate</code> might need to
 * be overide in order to change the deftemplate of the ACLMessage in Jess.
 * <p>
 * When this behaviour is added to the list of agent behaviours,
 * it creates a Jess engine and initializes the engine by:
 * <ul>
 * <li> defining the template of an ACLMessage,
 * <li> defining the userfuntion "send" to send ACLMessages,
 * <li> asserting the fact <code>(MyAgent (name nameofthisagent))</code>,
 * <li> parsing the Jess file passed as a parameter to the constructor.
 * </ul>
 * Then the behaviour loops infinitely by:
 * <ul>
 * <li> waiting that a message arrives,
 * <li> calling the <code>ACL2JessString</code> method that returns the fact to be
 * asserted in Jess,
 * <li> asserting the fact in Jess,
 * <li> running Jess.
 * </ul>
 * <p>
 * Notice for programmers of the Jess .clp file:
 * <ul>
 * <li> the template of the ACLMessage contains the following slots:
<code>(deftemplate ACLMessage (slot communicative-act) (slot sender) (multislot receiver) (slot reply-with) (slot in-reply-to) (slot envelope) (slot conversation-id) (slot protocol) (slot language) (slot ontology) (slot content) (slot encoding) (multislot reply-to) (slot reply-by))</code>
 * <li> match the fact <code>(MyAgent (name nameofthisagent))</code> to know the name of your agent;
 * <li> use the userfunction <code>send</code> to send ACLMessages.
 * The parameter of <code>send</code> must be a fact-id of type ACLMessage or
 * an ACLMessage itself; There are two styles of usage:
 * <p> <code>  ?m <- (ACLMessage (communicative-act cfp) (sender ?s))
 * <br>
 * (send ?m) </code>
 * <p> or, in alternative,
 * <p> <code>(send (assert (ACLMessage (communicative-act cfp)
 * (sender ?s))))</code>
 * <li> remember to load all the Jess Packages you need because, by default,
 * Jess just loads the built-in functions
 * </ul>
 * <p>
 * Look at the sample file JadeAgent.clp that is shipped with this example.
 * <p>
 * WARNING:
 * FIPA2000 standard has specified an AgentIdentifier to have a
 * template
 * composed of several slots, where the only mandatory one is the agent name,
 * i.e. the globally unique identifier of the agent (GUID).
 * In order to reduce the porting of the JESS user code, this basic
 * behaviour automatically
 * takes care of replacing the GUIDs with full-fledged AgentIdentifiers.
 */
public class BasicJessBehaviour extends CyclicBehaviour {
    // class variables
    Rete jess; // holds the pointer to jess
    Agent myAgent; // holds the pointer to this agent
    int m_maxJessPasses = 0; // holds the maximum number of Jess passes for each run
    int executedPasses = -1; // to count the number of Jess passes in the previous run
    Hashtable AIDCache; // holds a local cache to map agent names to AID

    /**
     * Creates a <code>BasicJessBehaviour</code> instance
     *
     * @param agent the agent that adds the behaviour
     * @param jessFile the name of the Jess file to be executed
     */
    public BasicJessBehaviour(Agent agent, String jessFile) {
        myAgent = agent;
        AIDCache = new Hashtable();

        // See info about the Display classes in Section 5 of Jess 4.1b6 Readme.htm
        //NullDisplay nd = new NullDisplay();
        // Create a Jess engine
        jess = new Rete();

        // The jess.MiscFunctions is no more used since JESS 6.0 (see e-mail of Csaba Tenkes
        //try {
        //jess.addUserpackage((Userpackage)Class.forName("jess.MiscFunctions").newInstance());
        // } catch (Throwable t) { System.out.println(t); }
        try {
            // First I define the ACLMessage template
            jess.executeCommand(ACLJessTemplate());

            // Then I define the myagent template
            jess.executeCommand("(deftemplate MyAgent (slot name))");

            // Then I add the send function
            jess.addUserfunction(new JessSend(myAgent, this));

            // Then I assert the fact (Myagent (name <my-name>))
            jess.executeCommand(
                "(deffacts MyAgent \"All facts about this agent\" (MyAgent (name " +
                myAgent.getName() + ")))");

            // Open the file test.clp
            FileReader fr = new FileReader(jessFile);

            // Create a parser for the file, telling it where to take input
            // from and which engine to send the results to
            Jesp j = new Jesp(fr, jess);

            // parse and execute one construct, without printing a prompt
            j.parse(false);
        } catch (JessException re) {
            System.out.println(re);
        } catch (FileNotFoundException e) {
            System.out.println(e);
        }
    }

    /**
     * Creates a <code>BasicJessBehaviour</code> instance that limits
     * the reasoning time of Jess before looking again for arrival of messages.
     *
     * @param agent the agent that adds the behaviour
     * @param jessFile the name of the Jess file to be executed
     * @param maxJessPasses the maximum number of passes that every run of Jess
     * can execute before giving again the control to this behaviour;
     * put <code>0</code> if you do not ever want to stop Jess.
     */
    public BasicJessBehaviour(Agent agent, String jessFile, int maxJessPasses) {
        this(agent, jessFile);
        m_maxJessPasses = maxJessPasses;
    }

    /**
     * executes the behaviour
     */
    public void action() {
        ACLMessage msg; // to keep the ACLMessage

        // wait a message
        if (executedPasses < m_maxJessPasses) {
            System.out.println(myAgent.getName() +
                " is blocked to wait a message...");
            msg = myAgent.blockingReceive();

            // assert the fact message in Jess
            makeassert(ACL2JessString(msg));
        } else {
            System.out.println(myAgent.getName() +
                " is checking if there is a message...");
            msg = myAgent.receive();

            if (msg != null) {
                // assert the fact message in Jess
                makeassert(ACL2JessString(msg));
            }
        }

        // run jess
        try {
            // jess.executeCommand("(facts)");
            if (m_maxJessPasses > 0) {
                executedPasses = jess.run(m_maxJessPasses);
                System.out.println("Jess has executed " + executedPasses +
                    " passes");
            } else {
                jess.run();
            }
        } catch (JessException re) {
            re.printStackTrace(System.err);
        }
    }

    private boolean isEmpty(String string) {
        return (string == null) || string.equals("");
    }

    /**
      replace a char in a String with a String
      It is used to convert all the quotation marks in backslash quote
      before asserting the content of a message in Jess.
      @return the new String
    */
    private String stringReplace(String str, char oldChar, String s) {
        int len = str.length();
        int i = 0;
        int j = 0;
        int k = 0;
        char[] val = new char[len];
        str.getChars(0, len, val, 0); // put chars into val

        char[] buf = new char[len * s.length()];

        while (i < len) {
            if (val[i] == oldChar) {
                s.getChars(0, s.length(), buf, j);
                j += s.length();
            } else {
                buf[j] = val[i];
                j++;
            }

            i++;
        }

        return new String(buf, 0, j);
    }

    /**
      * makeasserts a fact representing an ACLMessage in Jess. It is called after the arrival of a message.
      */
    private void makeassert(String fact) {
        try {
            jess.executeCommand(fact);
        } catch (JessException re) {
            re.printStackTrace(System.err);
        }
    }

    /**
     * Remove the first and the last character of the string
     * (if it is a quotation mark) and convert all backslash quote in quote
     * It is used to convert a Jess content into an ACL message content.
     */
    private String unquote(String str) {
        String t1 = str.trim();

        if (t1.startsWith("\"")) {
            t1 = t1.substring(1);
        }

        if (t1.endsWith("\"")) {

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美高清视频在线高清观看mv色露露十八| 日韩色视频在线观看| 免费观看在线综合| 国产精品人成在线观看免费| 欧美一区二区视频观看视频| 波多野结衣一区二区三区 | 国产精品国产三级国产aⅴ无密码| 欧美在线制服丝袜| 成人永久aaa| 美女一区二区三区在线观看| 亚洲欧美一区二区三区久本道91| 久久久久综合网| 3d成人动漫网站| 欧美最猛性xxxxx直播| 国产又黄又大久久| 免费不卡在线观看| 亚洲1区2区3区视频| 亚洲三级电影全部在线观看高清| 国产欧美日韩另类视频免费观看| 欧美一二三四在线| 这里只有精品免费| 欧美色电影在线| 在线欧美日韩国产| 色综合中文字幕国产 | 亚洲日本在线观看| 久久伊人中文字幕| 欧美一级黄色片| 欧美午夜宅男影院| 色久优优欧美色久优优| 91在线国产福利| a在线播放不卡| 波多野结衣精品在线| caoporen国产精品视频| 不卡一卡二卡三乱码免费网站| 国产成人午夜高潮毛片| 国产高清亚洲一区| 成人激情文学综合网| 国产福利一区二区| 成人午夜电影久久影院| 高清不卡在线观看| 成人福利视频网站| a4yy欧美一区二区三区| 99久久国产综合精品色伊| 成人激情文学综合网| 99久久久精品| 欧洲一区二区三区在线| 欧美日韩另类国产亚洲欧美一级| 欧美丝袜丝交足nylons图片| 91豆麻精品91久久久久久| 欧美优质美女网站| 欧美伦理影视网| 精品国产在天天线2019| 久久久久久久久久看片| 国产精品久久久久永久免费观看| 亚洲欧美欧美一区二区三区| 亚洲综合色网站| 三级欧美在线一区| 蜜桃精品视频在线| 国产麻豆精品在线| 亚洲成人激情自拍| 国产一区二区三区免费看| 美女在线观看视频一区二区| 精品一区二区三区视频在线观看| 国产高清无密码一区二区三区| 成人手机在线视频| 欧美午夜精品一区| 制服丝袜在线91| 久久你懂得1024| 亚洲欧美日韩国产一区二区三区| 亚洲电影一级片| 国内精品第一页| av成人老司机| 欧美久久久久久久久中文字幕| 精品国产一区a| 亚洲欧美激情一区二区| 日韩精品电影一区亚洲| 成人精品免费看| 91精品婷婷国产综合久久| 国产欧美一区二区三区在线看蜜臀| 亚洲三级电影网站| 久久精品国产亚洲5555| 97精品久久久午夜一区二区三区 | 成人免费观看男女羞羞视频| 色视频欧美一区二区三区| 制服丝袜中文字幕亚洲| 国产精品传媒入口麻豆| 免费观看日韩电影| 99久久精品免费| 欧美一二三四在线| 亚洲免费观看高清完整| 国产精品一区二区在线看| 欧美综合天天夜夜久久| 久久精品欧美日韩精品| 亚洲va韩国va欧美va精品| www.日本不卡| 久久久久久久久蜜桃| 日韩电影在线观看网站| 99久久久国产精品免费蜜臀| 精品乱人伦一区二区三区| 亚洲一区二区在线观看视频| 成人一区二区三区视频在线观看| 91精品国产综合久久精品性色| 亚洲视频在线一区观看| 国产精品一色哟哟哟| 欧美一区二区三区在线观看视频| 一区二区三区四区激情| 不卡av在线免费观看| 精品粉嫩超白一线天av| 日本伊人色综合网| 欧美色图在线观看| 亚洲欧洲精品成人久久奇米网| 激情文学综合丁香| 日韩欧美一区二区久久婷婷| 亚洲高清免费视频| 色综合久久综合中文综合网| 亚洲国产精品二十页| 国产一区二区三区久久久 | 91在线国产福利| 日本一区二区电影| 国产福利精品一区| 精品国产麻豆免费人成网站| 日本中文字幕不卡| 欧美精品在线一区二区三区| 亚洲欧美一区二区三区极速播放| 99久久久久久| 综合电影一区二区三区 | 精品国偷自产国产一区| 日本欧美大码aⅴ在线播放| 欧美日韩精品专区| 五月天亚洲精品| 欧美疯狂性受xxxxx喷水图片| 亚洲福利国产精品| 7799精品视频| 美女爽到高潮91| 精品国产乱码久久久久久图片| 麻豆精品新av中文字幕| 日韩你懂的电影在线观看| 久久av中文字幕片| 2023国产精华国产精品| 国产成人av福利| 国产农村妇女精品| 91香蕉视频在线| 亚洲午夜日本在线观看| 欧美三日本三级三级在线播放| 亚洲国产精品久久不卡毛片| 91精品国产综合久久久久| 久久国产尿小便嘘嘘尿| 久久人人超碰精品| 成人久久久精品乱码一区二区三区| 成人欧美一区二区三区在线播放| 色综合久久中文综合久久牛| 亚洲一区二区黄色| 日韩一区二区三区电影在线观看 | 久久色在线视频| 成人激情文学综合网| 亚洲综合色区另类av| 91精品国产一区二区三区| 九色综合国产一区二区三区| 国产日韩高清在线| 91在线小视频| 人禽交欧美网站| 国产欧美日本一区视频| 色呦呦国产精品| 奇米精品一区二区三区四区| 久久色.com| 日本道免费精品一区二区三区| 日韩综合在线视频| 国产日产亚洲精品系列| 日本高清无吗v一区| 久久精品av麻豆的观看方式| 欧美国产精品专区| 欧美日韩一区国产| 国产精品亚洲第一区在线暖暖韩国| 亚洲日本丝袜连裤袜办公室| 制服丝袜在线91| 成人福利电影精品一区二区在线观看| 亚洲午夜精品一区二区三区他趣| 精品国产亚洲一区二区三区在线观看| jlzzjlzz欧美大全| 日本不卡一区二区三区| 国产精品成人免费| 日韩精品一区二区三区三区免费| 成人免费电影视频| 另类小说综合欧美亚洲| 国产精品初高中害羞小美女文| 欧美精品v国产精品v日韩精品| 国产成人自拍网| 三级欧美韩日大片在线看| 国产精品每日更新在线播放网址| 欧美一区二区三区在线看| 99久久99久久综合| 国内精品嫩模私拍在线| 亚洲小说春色综合另类电影| 中文字幕不卡在线| 欧美一卡二卡三卡四卡| 在线国产亚洲欧美| 懂色一区二区三区免费观看| 看片的网站亚洲| 亚洲网友自拍偷拍| 亚洲欧美经典视频|