アイテムレコード
4352 ワード
データと表現の分離:細胞自動機
フィールドにcellを複数作成します.
各cellには生きているか死んでいるかの属性が設定されています.
コンテナを1次元配列Cellに変換すると、listのサイズが指定されます.
field.place(row, col, new Cell()
public Cell place(int row, int col, Cell o) {
Cell ret = cells[row][col];
cells[row][col] = o;
return ret;
}
フィールドにcellを複数作成します.
for ( int row = 0; row<field.getHeight(); row++ ) {
for ( int col = 0; col<field.getWidth(); col++ ) {
Cell cell = field.get(row, col);
if ( Math.random() < 0.2 ) {
cell.reborn();
}
}
}
各cellには生きているか死んでいるかの属性が設定されています.
return list.toArray(new Cell[list.size()]);
コンテナを1次元配列Cellに変換すると、listのサイズが指定されます.