• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Reward类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Reward的典型用法代码示例。如果您正苦于以下问题:C# Reward类的具体用法?C# Reward怎么用?C# Reward使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Reward类属于命名空间,在下文中一共展示了Reward类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: OnPopulateRewards

    public void OnPopulateRewards(Reward[] rewards)
    {
        int childCount = rewardsGrid.transform.childCount;
        for (int i = childCount - 1; i >= 0; i--) {
            Debug.Log("Deleting i: " + i);
            GameObject.DestroyImmediate(rewardsGrid.transform.GetChild(i).gameObject);
        }

        for (int i = 0; i < rewards.Length; i++) {
            Reward reward = rewards[i];
            RewardObject rewardGO = (RewardObject) GameObject.Instantiate (rewardObjectPrefab);
            rewardGO.transform.SetParent(rewardsGrid.transform);
            rewardGO.transform.localScale = Vector3.one;
            rewardGO.SetReward (reward);
        }
    }
开发者ID:sessionm,项目名称:sessionm-enterprise-unity,代码行数:16,代码来源:SessionMSampleGUI.cs


示例17: __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 QVal __update_q_value(State st, Action a, Reward r, State stplus, params object[] o)
 {
     var qt = this.__get_q_value(st, a);
     QVal v = QVal.MinValue;
     // argmaxQ(s', b)                   
     foreach (var __a in this.Actions)
     {
         var __q = this.__get_q_value(stplus, __a);
         if (v < __q)
             v = __q;
     }
     // Q(s, a) ← (1 - α)Q(s, a) + α[r + γ * argmaxQ(s', b)]
     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,代码行数:24,代码来源:QLearning.cs


示例18: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            Log.Info("CreateRewardForm", "Create Reward Form created");

            base.OnCreate(bundle);

            SetContentView(Resource.Layout.CreateRewardForm);

            var layout = FindViewById<LinearLayout>(Resource.Id.CreateRewardFormLayout);
            layout.SetBackgroundResource(Resource.Color.darkblue);

            var customRewardTitle = FindViewById<EditText>(Resource.Id.CustomRewardTitle);

            var customRewardContent = FindViewById<EditText>(Resource.Id.CustomRewardContent);

            var customRewardAddGoalButton = FindViewById<Button>(Resource.Id.CustomRewardAddGoalButton);
            customRewardAddGoalButton.Click += delegate { StartActivity(typeof (SelectCustomRewardGoal)); };

            var submitCustomRewardButton = FindViewById<Button>(Resource.Id.SubmitCustomRewardButton);
            submitCustomRewardButton.Click += delegate
                {
                    var title = customRewardTitle.Text;
                    var content = customRewardContent.Text;
                    if (_goalsList.Count != 0)
                    {
                        var reward = new Reward(title, content, _goalsList);
                        var storedRewards = JavaIO.LoadData<List<Reward>>(this, "Rewards.zad");
                        storedRewards.Add(reward);
                        var successfulSave = JavaIO.SaveData(this, "Rewards.zad", storedRewards);
                        if (successfulSave)
                        {
                            Toast.MakeText(this, "Reward Saved", ToastLength.Long).Show();
                            Finish();
                        }
                        else
                        {
                            Log.Error("CreateRewardForm", "Save reward error");
                            Toast.MakeText(this, "Error saving reward", ToastLength.Long).Show();
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, "Must select a goal", ToastLength.Long).Show();
                    }
                };
        }
开发者ID:ZAD-Man,项目名称:Zadify,代码行数:46,代码来源:CreateRewardForm.cs


示例19: 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");

			savedReward = reward;

#if UNITY_ANDROID && !UNITY_EDITOR
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniSoomlaVungleClass = new AndroidJavaClass("com.soomla.plugins.ads.vungle.SoomlaVungle")) {
				using(AndroidJavaObject jniSoomlaVungle = jniSoomlaVungleClass.CallStatic<AndroidJavaObject>("getInstance")) {
					jniSoomlaVungle.Call("playIncentivisedAd", enableBackButton, true, null);
				}
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
			soomlaVungle_PlayAd(enableBackButton);
#endif
		}
开发者ID:Ratel13,项目名称:soomla-vungle,代码行数:23,代码来源:SoomlaVungle.cs


示例20: Start

 void Start()
 {
     oh = objcHandlerObj.GetComponent<ObjectiveHandler> ();
     pv = player.GetComponent<PlayerVolume> ();
     sQstring = startQuestText.text;
     fQstring = finishQuestText.text;
     char[] delimitingChars = {'\n'};
     sQLines = sQstring.Split (delimitingChars);
     fQLines = fQstring.Split (delimitingChars);
     ch = chatHandlerObject.GetComponent<ChatHandler> ();
     npcb = this.GetComponent<NPCBehaviour> ();
     objectContainer = questObjectContainer.transform;
     questStarted = false;
     questFinished = false;
     r = new Reward (0, levelReward);
     q = new Quest (this.gameObject, r, quest_name, quest_description);
 }
开发者ID:alex-zhang-ayz,项目名称:questforcake,代码行数:17,代码来源:NPC_DestroyObjects.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RewriteRuleSubtreeStream类代码示例发布时间:2022-05-24
下一篇:
C# RevisionGridLayout类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap