Newer
Older
HelloAndroid / RiverCrossingAI / src / sample / game / ai / Memory.java
package sample.game.ai;

import java.util.ArrayList;

import sample.game.manager.EndIsland;
import sample.game.manager.StartIsland;
import sample.game.model.BoatModel;

public class Memory {

	//初めにここの情報を確定させる
	private StartIsland startIsland;
	private EndIsland endIsland;
	private BoatModel boat;


	//どうやってここの要素に来たかを表す
	private int ministerMoveNum=0;
	private int wolfMoveNum=0;
	private int cabbageMoveNum=0;
	private int cattleMoveNum=0;

	private ArrayList<Memory> nextMemorys;
	private Memory bifMemory;

	private int deepNumber=0;	//深さを示す
	private int id=0;


	public Memory(Memory bif,StartIsland s,EndIsland e,BoatModel b,
			int mNum,int wNum,int cabNum,int catNum){
		this.startIsland=s;
		this.endIsland=e;
		this.boat=b;

		this.bifMemory=bif;

		this.ministerMoveNum=mNum;
		this.wolfMoveNum=wNum;
		this.cabbageMoveNum=cabNum;
		this.cattleMoveNum=catNum;

		this.nextMemorys=new ArrayList<Memory>();

		if(bif!=null){
			this.deepNumber=bif.getDeepNumber()+1;
		}else{
			deepNumber=0;
		}
	}

	/**
	 * 引継ぎに必要なデータを再セット 
	 * (AIでのnextMemoryへの追加のタイミングの問題でここの4つのデータ
	 * 場面が切り替わった時点で再セットする必要がある)
	 * @param s
	 * @param e
	 * @param b
	 * @param layout
	 */
	public void setData(StartIsland s,EndIsland e,BoatModel b){
		this.startIsland=s;
		this.endIsland=e;
		this.boat=b;
	}


	public int getDeepNumber(){
		return this.deepNumber;
	}

	public int getId(){
		return this.id;
	}

	public void setId(int d){
		this.id=d;
	}



	public StartIsland getStartIsland() {
		return startIsland;
	}



	public EndIsland getEndIsland() {
		return endIsland;
	}


	public BoatModel getBoat() {
		return boat;
	}



	public int getMinisterMoveNum() {
		return ministerMoveNum;
	}



	public int getWolfMoveNum() {
		return wolfMoveNum;
	}



	public int getCabbageMoveNum() {
		return cabbageMoveNum;
	}



	public int getCattleMoveNum() {

		return cattleMoveNum;
	}

	public Memory getBifMemory(){
		return bifMemory;
	}


	public void addNextMemorys(Memory ai){
		this.nextMemorys.add(ai);
		ai.setId(this.nextMemorys.size());
	}



	public ArrayList<Memory> getNextMemorys(){
		return nextMemorys;
	}


	public void removeNextmemorys(int index){
		this.nextMemorys.remove(index);
	}


}