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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? basicjessbehaviour.java

?? JADE(JAVA Agent開發框架)是一個完全由JAVA語言開發的軟件,它簡化了多Agent系統的實現。
?? 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("\"")) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产网站在线观看| 亚洲欧美日韩小说| 美脚の诱脚舐め脚责91| 欧美少妇bbb| 一区二区三区在线视频观看| 成人免费高清在线观看| 一本一本久久a久久精品综合麻豆| 欧美成人性福生活免费看| 亚洲一区日韩精品中文字幕| 国产精选一区二区三区| 久久亚洲私人国产精品va媚药| 天天综合天天做天天综合| 国产在线观看免费一区| 欧美影院一区二区三区| 亚洲午夜私人影院| 欧美亚日韩国产aⅴ精品中极品| 亚洲日本韩国一区| 在线中文字幕一区二区| 一区二区三区在线观看欧美| 欧美亚洲一区二区在线| 亚洲成av人片一区二区梦乃 | 激情图区综合网| 精品国产伦一区二区三区观看体验| 美女一区二区三区| www国产成人| 99国产精品久久久久| 亚洲一区二区在线播放相泽| 色婷婷亚洲一区二区三区| 亚洲成人激情av| 2020国产精品| 成人亚洲一区二区一| 亚洲精品欧美在线| 精品国产凹凸成av人导航| 久久精品国产99久久6| 91浏览器入口在线观看| 亚洲国产一区二区视频| 精品国产三级a在线观看| 极品少妇xxxx偷拍精品少妇| 17c精品麻豆一区二区免费| 久久日韩粉嫩一区二区三区| 91日韩在线专区| 亚洲婷婷在线视频| 成人精品国产福利| 久久精品在这里| 国产在线精品一区在线观看麻豆| 国产欧美日韩激情| 久久精品国产精品亚洲综合| 国产成人精品免费视频网站| 91精品国产丝袜白色高跟鞋| 亚洲黄网站在线观看| 国产一区二区美女诱惑| 欧美一区二区在线视频| 欧美一二三区在线观看| 色婷婷综合久久久中文一区二区| 欧美精品1区2区3区| 日日夜夜一区二区| 欧美激情一区二区在线| 亚洲一二三四在线观看| 欧美日韩一区二区三区在线| 蜜臀精品久久久久久蜜臀| 欧美区一区二区三区| 国产真实乱偷精品视频免| 久久久久9999亚洲精品| 精品久久99ma| 91免费看`日韩一区二区| 国产成人综合视频| 免费不卡在线视频| 奇米影视在线99精品| 老司机精品视频导航| 亚洲v中文字幕| 一区二区三区免费| 亚洲蜜臀av乱码久久精品| 国产精品理论在线观看| 亚洲一区二区欧美| 亚洲成人精品一区二区| 日本色综合中文字幕| 免费成人av资源网| 国产91丝袜在线18| 欧美视频在线观看一区二区| 欧美大片在线观看| 日韩午夜三级在线| 中文字幕一区不卡| 亚洲无人区一区| 国产一区二区不卡在线| 在线视频综合导航| 欧美日韩国产一二三| 久久久91精品国产一区二区精品 | 日本亚洲天堂网| 日本不卡在线视频| 亚洲国产视频在线| 91小视频在线| 亚洲男同1069视频| 色婷婷av一区二区三区gif| 中文字幕亚洲精品在线观看| 国产精选一区二区三区| 国产精品视频线看| 91香蕉视频mp4| 欧美精品一区二区三区蜜桃视频| 日韩一区有码在线| 国产高清成人在线| xnxx国产精品| 久久成人麻豆午夜电影| 欧美一区二区三区不卡| 亚洲一区在线播放| 成人高清免费在线播放| 国产性色一区二区| 国产成人免费在线观看不卡| 欧美电影免费观看高清完整版在线观看 | 正在播放一区二区| 亚洲成人资源网| 欧美电影在线免费观看| 日韩二区在线观看| 欧美一区二区三区免费在线看| 日韩美女视频一区二区 | 2017欧美狠狠色| 国产乱码精品一区二区三区忘忧草| 欧美xxxx老人做受| 激情综合色播激情啊| 久久久久久毛片| 美女视频网站久久| 日韩精品一区二区三区中文不卡| 蓝色福利精品导航| 欧美二区乱c少妇| 夫妻av一区二区| 亚洲成va人在线观看| 国产亚洲一区字幕| 欧美高清性hdvideosex| 成人永久免费视频| 午夜激情综合网| 中文字幕在线不卡一区二区三区 | 91久久精品午夜一区二区| 精品影视av免费| 天堂影院一区二区| 综合av第一页| 久久九九全国免费| 欧美一级片在线看| 欧美精品 国产精品| 在线观看一区二区视频| av网站一区二区三区| 国产成人精品1024| 九九九精品视频| 五月婷婷综合在线| 三级不卡在线观看| 亚洲成人1区2区| 亚洲成人自拍偷拍| 亚洲一区二区三区四区在线免费观看| 国产精品久久久久久户外露出 | 色综合天天综合网国产成人综合天 | 天堂在线亚洲视频| 亚洲综合色区另类av| 国产精品欧美极品| 久久在线免费观看| 色偷偷一区二区三区| 一本色道亚洲精品aⅴ| 精品一区二区三区影院在线午夜| 天天综合色天天综合色h| 亚洲欧洲精品一区二区精品久久久 | 欧美在线观看视频一区二区三区 | 午夜激情久久久| 亚洲成人黄色影院| 中文字幕一区二区不卡| 日韩毛片一二三区| 日韩三级在线免费观看| 在线观看免费一区| 欧美视频日韩视频在线观看| 欧美午夜片在线看| 91精选在线观看| 久久久精品免费免费| 国产精品久久久久aaaa| 亚洲国产精华液网站w | 日韩午夜激情视频| 精品国产乱码久久久久久免费| 国产精品免费视频一区| 亚洲人成小说网站色在线| 亚洲一级二级三级| 日韩av网站免费在线| 国产毛片精品视频| av一区二区三区黑人| 欧美va亚洲va| 亚洲欧美日韩在线| 蜜臀av性久久久久蜜臀aⅴ| 国产不卡在线一区| 欧美日韩不卡一区二区| 国产欧美一区二区在线观看| 日本一区二区成人| 日韩精品电影在线观看| 成人a区在线观看| 在线不卡a资源高清| 一区二区三区四区高清精品免费观看| 日韩精品一区第一页| 99re视频精品| 精品成人一区二区三区| 亚洲靠逼com| 成人黄页毛片网站| 久久久久久久精| 麻豆91精品视频| 欧美日韩dvd在线观看| 国产精品久久久久aaaa| 国产不卡一区视频| 国产亚洲欧美一级|