本文整理汇总了C#中Reward类的典型用法代码示例。如果您正苦于以下问题:C# Reward类的具体用法?C# Reward怎么用?C# Reward使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Reward类属于命名空间,在下文中一共展示了Reward类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: __update_q_value
/// <summary>
/// Updates the Q-Value
/// </summary>
/// <param name="st">The state at `t`</param>
/// <param name="a">The action at `t`</param>
/// <param name="r">The awarded reward at `t+1`</param>
/// <param name="stplus">The state at `t+1`</param>
/// <returns>The updated Q-Value</returns>
protected override EligVal __update_q_value(State st, Action a, Reward r, State stplus, params object[] aplus)
{
if (aplus.Length == 0 || !(aplus[0] is Action))
throw new ArgumentException("Expecting an action as last comment", "aplus");
var qt = this.__get_q_value(st, a);
// if a' ties for the max, the a* ← a'
Action astar = (Action)aplus[0];
// Q(s', a')
QVal v = this.__get_q_value(stplus, astar);
// argmaxQ(s', b)
foreach (var __a in this.Actions) { var __q = this.__get_q_value(stplus, __a); if (v < __q) { v = __q; astar = __a; } }
// δ ← r + γ * Q(s', a*) - Q(s, a)
var delta = (r + this.Gamma * this.__get_q_value(stplus, astar) - this.__get_q_value(st, a));
// e(s, a) ← e(s, a) + 1
this.__set_elig_value(st, a, this.__get_elig_value(st, a) + 1);
var keys = this.QTable.Keys.Cast<KeyValuePair<State, Action>>().ToArray();
// for each s,a
for (int i = 0; i < keys.Length; i++)
{
var sa = (KeyValuePair<State, Action>)keys[i];
// Q(s, a) ← Q(s, a) + αδe(s, a)
this.__set_q_value(sa.Key, sa.Value, (QVal)this.QTable[sa] + this.Alpha * delta * this.__get_elig_value(sa.Key, sa.Value));
// if a' = a*
if ((Action)aplus[0] == astar)
// e(s, a) ← γλe(s, a)
this.__set_elig_value(sa.Key, sa.Value, this.Gamma * this.Lambda * this.__get_elig_value(sa.Key, sa.Value));
else
// e(s, a) ← 0
this.__set_elig_value(sa.Key, sa.Value, 0);
}
// return the updated Q-Value
return this.__get_q_value(st, a);
}
示例2: _getLastGivenTime
protected override DateTime _getLastGivenTime(Reward reward)
{
string rewardJson = seqReward.toJSONObject().ToString();
long lastTime = rewardStorage_GetLastGivenTimeMillis(rewardJson);
TimeSpan time = TimeSpan.FromMilliseconds(lastTime);
return new DateTime(time.Ticks);
}
示例3: _getTimesGiven
protected override int _getTimesGiven(Reward reward)
{
string rewardJson = reward.toJSONObject().ToString();
int times = rewardStorage_GetTimesGiven(rewardJson);
SoomlaUtils.LogDebug("SOOMLA/UNITY RewardStorageIOS", string.Format("reward {0} given={1}", reward.ID, times));
return times;
}
示例4: ConstructRitual
public void ConstructRitual(int length, Difficulty difficulty)
{
reward = Reward.GetReward(length);
ritual = new List<RitualKey>();
List<KeyCodes> keyCodesPool = new List<KeyCodes>()
{
KeyCodes.A, KeyCodes.B, KeyCodes.X, KeyCodes.Y
};
if (difficulty == Difficulty.Medium)
{
keyCodesPool.AddRange(new KeyCodes[4]{ KeyCodes.Left, KeyCodes.Right, KeyCodes.Up, KeyCodes.Down });
}
if (difficulty == Difficulty.Hard)
{
keyCodesPool.AddRange(new KeyCodes[4] { KeyCodes.LT, KeyCodes.RT, KeyCodes.LB, KeyCodes.RB });
}
for (int i = 0; i < length; ++i)
{
RitualKey ritualKey = new RitualKey(keyCodesPool[Random.Range(0, keyCodesPool.Count)]);
ritual.Add(ritualKey);
}
PostChangedEvent();
}
示例5: getRandomReward
public static Reward getRandomReward(int value) {
List<string> list = new List<string>();
string[] arr;
arr = new string[]{"Copper","Iron","Silver","Gold","Demonite","Meteorite","Hellstone"};
foreach (string s in arr) list.Add(s+" Bar");
arr = new string[]{"Amethyst","Topaz","Sapphire","Emerald","Ruby","Diamond"};
foreach (string s in arr) list.Add(s);
if (Main.hardMode) {
arr = new string[]{"Cobalt","Mythril","Adamantite"};
foreach (string s in arr) list.Add(s+" Bar");
}
while (true) {
if (Main.rand.Next(3) >= 1) {
string name = list[Main.rand.Next(list.Count)];
Item item = Config.itemDefs.byName[name];
if (item.value > value) continue;
Reward r = new Reward(name,(int)(value/item.value));
if (r.amount <= Config.itemDefs.byName[r.itemName].maxStack) return r;
} else {
string type = "Copper Coin";
if (value >= 100) {value /= 100; type = "Silver Coin";}
if (value >= 100) {value /= 100; type = "Gold Coin";}
if (value >= 100) {value /= 100; type = "Platinum Coin";}
return new Reward(type,value);
}
}
}
示例6: Start
void Start() {
_instance = this;
base.Init ();
missionId = 14;
reward = new Reward (false, 2);
animated = false;
}
示例7: _setTimesGiven
protected override void _setTimesGiven(Reward reward, bool up, bool notify)
{
AndroidJNI.PushLocalFrame(100);
using(AndroidJavaClass jniRewardStorage = new AndroidJavaClass("com.soomla.data.RewardStorage")) {
jniRewardStorage.CallStatic("setTimesGiven", reward.toJNIObject(), up, notify);
}
AndroidJNI.PopLocalFrame(IntPtr.Zero);
}
示例8: _getTimesGiven
override protected int _getTimesGiven(Reward reward) {
int times = 0;
AndroidJNI.PushLocalFrame(100);
using(AndroidJavaClass jniRewardStorage = new AndroidJavaClass("com.soomla.data.RewardStorage")) {
times = jniRewardStorage.CallStatic<int>("getTimesGiven", reward.ID);
}
AndroidJNI.PopLocalFrame(IntPtr.Zero);
return times;
}
示例9: Start
void Start() {
_instance = this;
bf = BattlefieldScript.Instance;
//bfc = bf.bf;
su = Submarine.Instance;
sh = Ship.Instance;
//la = LanguageScript.Instance;
mo = move.Instance;
reward = new Reward (false, 2);
}
示例10: ForceNextRewardToGive
public bool ForceNextRewardToGive(Reward reward)
{
for (int i = 0; i < Rewards.Count; i++) {
if (Rewards[i].GetId() == reward.GetId()) {
RewardStorage.SetLastSeqIdxGiven(mID, i - 1);
return true;
}
}
return false;
}
示例11: SetReward
public void SetReward(Reward reward)
{
title.text = reward.name;
tier.text = "Tier: " + reward.tier;
type.text = "Type: " + reward.type;
points.text = reward.ToString ();
this.url = reward.url;
StartCoroutine (DownloadImage (reward.imageURL));
}
示例12: PlayAd
/// <summary>
/// Plays a video ad and grants the user a reward for watching it.
/// </summary>
/// <param name="reward">The reward that will be given to users for watching the video ad.</param>
/// <param name="enableBackButton">Determines whether you would like to give the user the
/// option to skip out of the video. <c>true</c> means a close button will be displayed.</param>
public static void PlayAd(Reward reward, bool enableBackButton) {
SoomlaUtils.LogDebug(TAG, "Playing Vungle Ad");
#if UNITY_ANDROID && !UNITY_EDITOR
AndroidJNI.PushLocalFrame(100);
jniSoomlaVungle.Call("playIncentivisedAd", enableBackButton, true, (reward == null ? null : reward.toJNIObject()));
AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
soomlaVungle_PlayAd(enableBackButton, (reward == null ? null : reward.toJSONObject().print()));
#endif
}
示例13: Start
void Start() {
Debug.Log ("!!! MULTIPLAYER INITIATED !!!");
_instance = this;
bf = BattlefieldScript.Instance;
bfc = bf.bf;
su = Submarine.Instance;
sh = Ship.Instance;
la = LanguageScript.Instance;
mo = move.Instance;
reward = new Reward (false, 5);
}
示例14: __update_q_value
/// <summary>
/// Updates the Q-Value
/// </summary>
/// <param name="st">The state at `t`</param>
/// <param name="a">The action at `t`</param>
/// <param name="r">The awarded reward at `t+1`</param>
/// <param name="stplus">The state at `t+1`</param>
/// <param name="aplus">The action at `t+1`</param>
/// <returns>The updated Q-Value</returns>
protected override QVal __update_q_value(State st, Action a, Reward r, State stplus, params object[] aplus)
{
if (aplus.Length == 0 || !(aplus[0] is Action))
throw new ArgumentException("Expecting an action as last comment", "aplus");
var qt = this.__get_q_value(st, a);
var v = this.__get_q_value(stplus, (Action)aplus[0]);
// Q(s, a) ← (1 - α)Q(s, a) + α[r + γ * Q(s', a')]
qt = (1 - this.Alpha) * qt + this.Alpha * (r + this.Gamma * v);
this.__set_q_value(st, a, qt);
return qt;
}
示例15: _getLastGivenTime
override protected DateTime _getLastGivenTime(Reward reward) {
long lastTime = 0;
AndroidJNI.PushLocalFrame(100);
using(AndroidJavaClass jniRewardStorage = new AndroidJavaClass("com.soomla.data.RewardStorage")) {
lastTime = jniRewardStorage.CallStatic<long>("getLastGivenTimeMillis", reward.ID);
}
AndroidJNI.PopLocalFrame(IntPtr.Zero);
TimeSpan time = TimeSpan.FromMilliseconds(lastTime);
return new DateTime(time.Ticks);
}