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

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

?? modelswarm.java

?? 這是一個使用Eclipse構建基于Swarm平臺的復雜系統的優秀例子。
?? 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.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一区二区三区免费野_久草精品视频
丁香婷婷综合色啪| 三级一区在线视频先锋| 自拍偷拍亚洲综合| 亚洲午夜久久久久久久久电影网| 亚洲国产一区二区视频| 美国十次综合导航| 成人美女在线观看| 一区二区三区日韩精品视频| 亚洲一区二区三区三| 毛片一区二区三区| av网站一区二区三区| 91精品国产91综合久久蜜臀| 久久婷婷色综合| 亚洲综合一区二区精品导航| 麻豆91免费观看| 91视频你懂的| 欧美大片拔萝卜| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 久久伊人中文字幕| 一区二区三区中文免费| 极品少妇一区二区| 色噜噜狠狠一区二区三区果冻| 精品久久久久久久久久久久久久久| 亚洲天堂成人在线观看| 激情久久久久久久久久久久久久久久| 成人黄色电影在线| 日韩免费观看高清完整版在线观看| 一区在线观看视频| 久久丁香综合五月国产三级网站| 91色porny蝌蚪| 国产日产欧美一区二区视频| 午夜精品爽啪视频| 成人av午夜电影| www日韩大片| 丝袜亚洲另类欧美综合| 91网站在线播放| 久久精品一区二区三区四区| 视频在线在亚洲| 色狠狠色狠狠综合| 中文字幕在线播放不卡一区| 久久精品国产成人一区二区三区 | 国产精品成人免费| 国内精品免费**视频| 欧美日韩精品电影| 一区二区三区产品免费精品久久75| 欧美精品在线观看播放| 国产精品久久久久毛片软件| 蜜桃视频免费观看一区| 欧美日韩视频在线观看一区二区三区 | 亚洲成a天堂v人片| 色94色欧美sute亚洲线路二| 国产免费成人在线视频| 精彩视频一区二区| 日韩视频在线一区二区| 婷婷综合另类小说色区| 欧美四级电影网| 亚洲欧美日韩成人高清在线一区| 国产精品香蕉一区二区三区| 欧美成人一区二区三区片免费| 亚洲成年人网站在线观看| 色婷婷国产精品| 亚洲欧美自拍偷拍| 波多野结衣亚洲一区| 日本一区二区三区视频视频| 国产真实乱子伦精品视频| 日韩女优av电影| 久久国产精品色| 欧美一级专区免费大片| 日韩1区2区日韩1区2区| 3atv在线一区二区三区| 亚洲国产aⅴ成人精品无吗| 欧美视频一区二区三区在线观看 | 在线观看一区二区精品视频| 一区二区三区免费看视频| 一本一道久久a久久精品| 亚洲男人电影天堂| 在线亚洲一区观看| 亚洲小说春色综合另类电影| 欧美私人免费视频| 性久久久久久久久久久久| 欧美久久久一区| 男男成人高潮片免费网站| 日韩欧美不卡在线观看视频| 久久国内精品视频| 久久精子c满五个校花| 成人中文字幕合集| 亚洲人妖av一区二区| 欧洲精品一区二区| 日本亚洲免费观看| 精品99999| 不卡一区二区中文字幕| 亚洲激情中文1区| 91精品国产欧美一区二区| 激情综合网最新| 国产精品私房写真福利视频| 91天堂素人约啪| 五月婷婷综合在线| 欧美videos大乳护士334| 高清不卡一二三区| 亚洲一卡二卡三卡四卡五卡| 欧美丰满少妇xxxxx高潮对白| 狠狠色丁香婷婷综合久久片| 中文字幕免费一区| 欧美日韩亚洲另类| 国产伦精品一区二区三区视频青涩| 国产精品入口麻豆九色| 精品视频在线免费观看| 捆绑变态av一区二区三区| 中文字幕精品一区二区精品绿巨人| 色噜噜夜夜夜综合网| 日韩av电影免费观看高清完整版| 久久夜色精品一区| 色婷婷亚洲一区二区三区| 免费看黄色91| 国产精品国模大尺度视频| 欧美日本一区二区在线观看| 狠狠色丁香久久婷婷综合_中 | 色成年激情久久综合| 日本视频中文字幕一区二区三区| 国产偷v国产偷v亚洲高清| 欧美在线一区二区| 国产在线播放一区| 一区二区在线电影| 久久综合99re88久久爱| 日本久久一区二区| 国产伦精品一区二区三区在线观看| 亚洲欧美日本在线| 2022国产精品视频| 欧美综合在线视频| 国产**成人网毛片九色| 日韩av电影免费观看高清完整版在线观看| 国产欧美一区二区精品性| 欧美久久久久中文字幕| 成人av电影在线| 蜜臀av一级做a爰片久久| 亚洲欧美国产毛片在线| 久久亚洲春色中文字幕久久久| 91久久久免费一区二区| 国产精品91xxx| 日产国产欧美视频一区精品| 成人欧美一区二区三区黑人麻豆| 精品国产网站在线观看| 欧美午夜一区二区| eeuss影院一区二区三区 | 99国产精品99久久久久久| 日韩一区二区三区观看| 国产iv一区二区三区| 亚洲成人先锋电影| 国产精品乱人伦| 26uuu亚洲婷婷狠狠天堂| 欧美日韩免费电影| 99精品视频在线观看免费| 久久国产成人午夜av影院| 亚洲国产精品久久艾草纯爱| 国产精品久久久久久久久晋中| 精品三级av在线| 欧美老肥妇做.爰bbww视频| 色综合久久88色综合天天免费| 国产91在线观看| 国产美女一区二区| 理论片日本一区| 日本视频中文字幕一区二区三区| 一区二区成人在线观看| 自拍视频在线观看一区二区| 久久久久久亚洲综合| 2023国产精品视频| 精品国一区二区三区| 欧美一级理论片| 91精品久久久久久蜜臀| 欧美日韩一区二区在线观看| 91久久国产综合久久| 色欧美片视频在线观看| 色哟哟一区二区三区| 91丨porny丨国产| eeuss国产一区二区三区| 成人一二三区视频| 成人国产一区二区三区精品| 国产精品夜夜嗨| 成人性视频网站| 丁香五精品蜜臀久久久久99网站 | 亚洲成人午夜影院| 久久网站热最新地址| 欧美在线免费播放| 99精品久久免费看蜜臀剧情介绍| 成人黄色在线网站| 99免费精品视频| 91丝袜美女网| 欧美亚洲精品一区| 欧美日本国产视频| 5月丁香婷婷综合| 欧美一级高清大全免费观看| 欧美一卡二卡在线| 精品国产污污免费网站入口 | 激情久久五月天| 国产成人免费视频| 91在线视频播放地址| 色呦呦国产精品| 3d成人h动漫网站入口| 欧美成人video| 欧美国产一区二区在线观看|