protected override void OnEnter(AgentAction action) { this.mLocomotion.StopMove(); mAction = action as AgentActionAttack; mStartRotation = this.mAgent.transform.rotation; if (mAction.mTargetAgent != null) { float angle = 0; Vector3 dir = mAction.mTargetAgent.transform.position - this.mAgent.transform.position; if (dir.sqrMagnitude > 0.1f * 0.1f) { dir.Normalize(); angle = Vector3.Angle(this.mAgent.transform.forward, dir); } else { dir = this.mAgent.transform.forward; } mFinalRotation.SetLookRotation(dir); mRotationTime = angle / 1000.0f; } else { mFinalRotation.SetLookRotation(mAction.mAttackDir); mRotationTime = Vector3.Angle(this.mAgent.transform.forward, mAction.mAttackDir) / 1000.0f; } isRotationOk = mRotationTime == 0; mCurrentRotationTime = 0; }
public void PushAction(AgentAction action) { for (int i = 0; i < actionHandlerList.Count; ++i) { if (actionHandlerList[i] != null) actionHandlerList[i].HandleAction(action); } AgentActionFactory.RecycleAction(action); }
protected void ProgressToNextState(AgentAction action) { if (mNextState != null) { if (mNextState == mCurrentState) { mNextState = null; return; } if (null != mCurrentState) mCurrentState.Exit(); mCurrentState = mNextState; mCurrentState.Enter(action); mNextState = null; } }
protected override void OnEnter(AgentAction action) { mCurrentAction = action; if (mCurrentAction is AgentActionGoTo) { AgentActionGoTo act = mCurrentAction as AgentActionGoTo; this.mLocomotion.NavgateTo(act.mTargetPosition); } else if (mCurrentAction is AgentActionMoveTowards) { AgentActionMoveTowards act = mCurrentAction as AgentActionMoveTowards; act.mDirection.y = 0; this.mLocomotion.Move(act.mDirection); } }
public override bool HandleAction(AgentAction action) { // to do if (action is AgentActionGoTo) { //mCurrentAction = action; AgentActionGoTo act = action as AgentActionGoTo; this.mLocomotion.NavgateTo(act.mTargetPosition); return true; } else if (action is AgentActionMoveTowards) { AgentActionMoveTowards act = action as AgentActionMoveTowards; act.mDirection.y = 0; this.mLocomotion.Move(act.mDirection); return true; } return base.HandleAction(action); }
public override void DoAction(AgentAction action) { if (null != this.mCurrentState && this.mCurrentState.HandleAction(action)) { } else { if (action is AgentActionIdle) this.mNextState = mAnimStates[(int)StateType.Idle]; else if (action is AgentActionDie) this.mNextState = mAnimStates[(int)StateType.Die]; else if (action is AgentActionGoTo) this.mNextState = mAnimStates[(int)StateType.Walk]; else if (action is AgentActionMoveTowards) this.mNextState = mAnimStates[(int)StateType.Walk]; else if (action is AgentActionJumpTo) this.mNextState = mAnimStates[(int)StateType.Jump]; else if (action is AgentActionAttack) this.mNextState = mAnimStates[(int)StateType.Attack]; ProgressToNextState(action); } }
public override void OnActivate(AgentAction action) { base.OnActivate(action); }
public virtual void OnActivate(AgentAction _action) { SetFinished(false); Initialize(_action); }
public static void Run() { var regex = new Regex("streaming:\\[.*?\\]", RegexOptions.Singleline); using (var db = new MarketContext()) { using (var connection = db.GetConnection()) { connection.Open(); var tickers = db.GetMarketplaceTickers(connection); const string financeUrl = "https://www.google.com/finance?q={0}"; var session = new AgentSession(); var count = 0; foreach (var ticker in tickers) { var transaction = connection.BeginTransaction(); try { Console.Write($"{++count} of {tickers.Count}: {ticker} - "); var url = string.Format(financeUrl, ticker.Replace(":", "%3A")); var action = new AgentAction(url, false); var document = AgentHandler.Instance.PerformAction(session, action); var match = regex.Match(document.ResponseString); if (!match.Success) { Console.WriteLine("No relations!"); continue; } var json = "{" + match + "}"; var relatedItems = ((JObject)JsonConvert.DeserializeObject(json)).First?.First?.Children().AsJEnumerable() .ToList(); if (relatedItems == null) { Console.WriteLine("\nERROR!"); continue; } foreach (var relatedItem in relatedItems) { var values = relatedItem.Children().Select(x => (JProperty)x).ToDictionary(x => x.Name); var relatedTicker = values["s"].Value; var relatedExchange = values["e"].Value; if (ticker.EndsWith($":{relatedTicker}")) { continue; } Console.Write($"{relatedTicker} "); if (tickers.Contains($"{relatedExchange}:{relatedTicker}")) { db.AddRelationship(ticker, $"{relatedExchange}:{relatedTicker}", connection); continue; } var probableTicker = tickers.FirstOrDefault(x => x.EndsWith($":{relatedTicker}")); if (probableTicker != null) { db.AddRelationship(ticker, probableTicker, connection); Console.Write($"({probableTicker}) "); } else { Console.Write("! "); } } Console.WriteLine(); } finally { transaction.Commit(); } } } } Console.WriteLine("Done."); Console.ReadLine(); }
public override bool HandleAction(AgentAction action) { if (action is AgentActionTriggerSkill) { //... } return base.HandleAction(action); }
public AgentCommand(AgentAction action, ITangible target, int priority) { Action = action; Target = target; Priority = priority; }
public void ResponseForNotEnoughFreeSpaceRequest(DisplayType displayType, AgentAction agentAction) { _showPreparator.ResponseForNotEnoughFreeSpaceRequest(displayType, agentAction); }
public void PushAction(AgentAction act) { blackboard.PushAction(act); }
public Test(int[] inputs, AgentAction expectedAction, double scores) { Inputs = inputs; ExpectedAction = expectedAction; Scores = scores; }
public abstract void DoAction(AgentAction action);
protected override void OnExit() { mCurrentAction = null; }
void HandleAction(AgentAction action) { if (action is AgentActionAttack) { if (Owner.IsOwner) { Owner.NetworkView.RPC("AttackS", uLink.RPCMode.Server, (action as AgentActionAttack).FromPos, (action as AgentActionAttack).AttackDir); } } else if (action is AgentActionInjury) { var injury = action as AgentActionInjury; if (Owner.IsServer) { uLink.NetworkViewID viewId = (injury.Attacker != null && injury.Attacker.NetworkView != null) ? injury.Attacker.NetworkView.viewID : uLink.NetworkViewID.unassigned; Owner.NetworkView.RPC("Injury", RPCMode.Others, viewId, injury.Pos, injury.Impulse, (short)injury.Damage, (short)injury.BodyPart); } } else if (action is AgentActionReload) { if (Owner.IsOwner) { Owner.NetworkView.RPC("Reload", uLink.RPCMode.Server); } } else if (action is AgentActionTeamCommand) { AgentActionTeamCommand a = action as AgentActionTeamCommand; if (Owner.IsOwner) { Owner.NetworkView.RPC("TeamCmd", RPCMode.Server, a.Command); } } else if (action is AgentActionRoll) { if (Owner.IsOwner) { Owner.NetworkView.RPC("Roll", uLink.RPCMode.Server, (action as AgentActionRoll).Direction); } } else if (action is AgentActionDeath) { var death = action as AgentActionDeath; if (Owner.IsServer) { uLink.NetworkViewID viewId = (death.Attacker != null && death.Attacker.NetworkView != null) ? death.Attacker.NetworkView.viewID : uLink.NetworkViewID.unassigned; Owner.NetworkView.RPC("Death", RPCMode.Others, viewId, death.Pos, death.Impulse, (short)death.Damage, (short)death.BodyPart); if (null != death.Attacker) { PPIManager.Instance.ServerAddScoreForKill(Owner.NetworkView.owner, death.Attacker.NetworkView.owner, Owner.BlackBoard.AttackersDamageData, death.BodyPart, Owner.GadgetsComponent.GetBoostGoldReward()); } /*if (Server.Instance.GameInfo.GameType == E_MPGameType.ZoneControl) * { * // currently not using rebalancing after death * //PPIManager.Instance.ServerRebalanceTeams(); * }*/ } } else if (action is AgentActionCoverEnter) { if (Owner.IsOwner) { Owner.NetworkView.RPC("CoverEnter", uLink.RPCMode.Server, Mission.Instance.GameZone.GetCoverIndex(Owner.BlackBoard.Cover), Owner.BlackBoard.Desires.CoverPosition); } } else if (action is AgentActionCoverLeave) { if (Owner.IsOwner) { Owner.NetworkView.RPC("CoverLeave", uLink.RPCMode.Server, ((AgentActionCoverLeave)action).TypeOfLeave); } } else if (action is AgentActionCoverFire) { if (Owner.IsOwner) { AgentActionCoverFire a = action as AgentActionCoverFire; Owner.NetworkView.RPC("CoverFireStart", uLink.RPCMode.Server, a.CoverPose, a.CoverDirection); } } else if (action is AgentActionCoverFireCancel) { if (Owner.IsOwner) { Owner.NetworkView.RPC("CoverFireStop", uLink.RPCMode.Server); } } else if (action is AgentActionWeaponChange) { if (Owner.IsOwner) { Owner.NetworkView.RPC("ChangeWeapon", uLink.RPCMode.Server, (action as AgentActionWeaponChange).NewWeapon); } } else if (action is AgentActionUseItem) { // Debug.Log ("ComponentNetworkAction.HandleAction(), time=" + Time.timeSinceLevelLoad + ", BlackBoard.KeepMotion=" + Owner.BlackBoard.KeepMotion + ", Owner.IsOwner=" + Owner.IsOwner); if (Owner.IsOwner) { if (Owner.IsInCover) { Owner.NetworkView.RPC("UseItemInCover", uLink.RPCMode.Server, Owner.BlackBoard.Desires.Gadget, Owner.BlackBoard.CoverPose, Owner.BlackBoard.CoverPosition); } else { Owner.NetworkView.RPC("UseItem", uLink.RPCMode.Server, Owner.BlackBoard.Desires.Gadget, Owner.BlackBoard.KeepMotion); } } } else if (action is AgentActionMelee) { if (Owner.IsOwner) { AgentActionMelee a = action as AgentActionMelee; uLink.NetworkViewID viewId = (a.Target != null && a.Target.NetworkView != null) ? a.Target.NetworkView.viewID : uLink.NetworkViewID.unassigned; Owner.NetworkView.RPC("Melee", uLink.RPCMode.Server, a.MeleeType, viewId); } } else if (action is AgentActionKnockdown) { if (Owner.IsServer) { AgentActionKnockdown a = action as AgentActionKnockdown; uLink.NetworkViewID viewId = (a.Attacker != null && a.Attacker.NetworkView != null) ? a.Attacker.NetworkView.viewID : uLink.NetworkViewID.unassigned; Owner.NetworkView.RPC("Knockdown", uLink.RPCMode.Others, a.MeleeType, viewId, a.Direction); } } }
public void HandleAction(AgentAction a) { Owner.BlackBoard.UpdateCombatSetting(a); }
public override bool HandleNewAction(AgentAction action) { //if (m_Human.PlayerProperty != null) //if(Owner.debugAnims) Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " - action " + action.ToString()); if (action is AgentActionIdle) { action.SetFailed(); return(true); } else if (action is AgentActionAttack) { if (null != Owner.AnimSet) { string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Fire); if (null != s) { AnimationState state = Animation[s]; if (null != state) { TimeToFinishWeaponAction = Time.timeSinceLevelLoad + state.length * 0.5f; state.layer = 2; state.blendMode = AnimationBlendMode.Additive; if (Animation.IsPlaying(s)) { //Debug.Log(Time.timeSinceLevelLoad + " " + s + " rewind " + Animation[s].length + " " + Animation[s].time); state.time = 0; } else { //Debug.Log(Time.timeSinceLevelLoad + " " + s + " fade " + Animation[s].length + " " + Animation[s].time); Blend(s, 0.05f); } } } } if (WeaponAction != null) { WeaponAction.SetSuccess(); } WeaponAction = action; return(true); } else if (action is AgentActionInjury) { PlayInjuryAnimation(action as AgentActionInjury); return(true); } else if (action is AgentActionReload) { if (null != Owner.AnimSet) { string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Reload); if (null != s) { AnimationState state = Animation[s]; if (null != state) { state.layer = 2; state.blendMode = AnimationBlendMode.Blend; Blend(s, 0.2f); TimeToFinishWeaponAction = Time.timeSinceLevelLoad + state.length - 0.3f; } } action.SetSuccess(); WeaponAction = action; // PrevBlendUp *= 0.25f; //this is to minimize the quick blend to aim after reload // PrevBlendDown *= 0.25f; } return(true); } else if (action is AgentActionRotate) { RotateAction = action as AgentActionRotate; if (null != Owner.AnimSet) { string s = Owner.AnimSet.GetRotateAnim(RotateAction.Rotation); if (s != null && Animation.IsPlaying(s) == false) { /* if ( Animation[s] == null ) * { * Debug.Log ("Animation.Length=" + Animation.GetClipCount() + ", agent=" + Owner.name); * * foreach ( AnimationClip clip in Animation ) * Debug.Log ("clip=" + clip.name ); * } */ AnimationState state = Animation[s]; if (null != state) { state.blendMode = AnimationBlendMode.Additive; state.layer = 1; TimeToFinishRotateAction = Time.timeSinceLevelLoad + state.length + 0.3f; Blend(s, 0.1f); } } } } return(false); }
public void AddAction(AgentAction agentAction) { _agentActions.Enqueue(agentAction); }
public ActionResult Update(GameEngine engine, AgentAction action) { return(engine.DoAction(action)); }
override public void OnActivate(AgentAction action) { // Time.timeScale = 0.1f; base.OnActivate(action); }
public MemoryAgent(string name, int numTimePeriods, int numAgents, int health, int agentID) : base(name, numTimePeriods, numAgents, health, agentID) { lastAct = AgentAction.TRUST; // initially trust }
protected abstract void OnEnter(AgentAction action);
protected override void Initialize(AgentAction action) { base.Initialize(action); Action = action as AgentActionCoverLeave; StartPosition = Transform.position; string AnimName; //Debug.Log(Time.realtimeSinceStartup + " init"); RotationOK = true; switch (Action.TypeOfLeave) { case AgentActionCoverLeave.E_Type.Right: case AgentActionCoverLeave.E_Type.Left: float multiplierHelper = 1; if (Action.TypeOfLeave == AgentActionCoverLeave.E_Type.Right) { AnimName = Owner.AnimSet.GetCoverAnim(AnimSet.E_CoverAnim.LeaveRight, Owner.BlackBoard.CoverPose, E_CoverDirection.Right); } else { multiplierHelper = -1; AnimName = Owner.AnimSet.GetCoverAnim(AnimSet.E_CoverAnim.LeaveLeft, Owner.BlackBoard.CoverPose, E_CoverDirection.Left); } //FinalPosition = Owner.Position + Owner.Right * 1.5f * multiplierHelper + Owner.Forward * 1.3f; //FinalPosition = BuildSafeFinalPositionForLeavingCover( Owner.Position + Owner.Right * 1.5f * multiplierHelper + Owner.Forward * 1.1f ); FinalPosition = BuildSafeFinalPositionForLeavingCover(Action.TypeOfLeave, Owner.Position, Owner.Right, Owner.Forward); StartPositionHelper = StartPosition - Owner.Right * multiplierHelper; FinalPositionHelper = FinalPosition + Owner.Forward; CurrentMoveTime = 0f; Animation[AnimName].speed = 1f; MoveTime = 0.3f; EndOfStateTime = 0.3f + Time.timeSinceLevelLoad; Owner.BlackBoard.Speed = 5; break; case AgentActionCoverLeave.E_Type.Jump: AnimName = Owner.AnimSet.GetCoverAnim(AnimSet.E_CoverAnim.JumpOver, Owner.BlackBoard.CoverPose, E_CoverDirection.Middle); //FinalPosition = Owner.Position + Owner.Forward * 2.0f; //FinalPosition = BuildSafeFinalPositionForLeavingCover( Owner.Position + Owner.Forward * 2.0f ); // prevents to fall through the scene in case we are jumping 'uphill' FinalPosition = BuildSafeFinalPositionForLeavingCover(Action.TypeOfLeave, Owner.Position, Owner.Right, Owner.Forward); CurrentMoveTime = -0.2f; Animation[AnimName].speed = 1.3f; MoveTime = 0.4f; EndOfStateTime = 0.9f + Time.timeSinceLevelLoad; Owner.BlackBoard.Speed = 5; break; case AgentActionCoverLeave.E_Type.JumpUp: AnimName = Owner.AnimSet.GetCoverAnim(AnimSet.E_CoverAnim.JumpUp, Owner.BlackBoard.CoverPose, E_CoverDirection.Middle); //FinalPosition = Owner.Position + Vector3.up * 1.4f + Owner.Forward * 0.65f; FinalPosition = BuildSafeFinalPositionForLeavingCover(Action.TypeOfLeave, Owner.Position, Owner.Right, Owner.Forward); CurrentMoveTime = 0.0f; Animation[AnimName].speed = 1.4f; MoveTime = Animation[AnimName].length * 0.8f / Animation[AnimName].speed; EndOfStateTime = Animation[AnimName].length / Animation[AnimName].speed * 0.8f + Time.timeSinceLevelLoad; Owner.BlackBoard.Speed = 5; break; case AgentActionCoverLeave.E_Type.Back: AnimName = Owner.AnimSet.GetCoverAnim(AnimSet.E_CoverAnim.Leave, Owner.BlackBoard.CoverPose, E_CoverDirection.Middle); //FinalPosition = Owner.Position - Owner.BlackBoard.Cover.Forward * 1.1f; //FinalPosition = BuildSafeFinalPositionForLeavingCover( Owner.Position - Owner.BlackBoard.Cover.Forward * 1.1f ); FinalPosition = BuildSafeFinalPositionForLeavingCover(Action.TypeOfLeave, Owner.Position, Owner.Right, -Owner.BlackBoard.Cover.Forward); StartRotation = Owner.Transform.rotation; FinalRotation.eulerAngles = new Vector3(0, Owner.BlackBoard.Desires.Rotation.eulerAngles.y, 0); Animation[AnimName].speed = 1.2f; MoveTime = 0.1f; CurrentMoveTime = -0.1f; EndOfStateTime = 0.15f + Time.timeSinceLevelLoad; // RotationOK = false; //ComponentBody will take care about the rotation... When this is enabled it causes a rotation glitch. break; default: AnimName = ""; Debug.LogWarning("Unsupported type of cover leaving : Action.TypeOfLeave"); break; } // Debug.Log ("AnimStateCoverLeave, AnimName=" + AnimName + ", time=" + Time.timeSinceLevelLoad); CrossFade(AnimName, 0.15f, PlayMode.StopSameLayer); Owner.SetDominantAnimName(AnimName); Owner.WeaponComponent.DisableCurrentWeapon(Animation[AnimName].length); PositionOK = false; Owner.BlackBoard.MotionType = E_MotionType.None; //change FOV to the weapon/default value if (uLink.Network.isClient && Owner.NetworkView.isMine) { float newFOV = GameCamera.Instance.DefaultFOV; GameCamera.Instance.SetFov(newFOV, 200); } }
protected override void OnEnter(AgentAction action) { this.mLocomotion.StopMove(); }
/// <summary> /// Calculates the entry orders and stop-loss price. /// </summary> /// <param name="pair">The Forex pair Symbol.</param> /// <param name="action">The order direction.</param> /// <returns>a Tuple with the quantity as Item1 and the stop-loss price as Item2. If quantity is zero, then means that no trade must be done.</returns> public Tuple <int, decimal, decimal> CalculateEntryOrders(QuoteBars data, Symbol pair, AgentAction action) { // If exposure is greater than the max exposure, then return zero. if (_portfolio.TotalMarginUsed > _portfolio.TotalPortfolioValue * _maxExposure) { return(Tuple.Create(0, 0m, 0m)); } var closePrice = _portfolio.Securities[pair].Price; var leverage = _portfolio.Securities[pair].Leverage; var exchangeRate = _portfolio.Securities[pair].QuoteCurrency.ConversionRate; var volatility = _portfolio.Securities[pair].VolatilityModel.Volatility; // Estimate the maximum entry order quantity given the risk per trade. var moneyAtRisk = _portfolio.TotalPortfolioValue * _riskPerTrade; var quantity = action == AgentAction.GoLong ? _lotSize : -_lotSize; if ((volatility * exchangeRate) > 0) { var maxQuantitybyRisk = moneyAtRisk / (volatility * exchangeRate); // Estimate the maximum entry order quantity given the exposure per trade. var maxBuySize = Math.Min(_portfolio.MarginRemaining, _portfolio.TotalPortfolioValue * _maxExposurePerTrade) * leverage; var maxQuantitybyExposure = maxBuySize / (closePrice * exchangeRate); // The final quantity is the lowest of both. quantity = (int)(Math.Round(Math.Min(maxQuantitybyRisk, maxQuantitybyExposure) / _lotSize, 0) * _lotSize); // If the final quantity is lower than the minimum quantity of the given lot size, then return zero. if (quantity < _lotSize * _minQuantity) { return(Tuple.Create(0, 0m, 0m)); } quantity = action == AgentAction.GoLong ? quantity : -quantity; } var stopLossPrice = closePrice + (action == AgentAction.GoLong ? -volatility : volatility); var increment = _portfolio.Securities[pair].PriceVariationModel.GetMinimumPriceVariation(_portfolio.Securities[pair]); if (increment != 0) { stopLossPrice = Math.Round(stopLossPrice / increment) * increment; } return(Tuple.Create(quantity, stopLossPrice, action == AgentAction.GoLong ? data[pair].Ask.Close : data[pair].Bid.Close)); }
protected virtual void Initialize(AgentAction _action) { }
override public void OnActivate(AgentAction action) { /*if(Owner.IsPlayer == false) * Time.timeScale = 0.2f;*/ base.OnActivate(action); }
public virtual bool HandleNewAction(AgentAction _action) { return(false); }
override public void OnActivate(AgentAction action) { // Time.timeScale = 0.1f; base.OnActivate(action); PlayAnim(GetMotionType()); }
public override bool HandleNewAction(AgentAction action) { return(false); }
public override void OnActivate(AgentAction _action) { base.OnActivate(_action); //todo: play Animation... PlayAnim(GetMotionType()); }
public override bool HandleAction(AgentAction action) { // to do return base.HandleAction(action); }
private void Awake() { currentAction = new ActionMove(transform.position, new Vector2Int(0, 0), baseMvt, new InteractorSimulated()); lastSimulation = delayBetweenSimulations; }
public virtual bool HandleAction(AgentAction action) { return false; }
protected override void OnEnter(AgentAction action) { }
/// <summary> /// 激活这个状态 /// </summary> public virtual void OnActivate(AgentAction _action) { }
override protected void Initialize(AgentAction action) { base.Initialize(action); SetFinished(false); State = E_State.E_PREPARING; Owner.BlackBoard.MotionType = E_MotionType.Attack; Action = action as AgentActionAttack; Action.AttackPhaseDone = false; Action.Hit = false; if (Action.Data == null) { Action.Data = Owner.AnimSet.GetFirstAttackAnim(Owner.BlackBoard.WeaponSelected, Action.AttackType); } AnimAttackData = Action.Data; if (AnimAttackData == null) { Debug.LogError("AnimAttackData == null"); } StartRotation = Transform.rotation; StartPosition = Transform.position; float angle = 0; bool backstab = false; float distance = 0; if (Action.Target != null) { Vector3 dir = Action.Target.Position - Transform.position; distance = dir.magnitude; if (distance > 0.1f) { dir.Normalize(); angle = Vector3.Angle(Transform.forward, dir); //attacker uhel k cili je mensi nez 40 and uhel enemace a utocnika je mensi nez 80 stupnu if (angle < 40 && Vector3.Angle(Owner.Forward, Action.Target.Forward) < 80) { backstab = true; } } else { dir = Transform.forward; } FinalRotation.SetLookRotation(dir); if (distance < Owner.BlackBoard.WeaponRange) { FinalPosition = StartPosition; } else { FinalPosition = Action.Target.Transform.position - dir * Owner.BlackBoard.WeaponRange; } MoveTime = (FinalPosition - StartPosition).magnitude / 20.0f; RotationTime = angle / 720.0f; } else { FinalRotation.SetLookRotation(Action.AttackDir); RotationTime = Vector3.Angle(Transform.forward, Action.AttackDir) / 720.0f; MoveTime = 0; } RotationOk = RotationTime == 0; PositionOK = MoveTime == 0; CurrentRotationTime = 0; CurrentMoveTime = 0; if (Owner.IsPlayer && AnimAttackData.HitCriticalType != E_CriticalHitType.None && Action.Target && Action.Target.BlackBoard.CriticalAllowed && Action.Target.IsBlocking == false && Action.Target.IsInvulnerable == false && Action.Target.IsKnockedDown == false) { if (backstab) { Critical = true; } else { // Debug.Log("critical chance" + Owner.GetCriticalChance() * AnimAttackData.CriticalModificator * Action.Target.BlackBoard.CriticalHitModifier); Critical = Random.Range(0, 100) < Owner.GetCriticalChance() * AnimAttackData.CriticalModificator * Action.Target.BlackBoard.CriticalHitModifier; } } else { Critical = false; } Knockdown = AnimAttackData.HitAreaKnockdown && Random.Range(0, 100) < 60 * Owner.GetCriticalChance(); }
public override void Enter(AgentAction action) { base.Enter(action); _animName = null; PlayAnim(_agentActionGoTo.motionType); }
public GraphNode(Room room, GraphNode parent, AgentAction action) { this.room = room; this.parent = parent; this.action = action; }
private static void SavePage(string raptureURL) { AgentAction action = new AgentAction(raptureURL, false); AgentDocument document = null; int errorCount = 0; while (errorCount < 5) { try { document = AgentHandler.Instance.PerformAction(new AgentSession(), action); break; } catch (Exception ex) { errorCount++; } } int startIdx = document.ResponseString.IndexOf("Rapture Index ") + "Rapture Index ".Length; int endIdx = document.ResponseString.IndexOf("<", startIdx); int raptureIdx = int.Parse(document.ResponseString.Substring(startIdx, endIdx - startIdx)); startIdx = document.ResponseString.IndexOf("Updated ") + "Updated ".Length; endIdx = document.ResponseString.IndexOf("<", startIdx); string dateString = document.ResponseString.Substring(startIdx, endIdx - startIdx); dateString = dateString.Replace("Sept", "Sep"); DateTime raptureDate = (DateTime) new DateTimeConverter().ConvertFrom(dateString); if (!DB.RaptureIndexes.Where(x => x.rapture_day.Equals(raptureDate)).Any()) { int oil = GetRaptureAmount(document.ResponseString, "Oil Supply", dateString); int debt = GetRaptureAmount(document.ResponseString, "Debt and Trade", dateString); int weather = GetRaptureAmount(document.ResponseString, "Wild Weather", dateString); int globalism = GetRaptureAmount(document.ResponseString, "Globalism", dateString); int economy = GetRaptureAmount(document.ResponseString, "Economy", dateString); Console.WriteLine("Rapture on " + raptureDate.ToString("d") + " was " + raptureIdx + " - oil: " + oil + ", debt: " + debt + ", weather: " + weather + ", globalism: " + globalism + ", economy: " + economy); RaptureIndex rapture = new RaptureIndex { rapture_day = raptureDate, rapture_index = raptureIdx, oil = oil, debt = debt, weather = weather, globalism = globalism, economy = economy }; DB.AddToRaptureIndexes(rapture); DB.SaveChanges(); } else { Console.WriteLine("Rapture already happened on " + raptureDate.ToString("d")); } }
public static void PullQuotes(DateTime start, DateTime stop, string stockName) { ModelMadness madness = new ModelMadness(); StockName stock = (from q in madness.StockNames where q.Stock == stockName select q).First(); Console.WriteLine("Working on " + stock.Stock); //http://ichart.finance.yahoo.com/table.csv?s=TKR&a=00&b=1&c=2000&d=01&e=18&f=2010&g=d&ignore=.csv string url = @"http://ichart.finance.yahoo.com/table.csv?s=" + stock.Stock + "&a=" + TwoDig(start.Month - 1) + "&b=" + start.Day + "&c=" + start.Year + "&d=" + TwoDig(stop.Month - 1) + "&e=" + stop.Day + "&f=" + stop.Year + "&g=d&ignore=.csv"; AgentSession session = new AgentSession(); AgentAction action = new AgentAction(url, false); bool found = false; AgentDocument document = null; try { document = AgentHandler.Instance.PerformAction(session, action); found = true; } catch (Exception ex) { Console.WriteLine("ERROR: " + url + " - " + ex.Message); } if (!found) { return; } //Date,Open,High,Low,Close,Volume,Adj Close string[] rows = document.ResponseString.Split('\n'); if (rows.Length < 2) { return; } for (int i = 1; i < rows.Length; i++) { string row = rows[i]; string[] fields = row.Split(','); if (fields.Length < 7) { Console.WriteLine((i - 2) + " records stored"); continue; } quote q = new quote { day = (DateTime) new DateTimeConverter().ConvertFrom(fields[0]), open = decimal.Parse(fields[1]), high = decimal.Parse(fields[2]), low = decimal.Parse(fields[3]), close = decimal.Parse(fields[4]), volume = long.Parse(fields[5]), adjusted_close = decimal.Parse(fields[6]), StockName = stock }; madness.AddToquotes(q); } madness.SaveChanges(); }
public override void OnActionReceived(float[] vectorAction) { var cellPosition = _map.CellPosition(_player.transform.position); bool hasChangedCell = !_currentCell.Equals(cellPosition); // Reward for new visited cells //if (hasChangedCell && !_visitedCells.Contains(cellPosition)) //{ // CustomAddReward(0.01f); // _visitedCells.Add(cellPosition); //} // Check danger var dangerLevel = _map.GetDangerLevel(cellPosition); if (dangerLevel > 0) { var rewardValue = -((dangerLevel / 3f) * 0.005f); //Debug.Log($"DANGER: {rewardValue}"); CustomAddReward(rewardValue); } else if (dangerLevel == 0) { //CustomAddReward(0.001f); } var movement = Vector2Int.zero; var action = (AgentAction)Mathf.FloorToInt(vectorAction[0]); //Debug.Log($"Action: {action}"); // Malus if no action //if (action == AgentAction.Nothing && _player.BombCount == _player.MaxBombCount) //{ // CustomAddReward(-0.01f); //} // I don't like lazy agents //CustomAddReward(-0.01f); if (_previousAction != action) { _actionsHistory.Add(action); } _previousAction = action; _previousPosition = transform.position; _currentCell = cellPosition; switch (action) { case AgentAction.Nothing: // Do nothing break; case AgentAction.Right: movement.x = 1; break; case AgentAction.Left: movement.x = -1; break; case AgentAction.Up: movement.y = 1; break; case AgentAction.Down: movement.y = -1; break; case AgentAction.Bomb: _playerMovement.PlantBomb(); break; default: throw new ArgumentException("Invalid action value"); } //if (hasChangedCell) //{ // Debug.Log($"Changed cell => Current cell position: {_currentCell}"); // Debug.Log($"Changed cell => Current position: {transform.position}"); //} if (!_isMoving && movement != Vector2Int.zero) { Vector2Int targetCell = cellPosition + movement; if (_map.IsAccessible(targetCell, true, false)) { _targetPosition = _map.WorldPosition(targetCell); _isMoving = true; //Debug.Log($"Current cell position: {_currentCell}"); //Debug.Log($"Current position: {transform.position}"); //Debug.Log($"Target cell position: {targetCell}"); //Debug.Log($"Target position: {_targetPosition}"); } else { Debug.LogError($"Target cell is not accessible: {targetCell.ToString()}"); } } _playerMovement.Move(movement); }
public override void Enter(AgentAction action) { base.Enter(action); Owner.BlackBoard.invulnerable = true; //Effect = null; }
protected virtual void DoAction(AgentAction action) { }
internal void MakeDecision() { // Вычисление в сети for (int outIndex = 0; outIndex < MaxOutputs; outIndex++) { // Инициализация входной ячейки сложением Outputs[outIndex] = BiasO[outIndex]; // Перемножаем значения на входе выходной ячейки на соответствующие веса for (int inIndex = 0; inIndex < MaxInputs; inIndex++) { Outputs[outIndex] += Inputs[inIndex]*WeightOI[outIndex*MaxInputs + inIndex]; } } var largest = Int32.MinValue; var winnerOutput = Int32.MinValue; // Выбор ячейки с максимальным значением (победитель получает все) for (int outIndex = 0; outIndex < MaxOutputs; outIndex++) { if (Outputs[outIndex] >= largest) { largest = Outputs[outIndex]; winnerOutput = outIndex; } } Action = (AgentAction)winnerOutput; }
public void Enter(AgentAction action) { this.SetFinished(false); mAgent.followHud.OnEnterState(this.GetType().FullName); this.OnEnter(action); }