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

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

?? agent.java

?? 很好的windows驅動開發書記,基于WDM的,,可以很好的學習
?? JAVA
字號:
package bb;

import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.geom.*;

/*
This is the base class for all agents in the BBWar system. All decision-making 
mechanisms are here. Sub classes have mostly to fill in their "SKILLS" hashtable, 
which contains all the abilities that the agent possesses.
*/

public abstract class Agent extends DrawableObject {

    int team;                       //the team we are on.
    World world = null;             //ref to the world.
    Blackboard bb = null;           //ref to the blackboard
    
    Mission currentMission = null;  //the mission we are currently satisfying...
    Skill currentSkill = null;      //the currently-active skill

    int rank = 1;                   //military rank
    double maxSpeed = 1.0;          //1.0, let's say, is average...
    double hitPoints = 10.0;        //10.0, let's say, is average...
    double viewRange = 200.0;       //200.0, let's say, is average...
    
    //Note that each agent subclass should have a list of string constants (skills) which
    //indicate the type of mission it can satisfy...
    public Hashtable skills = new Hashtable();
    
    public Agent(int team, int rank, Vec2 pos, double maxSpeed, double hitPoints, Blackboard bb, World world) {
        this(team, rank, pos, maxSpeed, hitPoints, 50.0, bb, world);
    }
    
    public Agent(int team, int rank, Vec2 pos, double maxSpeed, double hitPoints, double viewRange, Blackboard bb, World world) {
    	super(pos);
        this.team = team;
        this.rank = rank;
        this.bb = bb;
        this.world = world;
        this.maxSpeed = maxSpeed;
        this.hitPoints = hitPoints;
        this.viewRange = viewRange;
    }

    //-----------------------------------ACCESSORS--------------------------------
    
    public int getRank() {
        return rank;   
    }
    
    public int getTeam() {
        return team;
    }
    
    /*----------------------------------ACTION SELECTION-------------------------------
    This is a three-part process - 
    1) In actionSelect() the agent decides which mission it would like to apply for, and
        passes its application along to the blackboard.
    2) The blackboard distributes the missions in its updateMissionAssignments method. In
        the course of this process, it will call back successful applicants with
        grantRequest().
    3) If the mission that was applied for is granted, the agent switches over to that 
        mission (perhaps by removing itself from the current mission, if it has one).
    */
    
    Mission missionPending = null;                  //the mission we've applied for
    public final static double BIAS = 1.1;          //a bias towards staying with the current mission

    public void actionSelect(double time) {
        
        Mission highestPriorityMission = null;
        double highestPriority = 0;

        //Find the highest-priority relevant mission on the blackboard.
        Iterator iterator = skills.values().iterator();        
        while(iterator.hasNext()) {
            Skill skill = (Skill)iterator.next();
            Vector relevantMissions = bb.getMissionsForSkill(skill);
            for (int d=0; d < relevantMissions.size(); d++) {
                Mission mission = (Mission)relevantMissions.elementAt(d);
                double temp = calcPriority(mission, skill);
                if (temp > highestPriority) {
                    highestPriority = temp;
                    highestPriorityMission = mission;
                }
            }
        }

        //Decide whether we should end our current mission.
        if (currentMission !=null && (currentMission.getMissionComplete() || currentMission.getPriority()==0.0)) {
            System.out.println(this + ": Mission null or complete");
            bb.removeFromMission(this, currentMission);
            currentMission = null;
            if (currentSkill!=null) {
                currentSkill.deActivate();
                currentSkill = null;
            }
        }

        //Decide whether to apply for the new mission.
        //We have a certain BIAS for staying with our old mission.
        double curPriority = calcPriority(currentMission, currentSkill);
        if ((currentMission == null) || (BIAS*curPriority < highestPriority)) {
            if (highestPriorityMission!=null) bb.applyForMission(this, highestPriorityMission, highestPriority);
            missionPending = highestPriorityMission;
        }
        else missionPending = null;
    }

