所属分类:repast发表于:2007年, 08月21日, 星期二crab
有了第四章的基础,我们来写一个自己的Model 阅读全文 »
标签:
agent,
i am,
myx,
myy,
repast,
repast 入门,
repast 学习,
repast 教程,
sim,
坐标,
模拟
所属分类:repast发表于:2007年, 08月21日, 星期二crab
前面我们写的Model都是基于SimModelImpl 的,其实可以有一个更好的父类可以让我们使用,那就是SimpleModel,它也是继承自SimModelImpl,我们来分析下它的源代码 阅读全文 »
标签:
agent,
repast,
repast 入门,
repast 学习,
repast 教程,
sim,
simplemodel,
uchicago,
模拟
所属分类:repast发表于:2007年, 08月21日, 星期二crab
上一章,我们用了TextDisplay和Value2DDisplay来显示界面,Value2DDisplay用 Discrete2DSpace和ColorMap配合来进行显示。现在我们讨论下 Object2DDisplay,看看它的构造函数:uchicago.src.sim.gui.Object2DDisplay.Object2DDisplay(Discrete2DSpace)
可以看出,没有了ColorMap,那么它是如何进行绘制的呢?按照我们的推论,肯定是Discrete2DSpace里的Object实现了某种绘制的接口。比如 :
new Object2DGrid(50,50).putObjectAt(20,20,myObject) 这里的myObject一定已经实现了某种绘制功能。 阅读全文 »
标签:
agent,
display,
displaysurf,
gui,
repast,
repast 入门,
repast 学习,
repast 教程,
sim,
接口
所属分类:repast发表于:2007年, 08月20日, 星期一crab
这一章我们来讨论下CarryDropSpace,它主要负责界面上的工作。来看一下它的代码:
- // CarryDropSpace.java
- package demo;
-
- import uchicago.src.sim.space.Object2DGrid; //这是space包中最常见的类,它是以一种非连续的格子来存放object,以x轴和y轴来标识。
-
-
-
-
- public class CarryDropSpace ...{
- private Object2DGrid moneySpace;
-
- public CarryDropSpace(int xSize, int ySize)...{
- moneySpace = new Object2DGrid(xSize, ySize);
-
- for(int i = 0; i < xSize; i++)...{
- for(int j = 0; j < ySize; j++)...{
- moneySpace.putObjectAt(i,j,new Integer(0)); //把所有的格子都放满 Integer(0) 这个对象。
- }
- }
- }
-
- public void spreadMoney(int money)...{
- // Randomly place money in moneySpace
- for(int i = 0; i < money; i++)...{
-
- // Choose coordinates
- int x = (int)(Math.random()*(moneySpace.getSizeX()));
- int y = (int)(Math.random()*(moneySpace.getSizeY()));
-
- // Get the value of the object at those coordinates
- int currentValue = getMoneyAt(x, y);
- // Replace the Integer object with another one with the new value
- moneySpace.putObjectAt(x,y,new Integer(currentValue + 1)); //随机改变money个格子里的对象为 Integer(1)
- }
- }
-
- public int getMoneyAt(int x, int y)...{
- int i;
- if(moneySpace.getObjectAt(x,y)!= null)...{
- i = ((Integer)moneySpace.getObjectAt(x,y)).intValue();
- }
- else...{
- i = 0;
- }
- return i;
- }
-
- public Object2DGrid getCurrentMoneySpace()...{
- return moneySpace;
- }
-
- }
阅读全文 »
标签:
agent,
displaysurface,
moneyspace,
repast,
repast 入门,
repast 学习,
repast 教程,
sim,
接口,
界面
所属分类:repast发表于:2007年, 08月17日, 星期五crab
第一章 概要
REPAST —— 一个多Agent仿真平台 对于国内做AGENT研究的学子来说,是一个不错的开源框架。本人也是研究AGENT的,希望和大家多多探讨。废话少说,我们开始吧。
注明:这个教程是我从 A RePast Tutorial by John T. Murphy, University of Arizona & Arizona State University 翻译过来,再按照自己的理解所写,希望对大家有所帮助。
阅读全文 »
标签:
agent,
arizona,
repast,
repast 入门,
repast 学习,
repast 教程