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

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

?? modelswarm.java

?? Swarm多agent仿真教程ObserverSwarm應用:運用GUI可初化仿真
?? JAVA
字號:
// ModelSwarm.java
// The top-level ModelSwarm

import swarm.Globals;
import swarm.Selector;
import swarm.defobj.Zone;

import swarm.objectbase.Swarm;
import swarm.objectbase.SwarmImpl;
import swarm.objectbase.EmptyProbeMap;
import swarm.objectbase.EmptyProbeMapImpl;

import swarm.activity.ActionGroupImpl;
import swarm.activity.ScheduleImpl;
import swarm.activity.Activity;

import swarm.space.Grid2dImpl;
import swarm.collections.ListImpl;

public class ModelSwarm extends SwarmImpl
{
    // Declare the model parameters and their default values.
    public int worldXSize = 80, worldYSize = 80;
    public double seedProb = 0.80;
    public double bugDensity = 0.10;
    public int bugHardiness = 10;
    public int numberOfBugs = 0;

    // Declare some other needed variables.
    public FoodSpace foodSpace;
    public Grid2dImpl bugSpace;
    public ListImpl bugList, reaperQueue;
    public ScheduleImpl modelSchedule;

    // This is the constructor for a new ModelSwarm.
    public ModelSwarm(Zone azone)
    {
	// Use the parent class to create a top-level swarm.
	super(azone);

	// Build a customized probe map.  Without a custom probe map
	// the default is to show all variables and messages.  Here we
	// choose to customize the appearance of the probe, giving a
	// nicer interface.

	// Create the probe map and give it the ModelSwarm class.
	EmptyProbeMapImpl probeMap = 
	    new EmptyProbeMapImpl(azone, getClass());

	// Now add probes for the variables we wish to probe.
	probeMap.addProbe(getProbeForVariable("worldXSize"));
	probeMap.addProbe(getProbeForVariable("worldYSize"));
	probeMap.addProbe(getProbeForVariable("seedProb"));
	probeMap.addProbe(getProbeForVariable("bugDensity"));
	probeMap.addProbe(getProbeForVariable("bugHardiness"));
	probeMap.addProbe(getProbeForVariable("numberOfBugs"));

	// And finaly install our probe map into the probeLibrary.
	// Note that this library was created by initSwarm().
	Globals.env.probeLibrary.setProbeMap$For(probeMap, getClass());
    }

    // This is the method for building the model's objects: the food
    // space, the two-dimensional positioning grid, and the host of
    // bugs.
    public Object buildObjects()
    {
	int x, y, num;
	SimpleBug abug;

	// use the parent class buildObject() method to initialize the
	// process
	super.buildObjects();

	// Now create the model's objects.
	// First create the foodspace and seed it with food.
	foodSpace = new FoodSpace(Globals.env.globalZone, 
				  worldXSize, worldYSize);
	foodSpace.seedFoodWithProb( seedProb );

	// Then create a 2-D grid that will be used to keep track of
	// each bug's position, insuring that no two bugs will ever be
	// on the same cell. Initialize the grid to be empty.
	bugSpace = new Grid2dImpl(Globals.env.globalZone, 
				   worldXSize, worldYSize);
	bugSpace.fastFillWithObject(null);

	// Now create a List object to manage all the bugs we are
	// about to create.
	bugList = new ListImpl(Globals.env.globalZone);

	// Iterate over the grid with a certain probability of
	// creating a bug at each site.  If a bug is created, put it
	// on the grid and add it to the end of the bug list.  Note
	// that we increment the bug number, num, each time a bug is
	// created.
	num = 0;
	for (y = 0; y < worldYSize; y++)
	    for (x = 0; x < worldXSize; x++)
		if ( Globals.env.uniformDblRand.getDoubleWithMin$withMax(
						  0.0, 1.0) <= bugDensity)
		    {
		    abug = new SimpleBug(Globals.env.globalZone, foodSpace, 
					 bugSpace, x, y, ++num, 
					 bugHardiness, this);
		    bugSpace.putObject$atX$Y(abug, x, y);
		    bugList.addLast(abug);
		    }

	// Report the number of bugs created.
	numberOfBugs = bugList.getCount();
	System.out.println(numberOfBugs + " bugs were created.");

	// Finally, create a list for holding those bugs that have
	// died and are marked for removal.
	reaperQueue = new ListImpl(Globals.env.globalZone);

	// We're done.
	return this;
    }

    // The next three methods return some useful information about the
    // created ModelSwarm to the caller.  They will be used by the
    // Observer Swarm.
    public ListImpl getBugList()
    {
	return bugList;
    }

    public Grid2dImpl getWorld()
    {
	return bugSpace;
    }

    public FoodSpace getFood()
    {
	return foodSpace;
    }

