本文整理汇总了C#中Move.CustomHash方法的典型用法代码示例。如果您正苦于以下问题:C# Move.CustomHash方法的具体用法?C# Move.CustomHash怎么用?C# Move.CustomHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Move
的用法示例。
在下文中一共展示了Move.CustomHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Learn
public void Learn(VirusBoard startstate, VirusBoard endstate, Move action, double reward) {
// -- Make sure the entries for the state and action exist --
if (!Q.ContainsKey(startstate.CustomHash()))
Q.Add(startstate.CustomHash(), new Dictionary<UInt32, double>());
if (!Q[startstate.CustomHash()].ContainsKey(action.CustomHash()))
Q[startstate.CustomHash()].Add(action.CustomHash(), initvalue);
if (!N.ContainsKey(startstate.CustomHash()))
N.Add(startstate.CustomHash(), new Dictionary<UInt32, int>());
if (!N[startstate.CustomHash()].ContainsKey(action.CustomHash()))
N[startstate.CustomHash()].Add(action.CustomHash(), 0);
// -- Perform the update of Q-values --
N[startstate.CustomHash()][action.CustomHash()]++;
Q[startstate.CustomHash()][action.CustomHash()] =
Q[startstate.CustomHash()][action.CustomHash()]
+ LearningRate(N[startstate.CustomHash()][action.CustomHash()])
* (reward + discount * GetMaxQ(endstate) - Q[startstate.CustomHash()][action.CustomHash()]);
}
示例2: Move
public override Move Move(Virus percept) {
VirusBoard newState = percept.GetBoardCopy();
if (!Q.ContainsKey(newState.CustomHash()))
Q.Add(newState.CustomHash(), new Dictionary<UInt32, double>());
if (learn && !prevState.Equals(default(VirusBoard))) {
if (!N.ContainsKey(prevState.CustomHash()))
N.Add(prevState.CustomHash(), new Dictionary<UInt32, int>());
if (!N[prevState.CustomHash()].ContainsKey(prevAction.CustomHash()))
N[prevState.CustomHash()].Add(prevAction.CustomHash(), 0);
N[prevState.CustomHash()][prevAction.CustomHash()]++;
Q[prevState.CustomHash()][prevAction.CustomHash()] =
Q[prevState.CustomHash()][prevAction.CustomHash()]
+ LearningRate(N[prevState.CustomHash()][prevAction.CustomHash()])
* (prevReward + discount * GetMaxQ(newState) - Q[prevState.CustomHash()][prevAction.CustomHash()]);
}
prevState = newState;
prevAction = GetMaxExplorationFunctionA(newState);
prevReward = 0;
if (learn && !Q[prevState.CustomHash()].ContainsKey(prevAction.CustomHash()))
Q[prevState.CustomHash()].Add(prevAction.CustomHash(), initvalue);
return prevAction;
}