org.boxed_economy.components.cell
クラス CellSpace

java.lang.Object
  拡張org.boxed_economy.components.cell.CellSpace
すべての実装インタフェース:
java.io.Serializable, Space

public class CellSpace
extends java.lang.Object
implements Space

Spaceを継承して、セル空間を定義します。縦横有限個のセルから構成され たSpaceを定義します。このセル空間にはエージェントを配置することができます。 このクラスではセルとエージェントの対応を保持し、取得可能にすることで、 エージェントの配置を定義しています。一つのセルに複数のエージェントを配置する ことが可能です。

バージョン:
$Id: CellSpace.java,v 1.1 2004/03/21 12:07:47 macchan Exp $
作成者:
Boxed Economy Project & Numeric Co,Ltd.
関連項目:
直列化された形式

フィールドの概要
 
インタフェース org.boxed_economy.besp.model.fmfw.Space から継承したフィールド
serialVersionUID
 
コンストラクタの概要
CellSpace(int xCellNum, int yCellNum, boolean isRound)
          コンストラクタです。
 
メソッドの概要
 void addAgent(Agent agent, int x, int y)
          x,yの座標のCellにエージェントを追加します。
 int getAgentCount()
          この空間に存在するエージェント数を返します。
 java.util.Collection getAgents(Agent centerAgent, CellScope scope)
          エージェントとスコープから該当するエージェントを取得します。
 java.util.Collection getAgents(Cell cell)
          セルにいるエージェントを検索します。
 java.util.Collection getAgents(int x, int y)
          セルにいるエージェントを検索します。
 Cell getCell(Agent agent)
          エージェントのいるCellを検索します。
 Cell getCell(int x, int y)
          引数の座標のCellを返します。
 java.util.Collection getCells(Agent centerAgent, CellScope scope)
          エージェントとスコープから該当するセルを取得します。
 int getXCellNum()
          この空間の横の広さを返します。
 int getYCellNum()
          この空間の縦の広さを返します。
 void moveAgent(Agent agent, Cell newCell)
          エージェントを移動させるためのメソッドです。
 void removeAgent(Agent agent)
          このSpaceからAgentを削除します。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

CellSpace

public CellSpace(int xCellNum,
                 int yCellNum,
                 boolean isRound)
コンストラクタです。大きさと巻き戻りの有無を指定して生成します。

パラメータ:
xCellNum -
yCellNum -
isRound -
メソッドの詳細

moveAgent

public void moveAgent(Agent agent,
                      Cell newCell)
エージェントを移動させるためのメソッドです。 エージェントに対応するCellを置き換えます。 もし、不正なCellを移動先として与えた場合、Exceptionを返します。

パラメータ:
agent - 移動するエージェント
newCell - 移動先のCell

addAgent

public void addAgent(Agent agent,
                     int x,
                     int y)
x,yの座標のCellにエージェントを追加します。 追加先の座標が不正であった場合、またはエージェントが全てどこかに 配置されている場合、Exceptionを返します。

パラメータ:
agent -
x -
y -

removeAgent

public void removeAgent(Agent agent)
このSpaceからAgentを削除します。

パラメータ:
agent -

getCell

public Cell getCell(Agent agent)
エージェントのいるCellを検索します。引数のエージェントの存在するCellを返します。

パラメータ:
agent -
戻り値:
Cell

getAgents

public java.util.Collection getAgents(Cell cell)
セルにいるエージェントを検索します。 引数のCellに関連付けられているAgentのCollectionを返します。

パラメータ:
cell -
戻り値:
Collection

getAgents

public java.util.Collection getAgents(int x,
                                      int y)
セルにいるエージェントを検索します。 引数のx,y座標のCellに関連付けられているAgentのCollectionを返します。

パラメータ:
x -
y -
戻り値:
Collection

getCells

public java.util.Collection getCells(Agent centerAgent,
                                     CellScope scope)
エージェントとスコープから該当するセルを取得します。

パラメータ:
centerAgent - スコープの中心のエージェント
scope - そのエージェントのスコープ
戻り値:
Collection 該当するセルの集合

getAgents

public java.util.Collection getAgents(Agent centerAgent,
                                      CellScope scope)
エージェントとスコープから該当するエージェントを取得します。

パラメータ:
centerAgent - スコープの中心のエージェント
scope - そのエージェントのスコープ
戻り値:
Collection 該当するエージェントの集合

getCell

public Cell getCell(int x,
                    int y)
引数の座標のCellを返します。

パラメータ:
x -
y -
戻り値:
Cell

getAgentCount

public int getAgentCount()
この空間に存在するエージェント数を返します。

戻り値:
int

getXCellNum

public int getXCellNum()
この空間の横の広さを返します。

戻り値:
int

getYCellNum

public int getYCellNum()
この空間の縦の広さを返します。

戻り値:
int