/// <summary> /// エージェントの内部状態を変更する /// エージェントの行動の起点 /// </summary> /// <param name="posx"></param> /// <param name="posy"></param> public void SetState(StateElement se, int confAgentNum, double reward, bool goalflag, bool judgeFlag) { WallQvalueSetting(); step++; if (state != null && goalFlag == false) { paststate = new State(new StateElement(state.StateChar)); } state = new State(se); if (goalFlag == false) { goalFlag = goalflag; } this.reward = reward; //GoalCheck(); ChooseAction(judgeFlag); if (judgeFlag == false) { logger.LogVisitRate(state); } if (goalFlag == true && absorbingFlag == false) // ゴールできたとき { absorbingFlag = true; if (modeChange == false) // 学習モード { logger.LogGoalPosSet(state); memory.SetGoalState(state); //Console.WriteLine("X: " + state.StateChar.X + " Y: " + state.StateChar.Y); for (int i = 0; i < config.GoalNum; i++) { if (memory.GoalDetecting(state) == i) { memory.SetStepTableList(new MemoryTable(i, step, reward)); if (config.Lerning == "PMRL") { if (stepTable[i] > step) { stepTable[i] = step; } if (rewardTable[i] < reward) { rewardTable[i] = reward; } } } } } } else if (step == config.MaxStep) // ゴールできなかった時 { if (modeChange == false) // 学習モード { memory.SetGoalState(new State(null)); } } }
public bool Comparison(StateElement se, int x = 0, int y = 0) { if (se != null) { return((this.x == se.X) && (this.y == se.Y)); } else { return((this.x == x) && (this.y == y)); } }
public State(StateElement stateElement = null, int confAgentNum = 0) { if (stateElement != null) { state = new StateElement(stateElement); } else { state = new StateElement(null); } this.confAgentNum = confAgentNum; }
public StateElement(StateElement se = null) { if (se != null) { x = se.X; y = se.Y; } else { this.x = 0; this.y = 0; } }