    //This method calculates the priority of a mission.   
    Vec2 scratch = new Vec2();
    double calcPriority(Mission mission, Skill skill) {
        //need to factor in distance as well...
        if (mission==null) return 0;
        double p = mission.getPriority()*skill.getProficiency();
        if (mission instanceof LocatableMission) {
            ((LocatableMission)mission).getTargetPosition(scratch);
            p = p / (1.0 + pos.distance(scratch)/10.0);
        }
        return p;
    }
    
    boolean requestGranted = false;
    public void grantRequest() {
        requestGranted = true;
    }
    
    public void denyRequest() {
        requestGranted = false;
    }
    
    public void actionExecute(double time) {
        //we know the action we are executing.
        //we just need a pointer to the world to do it.
        
        if (!isAlive()) return;
        

        //First of all, check if we were expecting a response for a request
        //we made.
        if (missionPending!=null) {
            if (requestGranted) {
                System.out.println("Agent " + this + " granted mission " + missionPending);
                if (currentMission != null) bb.removeFromMission(this, currentMission);
                if (currentSkill!=null) currentSkill.deActivate();  //deactivate old skill
                currentMission = missionPending;
                currentSkill = (Skill)skills.get(currentMission.getSkillName());
                currentSkill.activate();                            //activate new skill
            }
            missionPending = null;
        }
        
        //In some cases, we resort to our default skill...
        if (currentSkill==null || currentMission==null) {
            Skill def = defaultSkill();
            if (currentSkill != def) {
            	if (currentSkill!=null) currentSkill.deActivate();
            	currentSkill = def;
            	currentSkill.activate();
            }
        }

        //Finally, apply the current skill to the current mission.
        if (currentSkill!=null) currentSkill.apply(time, currentMission);
    }

    //Subclasses might have specific default skills.
    Skill defaultSkill = null;
    public Skill defaultSkill() {
        return defaultSkill;
    }

    //---------------------------------INTERACTIONS------------------------------

    public void getPosition(Agent askingAgent, Vec2 inplace) {
        inplace.set(pos);
    }

    public void damage(double damage) {
        hitPoints -= damage;
        if (hitPoints<=0) die();
    }
    
    public void die() {
        //agents can die!

        if (currentSkill!=null) currentSkill.deActivate();
        
        //let the blackboard know that we cannot complete the request...
        bb.removeFromMission(this, currentMission);

        System.out.println("Agent " + this + " dying!");
        
        //just DIE!
        alive = false;
    }

    boolean alive = true;
    public boolean isAlive() {
        return alive;
    }

    //-----------------------------------PHYSICS-----------------------------------

    /*
    There are not really full physics, just point-mass physics. Each agent is a mass, 
    on which various forces act, for locomotion, for example, or for attack response 
    (agents get thrown backwards if a strong force hits them).
    */

    /*
    These are self-generated forces. This force vector will eventually be normalized
    (since the agent can only go so fast).
    */
    public void addForce(Vec2 f) {
        Vec2.add(force, f, force);
    }

    /*
    An external force is, for example, a force from an enemy attack, and does not
    get normalized.
    */
    public void addExternalForce(Vec2 f) {
        Vec2.add(externalForce, f, externalForce);
    }
    
    double mass = 1.0;
    double lasttime = -1.0;
    Vec2 vel = new Vec2();
    Vec2 force = new Vec2();
    Vec2 externalForce = new Vec2();
    double drag;
    public double MAX_ACCEL = 1.0;
    public void updatePhysics(double time) {
        if (lasttime == -1.0) {
            lasttime = time;
            return;
        }
        
        double dt = time - lasttime;
        
        //add in forces from avoiding other agents...eventually
        
        force.scale(1.0/mass);
        double fm = force.mag();
        if (fm > MAX_ACCEL) force.scale(MAX_ACCEL/fm);   //accel can be 0 to MAX_ACCEL.
        force.scale(dt);
        
        Vec2.add(force, externalForce, force);
        externalForce.scale(0.0);

        drag = (maxSpeed-dt*MAX_ACCEL)/maxSpeed;
        vel.scale(drag);
        
        Vec2.add(force, vel, vel);
        
        force.set(vel);
        force.scale(dt);
        Vec2.add(force, pos, pos);
        
        force.scale(0.0);
        
        lasttime = time; 
    }