    // This is the method a) for building the list of actions for
    // these objects to accomplish and b) for scheduling these actions
    // in simulated time.
    public Object buildActions()
    {
	Selector sel;
	ActionGroupImpl modelActions;

	// First, use the parent class to initialize the process.
	super.buildActions();

	// Then create an ActionGroup object and insert a randomWalk
	// message to every bug in the bug list.  We've taken out the
	// old "checkTime" message as we have a new way to end the
	// simulation.
	modelActions = new ActionGroupImpl(getZone());

	sel = SwarmUtils.getSelector("SimpleBug", "randomWalk");
	modelActions.createActionForEach$message(bugList, sel);

	// We've added another action here, the cleaning out of the
	// reaperQueue of bugs that have died.  It will be done only
	// after all the bugs have taken their random walks.
	sel = SwarmUtils.getSelector(this, "reapBugs");
	modelActions.createActionTo$message(this, sel);

	// Now create the schedule and set the repeat interval to unity.
	modelSchedule = new ScheduleImpl(getZone(), 1);

	// Finally, insert the action list into the schedule at period zero
	modelSchedule.at$createAction(0, modelActions);

	return this;
    }

    // This method specifies the context in which the model is to be run.
    public Activity activateIn(Swarm swarmContext)
    {
	// Use the parent class to activate ourselves in the context
	// passed to us.
	super.activateIn(swarmContext);

	// Then activate the schedule in ourselves.
	modelSchedule.activateIn(this);

	// Finally, return the activity we have built.
	return getActivity();
    }

    // bugDeath insures the orderly death of a bug.  First we check to
    // see that the agent is on the grid where it thinks it is.  If
    // so, we remove it from the grid and add it to reaperQueue for
    // later removal.
    public void bugDeath(SimpleBug abug)
    {
	if ((SimpleBug)bugSpace.getObjectAtX$Y(abug.xPos, abug.yPos) == abug)
	    {
	    bugSpace.putObject$atX$Y(null, abug.xPos, abug.yPos);
	    reaperQueue.addLast(abug);
	    }
    }

