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

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

?? agent.java

?? C人工智能游戲開發(fā)的一些實(shí)例源代碼 C Game development in artificial intelligence source code of some examples
?? JAVA
字號(hào):
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);
    }

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色老汉一区二区三区| 欧美男人的天堂一二区| 91精品国产综合久久小美女| 国产精品卡一卡二卡三| 国产精品123区| 久久先锋影音av鲁色资源网| 日本午夜精品视频在线观看| 欧美性色欧美a在线播放| 亚洲成人综合网站| 欧美三级韩国三级日本一级| 日韩精品一级中文字幕精品视频免费观看 | 丁香婷婷综合网| 久久综合av免费| 欧美美女一区二区在线观看| 日韩av一级片| 一区二区三区国产精品| 欧洲一区在线电影| 日韩精品视频网| 亚洲黄色性网站| 欧美日韩视频专区在线播放| av成人老司机| 亚洲国产视频在线| 日韩三级视频在线观看| 久久97超碰色| 国产精品视频一二| 色婷婷亚洲一区二区三区| 亚洲亚洲精品在线观看| 国产精品久久久久久久久图文区| 精品国产露脸精彩对白| www.欧美亚洲| 岛国精品在线播放| 亚洲h在线观看| 一区二区三区四区激情 | 国产女人18水真多18精品一级做| 99久精品国产| 免费不卡在线视频| 国产精品久久国产精麻豆99网站| 久久久久久亚洲综合| 欧美性大战久久| av色综合久久天堂av综合| 99re这里只有精品6| 成人av资源站| 久久综合综合久久综合| 亚洲精品国产品国语在线app| 亚洲欧美日韩一区二区| 欧美一卡二卡三卡| 99热这里都是精品| www..com久久爱| 99久久国产综合精品女不卡| 99久久精品费精品国产一区二区| 色女孩综合影院| 欧美日韩国产美女| 欧美一区二区播放| 久久无码av三级| 国产女同互慰高潮91漫画| 久久免费的精品国产v∧| 久久这里只有精品视频网| 久久亚洲精精品中文字幕早川悠里 | 91原创在线视频| 另类小说图片综合网| 激情综合色综合久久综合| 国产露脸91国语对白| 日韩精品亚洲一区| 久久精品国产一区二区三区免费看 | caoporm超碰国产精品| 在线影视一区二区三区| 欧美三级电影在线观看| 精品国产3级a| 中文字幕一区二区三区色视频| 精品卡一卡二卡三卡四在线| 欧美日韩aaaaa| 精品国产一区二区三区四区四| 国产区在线观看成人精品| 亚洲综合在线电影| 久久久久九九视频| 亚洲黄色免费网站| 捆绑紧缚一区二区三区视频| av午夜一区麻豆| 欧美一区二区性放荡片| 国产精品久久免费看| 日韩高清在线一区| 成人听书哪个软件好| 欧美丰满嫩嫩电影| 国产精品美女久久久久久 | 午夜视频一区在线观看| 亚洲欧美日韩国产成人精品影院 | 欧美久久一二区| 欧美经典一区二区三区| 久久久精品人体av艺术| 亚洲国产综合91精品麻豆| 国产在线精品不卡| 国产在线播放一区| 色老汉一区二区三区| 精品国产露脸精彩对白| 亚洲一区二区av电影| 国产成人夜色高潮福利影视| 在线成人av影院| 亚洲情趣在线观看| 国产一区二区福利视频| 欧美日韩精品欧美日韩精品一| 国产欧美视频一区二区| 老司机一区二区| 欧美午夜精品免费| 中文av一区特黄| 狠狠色狠狠色综合| 国产不卡在线一区| 欧美一区二区福利在线| 伊人一区二区三区| 国产成人精品亚洲777人妖| 日韩欧美卡一卡二| 国产日韩欧美一区二区三区综合| 亚洲午夜视频在线观看| eeuss国产一区二区三区| 久久综合网色—综合色88| 亚洲gay无套男同| 色婷婷国产精品| 最新成人av在线| 天天色综合天天| 91在线精品一区二区三区| 久久亚洲精精品中文字幕早川悠里 | 国产激情91久久精品导航 | 欧美日韩亚洲高清一区二区| 亚洲欧美色一区| 91在线云播放| 亚洲欧美国产77777| 日韩亚洲欧美成人一区| 亚洲国产日韩在线一区模特| 91麻豆视频网站| 亚洲美女淫视频| 一本在线高清不卡dvd| 中文字幕一区二区三区不卡在线| 国产精品99久久久久久似苏梦涵| 亚洲精品一区二区三区影院| 美腿丝袜在线亚洲一区| 久久爱www久久做| 欧美一级欧美三级在线观看| 三级影片在线观看欧美日韩一区二区| 在线观看免费一区| 亚洲一区在线观看视频| 色综合天天综合在线视频| 制服丝袜av成人在线看| 亚洲成人激情综合网| 欧美日韩精品系列| 日韩高清欧美激情| 日韩一区二区三区精品视频| 久久电影网站中文字幕| 国产亚洲污的网站| 一区二区三区高清| 91福利国产成人精品照片| 亚洲黄色免费网站| 7777精品久久久大香线蕉| 日本aⅴ精品一区二区三区 | 欧美r级电影在线观看| 久久99国内精品| 中文一区二区完整视频在线观看| 国产福利不卡视频| 亚洲伦理在线免费看| 欧美唯美清纯偷拍| 免费在线看一区| 中文字幕免费不卡| 欧美三区在线观看| 免费成人性网站| 亚洲国产精品成人综合| 色婷婷综合激情| 麻豆91在线播放免费| 国产精品剧情在线亚洲| 欧美又粗又大又爽| 免费xxxx性欧美18vr| 国产亚洲va综合人人澡精品| 色婷婷精品久久二区二区蜜臂av| 看电影不卡的网站| 成人欧美一区二区三区| 欧美高清激情brazzers| 国产精品一卡二卡在线观看| 亚洲日本在线观看| 日韩午夜三级在线| 99精品视频在线免费观看| 喷水一区二区三区| 国产精品免费丝袜| 欧美一区二区日韩| 99精品视频在线观看| 蜜臀久久99精品久久久画质超高清| 欧美激情综合五月色丁香小说| 欧美曰成人黄网| 成人午夜精品一区二区三区| 五月婷婷综合激情| 国产精品高潮呻吟久久| 日韩亚洲欧美一区二区三区| 91官网在线免费观看| 国产suv一区二区三区88区| 亚洲地区一二三色| 国产精品久久久久婷婷二区次| 欧美一区二区三区婷婷月色| 99久久婷婷国产| 国产麻豆视频精品| 日本三级亚洲精品| 亚洲欧美成人一区二区三区| 久久精品人人做人人综合| 91精品国产丝袜白色高跟鞋| 91看片淫黄大片一级在线观看|