} // 等额本息法 public static List <Bt> DEBJ(double amount, double yearRate, int months, double lx) { /// <summary> /// 等额本金法 /// </summary> /// <param name="amountT">投资金额</param> /// <param name="yearRate">年利率</param> /// <param name="monthsx">投资期限,单位:月</param> /// <returns></returns> /// var MEIYUEHUAN = amount / months; //每月归还本金 var monthRate = yearRate; //年利率转为月利率 var datalist = new List <Bt>(); var i = 0; var b = 0.0; // 偿还利息 var c = amount / months; // 偿还本金 //利息收益 for (i = 1; i <= months; i++) { b = amount * yearRate * lx; b = Math.Round(b * 100) / 100; c = Math.Round(c * 100) / 100; var unit = new Bt(); unit.QS = i; // 期数 unit.SY = b; // 偿还利息 unit.BJ = c; // 偿还本金 datalist.Add(unit); amount = amount - MEIYUEHUAN; } return(datalist); } // 等额本金法
public static void Fill(Bt[] src, Bt init) { for (int i = 0; i < src.Length; ++i) { src[i] = init; } }
} // 一次性还本付息 public static List <Bt> XXHB(double amount, double yearRate, int months, double lx) { /// <summary> /// 按月付息到期还本 /// </summary> /// <param name="amount">投资金额</param> /// <param name="yearRate">年利率</param> /// <param name="months">投资期限,单位:月</param> /// <returns></returns> var datalist = new List <Bt>(); //new Array(Deadline); // double rateIncome = amount * yearRate * months; double rateIncomeEve = (rateIncome / months); var total = amount + rateIncome; for (var i = 1; i < months; i++) { var unit = new Bt(); unit.QS = i; // 期数 unit.SY = Math.Round(rateIncomeEve * 100 * lx) / 100; // 偿还利息 unit.BJ = 0; // 偿还本金 datalist.Add(unit); } datalist.Add(new Bt() { QS = months, SY = Math.Round(rateIncomeEve * 100 * lx) / 100, BJ = amount, }); return(datalist); } // 先息后本
public void Test_BitTools_get_setLongValue() { const int nBits = 32; const int nTests = 10000; Random rnd = new Random((int)DateTime.Now.Ticks); Bt[] a = new Bt[nBits]; int nNegativeNumbers = 0; int nPositiveNumbers = 0; for (int k = 0; k < nTests; ++k) { long aValue = RandLong(nBits, rnd); if (aValue > 0) { nPositiveNumbers++; } else { nNegativeNumbers++; } BitTools.SetLongValue(ref a, aValue); Assert.AreEqual(aValue, BitTools.GetLongValue(a), "test " + k + "/" + nTests); } Assert.IsTrue(nPositiveNumbers > 0, "nPositiveNumbers=" + nPositiveNumbers); Assert.IsTrue(nNegativeNumbers > 0, "nNegativeNumbers=" + nNegativeNumbers); }
//------------------------------------------------------------------------- void _onPropBtNameChanged(IProp prop, object param) { string bt_name = Def.mPropBtName.get(); if (!string.IsNullOrEmpty(bt_name)) { Bt = CellApp.Instance.createBt(bt_name, Entity); } }
//------------------------------------------------------------------------- public override void release() { if (Bt != null) { Bt.close(); Bt = null; } CoActorMirror = null; ActorAiConfig = null; }
/// <summary> /// Make BT[64] array from ulong d (data) and ulong du (data UNDEFINED) If bit is 0 in du, then the truth-value is UNDEFINED. /// </summary> /// <param name="d">DATA</param> /// <param name="du">Data UNDEFINED. if bit is 0 then the truth-value is UNDEFINED</param> /// <returns></returns> public static Bt[] ToBtArray(ulong d, ulong du) { Bt[] a = new Bt[64]; ulong mask = 1; for (int i = 0; i < 64; ++i) { a[i] = ((du & mask) == 0) ? Bt.UNDEFINED : (((d & mask) == 0) ? Bt.ZERO : Bt.ONE); mask <<= 1; } return(a); }
private void CircularcalcBtn_Click(object sender, EventArgs e) { double HCRT, Bt, HLC, WCF, BLT; if (Discanalrecttextbox.Text == "" || averageyradTextBox1.Text == "" || rblradTextBox2.Text == "" || cflradTextBox3.Text == "" || calradTextBox4.Text == "" || slopradTextBox5.Text == "" || BtmwdthradTextBox7.Text == "" || SIradTextBox1.Text == "" || LIradTextBox1.Text == "") { MessageBox.Show("please fill the filled corectly", "message", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } else { QC = Convert.ToDouble(Discanalrecttextbox.Text); Y1 = Convert.ToDouble(averageyradTextBox1.Text); RBL = Convert.ToDouble(rblradTextBox2.Text); CFL = Convert.ToDouble(cflradTextBox3.Text); CAL = Convert.ToDouble(calradTextBox4.Text); S = Convert.ToDouble(slopradTextBox5.Text); b = Convert.ToDouble(BtmwdthradTextBox7.Text); LI = Convert.ToDouble(LIradTextBox1.Text); SI = Convert.ToDouble(SIradTextBox1.Text); } HCRT = (double)0.9 * Y1; Bt = QC / ((double)1.61 * (Math.Sqrt(Math.Pow(HCRT, 3)))); HLC = CAL * S; HLI = LI * SI; if (CanaltypecomboBox1.Text == "Trapezoidal") { WDC = (double)0.8673 * b; } else if (CanaltypecomboBox1.Text == "Rectangular") { WDC = (double)b / 2; } WCF = CFL + HLI + HLC + WDC; BLT = WCF - HCRT; if (BLT < RBL) { bwtradTextBox8.Text = Math.Round(Bt, 2).ToString(); bltradTextBox9.Text = Math.Round(RBL, 2).ToString(); } else { bwtradTextBox8.Text = Bt.ToString(); bltradTextBox9.Text = BLT.ToString(); } radButton1.Visible = true; }
} // 先息后本 public static List <Bt> DEBX(double amount, double yearRate, int months, double lx) { /// <summary> /// 等额本息法 /// </summary> /// <param name="amountT">投资金额</param> /// <param name="yearRate">年利率</param> /// <param name="monthsx">投资期限,单位:月</param> /// <returns></returns> var monthRate = (yearRate); //年利率转为月利率 var datalist = new List <Bt>(); var i = 0; var a = 0.0; // 偿还本息 var b = 0.0; // 偿还利息 var c = 0.0; // 偿还本金 //利息收益 var totalRateIncome = (amount * months * monthRate * Math.Pow((1 + monthRate), months)) / (Math.Pow((1 + monthRate), months) - 1) - amount; var totalIncome = totalRateIncome + amount; var d = amount + totalRateIncome; // 剩余本金 totalRateIncome = Math.Round(totalRateIncome * 100) / 100; // 支付总利息 totalIncome = Math.Round(totalIncome * 100) / 100; a = totalIncome / months; //每月还款本息 a = Math.Round(a * 100) / 100; //每月还款本息 for (i = 1; i <= months; i++) { b = (amount * monthRate * (Math.Pow((1 + monthRate), months) - Math.Pow((1 + monthRate), (i - 1)))) / (Math.Pow((1 + monthRate), months) - 1); b = Math.Round(b * 100 * lx) / 100; c = a - b; c = Math.Round(c * 100) / 100; d = d - a; d = Math.Round(d * 100) / 100; if (i == months) { c = c + d; b = b - d; c = Math.Round(c * 100) / 100; b = Math.Round(b * 100 * lx) / 100; d = 0; } var unit = new Bt(); unit.QS = i; // 期数 unit.SY = b; // 偿还利息 unit.BJ = c; // 偿还本金 datalist.Add(unit); } return(datalist); } // 等额本息法
public static char BitToChar(Bt bit) { switch (bit) { case Bt.ZERO: return('0'); case Bt.ONE: return('1'); case Bt.UNDEFINED: return('U'); case Bt.KNOWN: return('K'); default: return('?'); } }
public void Test_BitTools_get_setUlongValue() { const int nBits = 16; const int nTests = 10000; Random rnd = new Random((int)DateTime.Now.Ticks); Bt[] a = new Bt[nBits]; for (int k = 0; k < nTests; ++k) { ulong aValue = RandUlong(nBits, rnd); BitTools.SetUlongValue(ref a, aValue); Assert.AreEqual(aValue, BitTools.GetUlongValue(a), "test " + k + "/" + nTests); } }
protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response) { EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0)); StringBuilder ListBuilder = new StringBuilder(); ListBuilder.Append("Here are the following enums you can use in commands:\n\nBreakType: "); foreach (BreakType Bt in Enum.GetValues(typeof(BreakType))) { ListBuilder.Append(Bt.ToString()); ListBuilder.Append(" "); } ListBuilder.AppendLine(); ListBuilder.Append("MoveType: "); foreach (MoveType Mt in Enum.GetValues(typeof(MoveType))) { ListBuilder.Append(Mt.ToString()); ListBuilder.Append(" "); } ListBuilder.AppendLine(); ListBuilder.Append("GrenadeType: "); foreach (GrenadeType Gt in Enum.GetValues(typeof(GrenadeType))) { ListBuilder.Append(Gt.ToString()); ListBuilder.Append(" "); } ListBuilder.AppendLine(); ListBuilder.Append("VectorAxis: "); foreach (VectorAxis Va in Enum.GetValues(typeof(VectorAxis))) { ListBuilder.Append(Va.ToString()); ListBuilder.Append(" "); } ListBuilder.AppendLine(); ListBuilder.Append("PositionModifier: "); foreach (PositionModifier Pm in Enum.GetValues(typeof(PositionModifier))) { ListBuilder.Append(Pm.ToString()); ListBuilder.Append(" "); } string message = ListBuilder.ToString(); ListBuilder.Clear(); response = message; return(true); }
} // 等额本金法 public static List <Bt> HXXT(double amount, double yearRate, int months, double lx) { /// <summary> /// 等额本息法 /// </summary> /// <param name="amountT">投资金额</param> /// <param name="yearRate">年利率</param> /// <param name="monthsx">投资期限,单位:月</param> /// <returns></returns> Bt unit = new Bt(); var datalist = new List <Bt>(); unit.QS = 1; // 期数 unit.BJ = amount; // 偿还本金 unit.SY = 0; // 偿还利息 datalist.Add(unit); return(datalist); } // 还息续投法
public void Test_BitTools_toBtArray() { Random rnd = new Random((int)DateTime.Now.Ticks); const int nTests = 10000; Bt[] a = new Bt[64]; for (int k = 0; k < nTests; ++k) { long aValue = RandLong(64, rnd); BitTools.SetLongValue(ref a, aValue); (ulong, ulong)t1 = BitTools.ToRaw(a); Bt[] t2 = BitTools.ToBtArray(t1.Item1, t1.Item2); for (int i = 0; i < 64; ++i) { Assert.AreEqual(a[i], t2[i], "test " + k + "/" + nTests + ": i=" + i); } } }
} // 天标 public static List <Bt> YcxBx(double amount, double yearRate, int months, double lx) { /// <summary> /// 一次性还本付息 /// </summary> /// <param name="amountT">投资金额</param> /// <param name="yearRate">年利率</param> /// <param name="monthsx">投资期限,单位:天</param> /// <returns></returns> /// var a = yearRate; //年利率 var b = amount; // 偿还利息 var c = b * a * months; // 偿还利息 Bt unit = new Bt(); var datalist = new List <Bt>(); unit.QS = 1; // 期数 unit.BJ = Math.Round(b * 100) / 100; // 偿还本金 unit.SY = Math.Round(c * 100 * lx) / 100; // 偿还利息 datalist.Add(unit); return(datalist); } // 一次性还本付息
public FlagValue(Bt v) { _value = v; }
public AuxiliaryFlag(Bt v) : base(v) { }
public void Execute() { UpdatePvpQueueStatus(); Bt.Tick(); }
public ZeroFlag(Bt v) : base(v) { }
public ParityFlag(Bt v) : base(v) { }
public SignFlag(Bt v) : base(v) { }
public OverflowFlag(Bt v) : base(v) { }
public static char BitToCharHex(Bt b0, Bt b1, Bt b2, Bt b3) { if ((b3 == Bt.UNDEFINED) || (b2 == Bt.UNDEFINED) || (b1 == Bt.UNDEFINED) || (b0 == Bt.UNDEFINED)) { return('U'); } if ((b3 == Bt.KNOWN) || (b2 == Bt.KNOWN) || (b1 == Bt.KNOWN) || (b0 == Bt.KNOWN)) { return('K'); } if ((b3 == Bt.ZERO) && (b2 == Bt.ZERO) && (b1 == Bt.ZERO) && (b0 == Bt.ZERO)) { return('0'); } if ((b3 == Bt.ZERO) && (b2 == Bt.ZERO) && (b1 == Bt.ZERO) && (b0 == Bt.ONE)) { return('1'); } if ((b3 == Bt.ZERO) && (b2 == Bt.ZERO) && (b1 == Bt.ONE) && (b0 == Bt.ZERO)) { return('2'); } if ((b3 == Bt.ZERO) && (b2 == Bt.ZERO) && (b1 == Bt.ONE) && (b0 == Bt.ONE)) { return('3'); } if ((b3 == Bt.ZERO) && (b2 == Bt.ONE) && (b1 == Bt.ZERO) && (b0 == Bt.ZERO)) { return('4'); } if ((b3 == Bt.ZERO) && (b2 == Bt.ONE) && (b1 == Bt.ZERO) && (b0 == Bt.ONE)) { return('5'); } if ((b3 == Bt.ZERO) && (b2 == Bt.ONE) && (b1 == Bt.ONE) && (b0 == Bt.ZERO)) { return('6'); } if ((b3 == Bt.ZERO) && (b2 == Bt.ONE) && (b1 == Bt.ONE) && (b0 == Bt.ONE)) { return('7'); } if ((b3 == Bt.ONE) && (b2 == Bt.ZERO) && (b1 == Bt.ZERO) && (b0 == Bt.ZERO)) { return('8'); } if ((b3 == Bt.ONE) && (b2 == Bt.ZERO) && (b1 == Bt.ZERO) && (b0 == Bt.ONE)) { return('9'); } if ((b3 == Bt.ONE) && (b2 == Bt.ZERO) && (b1 == Bt.ONE) && (b0 == Bt.ZERO)) { return('A'); } if ((b3 == Bt.ONE) && (b2 == Bt.ZERO) && (b1 == Bt.ONE) && (b0 == Bt.ONE)) { return('B'); } if ((b3 == Bt.ONE) && (b2 == Bt.ONE) && (b1 == Bt.ZERO) && (b0 == Bt.ZERO)) { return('C'); } if ((b3 == Bt.ONE) && (b2 == Bt.ONE) && (b1 == Bt.ZERO) && (b0 == Bt.ONE)) { return('D'); } if ((b3 == Bt.ONE) && (b2 == Bt.ONE) && (b1 == Bt.ONE) && (b0 == Bt.ZERO)) { return('E'); } if ((b3 == Bt.ONE) && (b2 == Bt.ONE) && (b1 == Bt.ONE) && (b0 == Bt.ONE)) { return('F'); } // unreachable return('?'); }
public DirectionFlag(Bt v) : base(v) { }
public FlagValue(Bt v) { this._value = v; }
public CarryFlag(Bt v) : base(v) { }
//Finalval is the result of the look up of Lambda and Beta in the CP map. //The function uses a bilinear interpolation method, and has been developed //to replace interpn in an embedded matlab environment public void Interpolate(double Beta, double Lambda, ILArray <double> table2, ILArray <double> Betavec2, ILArray <double> Lambdavec2, out double Finalval) { ILArray <int> Bt; int B1; int B2; ILArray <int> Lt; int L1; int L2; ILArray <double> Yvals; ILArray <double> Yintervals; //Setting up persistent variables //Function initialization //The first time the function is run, it stores supplied map as a persistent //variable. if (_persistentCt == null)// Is only run once { _persistentCt = new PersistentVariables(); _persistentCt.Table = table2.C; _persistentCt.Betavec = Betavec2.C; _persistentCt.Lambdavec = Lambdavec2.C; } //Step 1, finding two adjecent indexes of the BetaVec, which contain the //supplied beta value Bt = ILMath.empty <int>(); ILMath.min(ILMath.abs(_persistentCt.Betavec - Beta), Bt); //Finding index 1 B1 = Bt.GetValue(0); //Necessary specification in embedded //matlab if (Beta > _persistentCt.Betavec.GetValue(B1)) //Finding index 2 { if (B1 == (_persistentCt.Betavec.Length - 1)) //testing if endpoint-extrapolation { B2 = B1; //should be used B1 = B1 - 1; } else { B2 = B1 + 1; } } else { if (B1 == 0) { B1 = 1; B2 = 0; } else { B2 = B1 - 1; } } //Step 2, finding two adjecent indexes of the LambdaVec, which contain the //supplied Lambda value Lt = ILMath.empty <int>(); ILMath.min(ILMath.abs(_persistentCt.Lambdavec - Lambda), Lt); L1 = Lt.GetValue(0); if (Lambda > _persistentCt.Lambdavec.GetValue(L1)) //Need to work out of indexes { if (L1 == (_persistentCt.Lambdavec.Length - 1)) { L2 = L1; L1 = L1 - 1; } else { L2 = L1 + 1; } } else { if (L1 == 0) { L1 = 1; L2 = 0; } else { L2 = L1 - 1; } } //Step 3 //Finding the four indexed values by means of the indexes Yvals = new double[, ] { { _persistentCt.Table.GetValue(B1, L1), _persistentCt.Table.GetValue(B2, L1) }, { _persistentCt.Table.GetValue(B1, L2), _persistentCt.Table.GetValue(B2, L2) } }; //Step 4 //Making two sets of linear interpolations by using the different lambda values Yintervals = ILMath.array(new double[] { ((Yvals.GetValue(0, 1) - Yvals.GetValue(0, 0)) / (_persistentCt.Lambdavec.GetValue(L2) - _persistentCt.Lambdavec.GetValue(L1)) * (Lambda - _persistentCt.Lambdavec.GetValue(L1)) + Yvals.GetValue(0, 0)), ((Yvals.GetValue(1, 1) - Yvals.GetValue(1, 0)) / (_persistentCt.Lambdavec.GetValue(L2) - _persistentCt.Lambdavec.GetValue(L1)) * (Lambda - _persistentCt.Lambdavec.GetValue(L1)) + Yvals.GetValue(1, 0)) }, 2, 1); //Step 5 //Making the final linear interpolation on the results obtained in //stepp 4 Finalval = ((Yintervals.GetValue(1) - Yintervals.GetValue(0)) / (_persistentCt.Betavec.GetValue(B2) - _persistentCt.Betavec.GetValue(B1))) * (Beta - _persistentCt.Betavec.GetValue(B1)) + Yintervals.GetValue(0); }
public override void _Ready() { _textLabel = GetNode(TextPath) as RichTextLabel; _input = new AIInputHandler <InputActions>(); _fsm = new FiniteStateMachine <PlayerState, Malo>(equalizer: (current, captured) => current == captured) { InitialState = PlayerState.OnAir }; _fsm.Add(PlayerState.OnAir, (current, player) => { if (!IsOnFloor() && !IsOnWall()) { GlobalVelocity += GravityVector; return(PlayerState.OnAir); } return(IsOnFloor() && !IsOnWall() ? PlayerState.OnGround : current); }); _fsm.Add(PlayerState.OnGround, (current, player) => { if (_input.IsActionPressed(InputActions.Jump)) { var jump = new Vector2(GlobalVelocity.x, -JumpForce); GlobalVelocity = jump; return(PlayerState.OnAir); } return(current); }); _fsm.Add(PlayerState.OnGround, (current, player) => { var horizontal = Vector2.Zero; if (_input.IsActionPressed(InputActions.MoveLeft)) { horizontal = new Vector2((-1 * HorizontalSpeed), GlobalVelocity.y); } if (_input.IsActionPressed(InputActions.MoveRight)) { horizontal = new Vector2((HorizontalSpeed), GlobalVelocity.y); } GlobalVelocity = horizontal; return(current); }); _fsm.Add(PlayerState.OnAir, (current, player) => { if (_wallTime > 0) { return(current); } var horizontal = Vector2.Zero; if (_input.IsActionPressed(InputActions.MoveLeft)) { horizontal = new Vector2((-1 * HorizontalSpeed), GlobalVelocity.y); GlobalVelocity = horizontal; } if (_input.IsActionPressed(InputActions.MoveRight)) { horizontal = new Vector2((HorizontalSpeed), GlobalVelocity.y); GlobalVelocity = horizontal; } return(current); }); _fsm.Add(PlayerState.OnAir, (current, player) => { if (IsOnFloor()) { GlobalVelocity.x = 0; return(PlayerState.OnGround); } return(current); }); _fsm.Add(PlayerState.OnAir, (current, player) => { if (IsOnWall()) { GlobalVelocity = GravityVector; var isLef = _getCollisionNormal() == Vector2.Left; return(isLef ? PlayerState.OnRightWall : PlayerState.OnLeftWall); } return(current); }); _fsm.Add(PlayerState.OnLeftWall, (current, delta) => IsOnFloor() ? PlayerState.OnGround : current); _fsm.Add(PlayerState.OnRightWall, (current, delta) => IsOnFloor() ? PlayerState.OnGround : current); _fsm.Add(PlayerState.OnLeftWall, (current, delta) => { if (_input.IsActionPressed(InputActions.MoveRight)) { var jump = new Vector2(HorizontalSpeed, -JumpForce); GlobalVelocity = jump; return(PlayerState.OnAir); } return(current); }); _fsm.Add(PlayerState.OnRightWall, (current, player) => { if (_input.IsActionPressed(InputActions.MoveLeft)) { var jump = new Vector2(HorizontalSpeed * -1, -JumpForce); GlobalVelocity = jump; return(PlayerState.OnAir); } return(current); }); _fsm.Add(PlayerState.OnLeftWall, (current, player) => { if (_input.IsActionJustPressed(InputActions.Jump)) { var jump = new Vector2(WallJumpHorizontalForce, -JumpForce); GlobalVelocity = jump; _wallTime = WallTime; return(PlayerState.OnAir); } return(current); }); _fsm.Add(PlayerState.OnRightWall, (current, player) => { if (_input.IsActionJustPressed(InputActions.Jump)) { var jump = new Vector2(WallJumpHorizontalForce * -1, -JumpForce); GlobalVelocity = jump; _wallTime = WallTime; return(PlayerState.OnAir); } return(current); }); _bt = Bt.Root( _bt.Function(x => { if (!x.IsOnWall() || x.IsOnWall() && x._getCollisionNormal() == Vector2.Left) { x._input.SetActionPressed(InputActions.MoveLeft); return(Node <Malo> .Status.Prossess); } else { x._input.SetActionReleased(InputActions.MoveLeft); return(Node <Malo> .Status.Success); } }), _bt.Wait(5f), _bt.Function(x => { if (!x.IsOnWall() || x.IsOnWall() && x._getCollisionNormal() == Vector2.Right) { x._input.SetActionPressed(InputActions.MoveRight); return(Node <Malo> .Status.Prossess); } else { x._input.SetActionReleased(InputActions.MoveRight); return(Node <Malo> .Status.Success); } }), _bt.Wait(5f) ); }