    // reapBugs drops the bugs queued for removal.  It is scheduled
    // for action when it is safe to do so, i.e., after all the bugs
    // have finished their random walks.  We get each agent in the
    // reaperQueue and remove it from the bugListf.  If we run out of
    // bugs, we terminate the simulation.
    public void reapBugs()
    {
	SimpleBug abug;

	while (reaperQueue.getCount() != 0)
	    {
	    abug = (SimpleBug)reaperQueue.removeFirst();
	    bugList.remove(abug);
	    System.out.println("Bug " + abug.bugNumber + 
			       " has died of hunger.");
	    abug.drop();
	    numberOfBugs -= 1;
	    }

	// Check the number of remaining bugs and quit the simulation
	// if there are none left, by terminating the ModelSwarm
	// activity.
	if (bugList.getCount() == 0)
	    getActivity().terminate();

    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品在线免费观看| 久久99蜜桃精品| 亚洲成a天堂v人片| 日本不卡免费在线视频| 成人动漫一区二区在线| 欧美日本在线观看| 欧美激情自拍偷拍| 午夜精品久久久久久久久| 国产成人午夜99999| 欧美另类久久久品| 欧美激情一区二区三区在线| 日韩精品视频网| 不卡视频在线看| 日韩欧美一级二级三级久久久| 国产精品婷婷午夜在线观看| 亚洲成人自拍网| 成人国产一区二区三区精品| 日韩一区二区免费在线电影| 亚洲日本在线a| 国产一区二区三区香蕉| 欧美日韩国产综合视频在线观看 | 激情久久五月天| 欧美午夜精品久久久久久超碰| 26uuu国产一区二区三区| 亚洲一区二区三区四区在线免费观看| 国产一区二区三区久久久 | 日韩av一区二| 91网上在线视频| 久久久亚洲精品石原莉奈 | 精品国产一区二区国模嫣然| 玉足女爽爽91| 成人午夜视频在线| 精品国精品国产| 婷婷中文字幕一区三区| av在线不卡免费看| 精品欧美久久久| 午夜国产精品影院在线观看| 色又黄又爽网站www久久| 国产无一区二区| 久久激情五月激情| 欧美日韩黄色影视| 亚洲激情图片一区| av电影一区二区| 国产三级欧美三级日产三级99| 美脚の诱脚舐め脚责91| 色欧美片视频在线观看| 国产精品夫妻自拍| 国产91对白在线观看九色| 精品成人免费观看| 婷婷综合另类小说色区| 欧美色老头old∨ideo| 亚洲激情一二三区| 91在线精品一区二区三区| 欧美极品少妇xxxxⅹ高跟鞋 | 国产精品久久久久9999吃药| 国产一区二区在线免费观看| 日韩欧美二区三区| 免费观看日韩av| 欧美一级欧美三级在线观看| 爽爽淫人综合网网站| 欧美色窝79yyyycom| 一区二区三国产精华液| 色视频成人在线观看免| 一区二区三区在线观看国产 | 亚洲高清在线精品| 欧美日韩免费不卡视频一区二区三区| 洋洋成人永久网站入口| 欧美视频一区二区在线观看| 亚洲一区二区视频在线观看| 欧美在线观看视频在线| 一区二区激情小说| 欧美午夜精品一区| 亚州成人在线电影| 91精品国产福利| 老司机午夜精品99久久| 欧美α欧美αv大片| 国产制服丝袜一区| 国产人久久人人人人爽| 成人美女在线观看| 亚洲日本一区二区| 在线看国产一区二区| 亚洲第一久久影院| 91精品国产欧美一区二区| 玖玖九九国产精品| 久久蜜桃一区二区| 波多野结衣亚洲| 一区二区成人在线| 91麻豆精品国产综合久久久久久| 美女视频一区二区三区| 久久夜色精品一区| av在线一区二区三区| 亚洲国产精品久久人人爱| 欧美一区二区精品在线| 国产激情视频一区二区在线观看 | 日本国产一区二区| 天堂av在线一区| 欧美刺激午夜性久久久久久久| 国产成人午夜精品5599 | 7777精品伊人久久久大香线蕉| 免费成人美女在线观看| 久久精品男人天堂av| 一本久久精品一区二区| 丝袜国产日韩另类美女| 久久久电影一区二区三区| 一本久道中文字幕精品亚洲嫩| 丝袜国产日韩另类美女| 国产亚洲成年网址在线观看| 色婷婷久久99综合精品jk白丝 | 久久精品水蜜桃av综合天堂| 一本一道久久a久久精品综合蜜臀 一本一道综合狠狠老 | 免费成人在线网站| 久久久久久久av麻豆果冻| 91高清在线观看| 狠狠v欧美v日韩v亚洲ⅴ| 亚洲欧洲成人自拍| 在线观看国产日韩| 激情综合五月天| 亚洲精品免费在线播放| 日韩精品一区国产麻豆| 91视频你懂的| 狠狠色狠狠色综合系列| 亚洲精品乱码久久久久久久久| 欧美大白屁股肥臀xxxxxx| 91日韩一区二区三区| 精品在线视频一区| 亚洲一区二区欧美激情| 久久久91精品国产一区二区精品 | 亚洲一本大道在线| 精品国产精品网麻豆系列| 91在线云播放| 国产一区免费电影| 亚洲一区二三区| 日本一区二区三区电影| 欧美一区二区三区视频在线| 99国产一区二区三精品乱码| 韩国午夜理伦三级不卡影院| 亚洲图片一区二区| 亚洲欧洲99久久| 精品国产乱码久久久久久夜甘婷婷| 色婷婷综合在线| 国产河南妇女毛片精品久久久| 婷婷久久综合九色综合伊人色| 中文字幕亚洲欧美在线不卡| 久久久蜜桃精品| 日韩午夜中文字幕| 欧美无乱码久久久免费午夜一区| 国产一二精品视频| 日韩综合一区二区| 亚洲精品久久久久久国产精华液| 国产欧美视频一区二区| 日韩三级在线观看| 欧美久久高跟鞋激| 欧洲人成人精品| 一本久道久久综合中文字幕 | 亚洲欧洲精品一区二区三区不卡| 久久五月婷婷丁香社区| 日韩一区二区免费高清| 欧美日韩不卡视频| 欧洲国内综合视频| 色婷婷激情久久| av不卡免费电影| 国产成人精品免费网站| 国产乱码精品一区二区三| 免费人成网站在线观看欧美高清| 亚洲一区二区三区免费视频| 亚洲日韩欧美一区二区在线| 国产精品伦理在线| 国产精品久久影院| 国产三级久久久| 久久久噜噜噜久久人人看 | thepron国产精品| 风间由美一区二区av101 | 国产精品无码永久免费888| 久久这里只精品最新地址| 欧美mv和日韩mv国产网站| 欧美成人猛片aaaaaaa| 91精品国产黑色紧身裤美女| 欧美一区二区在线免费播放| 欧美肥妇free| 欧美精品色一区二区三区| 欧美丰满少妇xxxxx高潮对白| 欧美三级电影网| 欧美日本一道本在线视频| 欧美一区二区视频在线观看| 日韩一区二区视频在线观看| 日韩美女主播在线视频一区二区三区 | 国产黄色成人av| 高清视频一区二区| 91丨porny丨首页| 一本色道亚洲精品aⅴ| 97精品久久久久中文字幕| 色婷婷综合久久久久中文一区二区| 一本色道久久综合亚洲aⅴ蜜桃 | 麻豆久久一区二区| 蜜桃视频在线观看一区| 免费在线观看精品| 精品无码三级在线观看视频| 丰满少妇在线播放bd日韩电影| 99精品国产99久久久久久白柏| 色av一区二区|