当前位置: 首页>>代码示例>>C#>>正文


C# Reward类代码示例

本文整理汇总了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);
 }
开发者ID:Yvaine,项目名称:M.S-P.P,代码行数:41,代码来源:QLambdaLearning.cs

示例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);
 }
开发者ID:radiochecker,项目名称:soomla-unity3d-core,代码行数:7,代码来源:RewardStorageIOS.cs

示例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;
 }
开发者ID:radiochecker,项目名称:soomla-unity3d-core,代码行数:7,代码来源:RewardStorageIOS.cs

示例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();
    }
开发者ID:SunParlorStudios,项目名称:GlobalGameJam16,代码行数:30,代码来源:Ritual.cs

示例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);
			}
		}
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:29,代码来源:Reward.cs

示例6: Start

	void Start() {
		_instance = this;
		base.Init ();
		missionId = 14;
		reward = new Reward (false, 2);
		animated = false;
	}
开发者ID:vit2005,项目名称:seaBattletest1,代码行数:7,代码来源:Mission14.cs

示例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);
 }
开发者ID:radiochecker,项目名称:soomla-unity3d-core,代码行数:8,代码来源:RewardStorageAndroid.cs

示例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;
		}
开发者ID:Ratel13,项目名称:soomla-unity3d-core,代码行数:9,代码来源:RewardStorageAndroid.cs

示例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);
	}
开发者ID:vit2005,项目名称:seaBattletest1,代码行数:10,代码来源:ClassicGame.cs

示例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;
 }
开发者ID:dfalcone,项目名称:soomla-wp-core,代码行数:10,代码来源:SequenceReward.cs

示例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));
    }
开发者ID:sessionm,项目名称:sessionm-enterprise-unity,代码行数:10,代码来源:RewardObject.cs

示例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
		}
开发者ID:anitricks,项目名称:soomla-vungle,代码行数:16,代码来源:SoomlaVungle.cs

示例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);
	}
开发者ID:vit2005,项目名称:seaBattletest1,代码行数:11,代码来源:MultiplayerGame.cs

示例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;
 }
开发者ID:Yvaine,项目名称:M.S-P.P,代码行数:20,代码来源:SarsaLearning.cs

示例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);
		}
开发者ID:Ratel13,项目名称:soomla-unity3d-core,代码行数:11,代码来源:RewardStorageAndroid.cs


注:本文中的Reward类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。