	//---------------------------------DRAWGRAPHICS---------------------------------------

    //Give the skill a chance to draw itself if it wants to.
    public void updateGraphics(double time, Graphics2D g2) {
    	super.updateGraphics(time, g2);
    	if (currentSkill!=null) currentSkill.drawSkill(time, g2);
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91久久精品午夜一区二区| 毛片基地黄久久久久久天堂| 久久综合久久99| 欧美mv日韩mv国产| wwwwww.欧美系列| 久久久久国产精品厨房| 国产日韩欧美精品电影三级在线| 欧美精品一区二区三区视频| 久久影院电视剧免费观看| 欧美精品一区二区蜜臀亚洲| 亚洲国产精品二十页| 国产精品视频第一区| 亚洲欧美一区二区三区极速播放 | 日本免费在线视频不卡一不卡二| 亚洲丶国产丶欧美一区二区三区| 亚洲美女视频在线| 亚洲国产精品久久不卡毛片| 青青草成人在线观看| 狠狠狠色丁香婷婷综合激情| 岛国精品在线播放| 欧美性猛片xxxx免费看久爱| 欧美一区二区精品| 国产免费成人在线视频| 一二三区精品福利视频| 日韩高清中文字幕一区| 国产精品综合久久| 欧美亚洲禁片免费| 欧美精品一区二区三区四区| 亚洲欧美韩国综合色| 五月婷婷综合激情| 国产精品白丝av| 欧美性猛交一区二区三区精品| 欧美大片顶级少妇| 亚洲乱码中文字幕| 精品一区二区在线看| 色综合天天天天做夜夜夜夜做| 7777精品伊人久久久大香线蕉的 | 91精品中文字幕一区二区三区| 欧美mv日韩mv| 亚洲va国产va欧美va观看| 国产一区二区福利| 欧美在线综合视频| 国产欧美一区在线| 美女mm1313爽爽久久久蜜臀| 色8久久精品久久久久久蜜| 精品免费视频一区二区| 亚洲综合免费观看高清完整版在线| 麻豆成人91精品二区三区| 91在线观看一区二区| 精品国产免费人成电影在线观看四季| 中文字幕字幕中文在线中不卡视频| 久久国产婷婷国产香蕉| 精品视频免费看| 国产精品网站在线观看| 精品无人区卡一卡二卡三乱码免费卡| 色综合天天综合网国产成人综合天| 精品国产免费人成在线观看| 日韩精品一级中文字幕精品视频免费观看| 成人av网站在线| 国产日本一区二区| 国产在线视频精品一区| 欧美大片在线观看一区二区| 日韩电影免费一区| 欧美精品国产精品| 午夜视频在线观看一区二区| 一本一道波多野结衣一区二区| 国产精品久久久久婷婷| 国产精品1024久久| 欧美极品另类videosde| 国产另类ts人妖一区二区| 久久久亚洲精品一区二区三区| 日韩 欧美一区二区三区| 欧美精品三级日韩久久| 天堂一区二区在线免费观看| 欧美另类变人与禽xxxxx| 午夜精品久久久久久久99水蜜桃| 欧美三级中文字幕在线观看| 亚洲自拍与偷拍| 欧美精品在线一区二区三区| 蜜臀av一区二区三区| 欧美成人一区二区| 国产福利91精品一区| 日本一区二区三级电影在线观看| 从欧美一区二区三区| 国产精品久久久久久久久果冻传媒| av午夜一区麻豆| 亚洲一区二区综合| 日韩欧美国产综合在线一区二区三区| 韩国精品在线观看| 中文字幕字幕中文在线中不卡视频| 色婷婷精品久久二区二区蜜臀av| 午夜精品福利久久久| 日韩欧美一级片| 成人黄色综合网站| 亚洲综合色丁香婷婷六月图片| 51精品秘密在线观看| 国产精品一区二区在线看| 中文字幕一区二区三区不卡| 欧美在线观看视频在线| 免费三级欧美电影| 国产精品色呦呦| 欧美女孩性生活视频| 国产剧情一区二区| 亚洲欧美偷拍卡通变态| 91精品国产综合久久小美女| 国产v综合v亚洲欧| 亚洲自拍偷拍欧美| 久久久国产一区二区三区四区小说| 91美女视频网站| 裸体健美xxxx欧美裸体表演| 国产精品福利影院| 欧美一区二区人人喊爽| 国产91精品在线观看| 亚洲第一狼人社区| 国产精品久久久久久久蜜臀| 6080日韩午夜伦伦午夜伦| 成人伦理片在线| 老司机免费视频一区二区三区| 日韩毛片精品高清免费| 日韩免费观看高清完整版在线观看| aa级大片欧美| 国产一区二区三区久久久| 亚洲一区二区精品久久av| 欧美激情中文字幕| 日韩一卡二卡三卡四卡| 在线观看日韩一区| 成人sese在线| 国产成人av网站| 久久国产婷婷国产香蕉| 婷婷国产在线综合| 亚洲精品国产a| 国产精品亲子乱子伦xxxx裸| 日韩限制级电影在线观看| 在线免费观看日本欧美| 成人福利视频网站| 国产精品一级片在线观看| 日韩电影网1区2区| 日韩高清中文字幕一区| 亚洲a一区二区| 亚洲一区二区三区视频在线播放| 国产精品久久久久四虎| 久久精品水蜜桃av综合天堂| 精品成人佐山爱一区二区| 91精品视频网| 91精品国产综合久久福利| 色婷婷狠狠综合| 在线免费不卡电影| 91福利国产精品| 欧美在线观看18| 欧美日韩黄色影视| 欧美日韩精品一区二区| 欧美日韩在线播放三区| 欧美色图激情小说| 欧美日韩精品一区二区三区四区| 91精品办公室少妇高潮对白| 欧洲精品一区二区三区在线观看| 99热精品国产| 在线视频一区二区三| 欧美高清精品3d| 精品日韩成人av| 久久免费视频一区| 国产精品国模大尺度视频| 国产精品福利电影一区二区三区四区 | 国产三级精品在线| 中文字幕第一页久久| 国产精品久久久久久久久搜平片| 亚洲欧洲国产日本综合| 亚洲欧美日韩国产综合在线 | 69av一区二区三区| 日韩午夜激情视频| 国产日韩精品一区二区浪潮av| 中文字幕在线不卡一区| 玉米视频成人免费看| 日韩成人dvd| 国产盗摄一区二区| 欧美三级蜜桃2在线观看| 69成人精品免费视频| 亚洲国产精品成人综合色在线婷婷 | 丁香五精品蜜臀久久久久99网站| www.日韩精品| 91.xcao| 国产精品久久久久久久久动漫| 亚洲一区二区三区中文字幕在线| 免费观看30秒视频久久| 丁香婷婷综合激情五月色| 欧美羞羞免费网站| 2021国产精品久久精品| 亚洲色图色小说| 久久精品噜噜噜成人88aⅴ | 天天色天天操综合| 国产91精品久久久久久久网曝门| 欧美亚一区二区| 国产精品久久久久久久蜜臀 | 国产亚洲精品7777| 一区二区三区精品| 国产精品亚洲人在线观看| 欧美日韩精品一区二区三区四区| 亚洲国产精品国自产拍av| 日韩国产高清影视| 在线免费观看一区|