public void EnsureEvaluateCanReturnLastIn() { string expected = "-8 * 9"; Evaluate evaluate = new Evaluate(); evaluate.Input(expected); string actual = evaluate.LastIn; Assert.AreEqual(expected, actual); }
public void EnsureEvaluateCanReturnLastOut() { string input = "-8 * 9"; Evaluate evaluate = new Evaluate(); evaluate.Input(input); string expected = evaluate.Result; string actual = evaluate.LastOut; Assert.AreEqual(expected, actual); }
private IEnumerable<DimensionFilter> GetDimensionFilters(INEService.IndicatorValue value, IEnumerable<DimensionFilter> projectedDimensions, Evaluate eval) { foreach (var d in value.Dimensions) { DimensionFilter filter = projectedDimensions.Where(proj => d.Order.ToString() == proj.DimensionID).FirstOrDefault(); if (eval(filter)) yield return d.ToDimensionFilter(); } yield break; }
public void Main(string[] args) { int counter = 0; Parse parse = new Parse(); Evaluate eval = new Evaluate(); Stack stack = new Stack(); Console.Write("[{0}]>", counter); string input = Console.ReadLine(); while(true) { if (input.ToLower() == "exit" || input.ToLower() == "quit") break; try { if (input.Contains('=')) { parse.ExtractConstant(input); stack.SaveConstant(parse.ConstantKey, parse.ConstantValue); } else { parse.ExtractValues(input); eval.Calculate(parse.Int1, parse.Int2); } } catch (System.ArgumentException) { Console.WriteLine("Input entered in wrong format"); } counter++; Console.Write("[{0}]>", counter); input = Console.ReadLine(); } Console.WriteLine("Exiting program..."); System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(2)).Wait(); }
/// <summary> /// Appends the query. /// </summary> /// <param name="name">The query name.</param> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <param name="values">The query values.</param> /// <returns>The current HttpWebClient instance.</returns> /// <exception cref="ArgumentException">values cannot be null or empty. - values</exception> public HttpWebClient AppendQuery(string name, Evaluate <bool> canProceed, params Evaluate <object>[] values) { this._urlBuilder.AppendQuery(name, canProceed, values); return(this); }
/// <summary> /// Sets the Domain Name System (DNS) host name or IP address. /// </summary> /// <param name="host">The host.</param> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient SetHost(Evaluate <string> host, Evaluate <bool> canProceed = null) { this._urlBuilder.SetHost(host, canProceed); return(this); }
/// <summary> /// Sets the authority. /// </summary> /// <param name="user">The user.</param> /// <param name="password">The password.</param> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient SetAuthority(Evaluate <string> user, Evaluate <string> password, Evaluate <bool> canProceed = null) { this._urlBuilder.SetAuthority(user, password, canProceed); return(this); }
/// <summary> /// Sets the scheme name of the UrlBuilder. /// </summary> /// <param name="scheme">The scheme.</param> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient SetScheme(Evaluate <UrlBuilder.Scheme> scheme, Evaluate <bool> canProceed = null) { this._urlBuilder.SetScheme(scheme, canProceed); return(this); }
/// <summary> /// Creates hash code. /// </summary> /// <returns> /// The hash code for this value as an <see cref="int" />. /// </returns> private int CreateHashCode() { return(Evaluate.GenerateHashCode(this, ComparisonProperties)); }
/// <summary> /// Resets the current UrlBuilder instance to empty URL. /// </summary> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient Reset(Evaluate <bool> canProceed = null) { this._urlBuilder.Reset(canProceed); return(this); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(DocumentTypeRow other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
private void TestEncode() { RLWEParameters mpar = (RLWEParameters)RLWEParamSets.RLWEN256Q7681.DeepCopy(); RLWEKeyGenerator mkgen = new RLWEKeyGenerator(mpar); IAsymmetricKeyPair akp = mkgen.GenerateKeyPair(); RLWEPublicKey pub = (RLWEPublicKey)akp.PublicKey; byte[] enc = pub.ToBytes(); using (RLWEPublicKey pub2 = RLWEPublicKey.From(enc)) { if (!pub.Equals(pub2)) { throw new Exception("EncryptionKey: public key comparison test failed!"); } if (pub.GetHashCode() != pub2.GetHashCode()) { throw new Exception("EncryptionKey: public key hash test failed!"); } } OnProgress(new TestEventArgs("Passed public key serialization")); MemoryStream pubstr = pub.ToStream(); using (RLWEPublicKey pub2 = RLWEPublicKey.From(pubstr)) { if (!pub.Equals(pub2)) { throw new Exception("EncryptionKey: public key comparison test failed!"); } if (pub.GetHashCode() != pub2.GetHashCode()) { throw new Exception("EncryptionKey: public key hash test failed!"); } } pubstr.Dispose(); OnProgress(new TestEventArgs("Passed public key stream test")); RLWEPrivateKey pri = (RLWEPrivateKey)akp.PrivateKey; enc = pri.ToBytes(); using (RLWEPrivateKey pri2 = RLWEPrivateKey.From(enc)) { if (!pri.Equals(pri2)) { throw new Exception("EncryptionKey: private key comparison test failed!"); } if (pri.GetHashCode() != pri2.GetHashCode()) { throw new Exception("EncryptionKey: private key hash test failed!"); } } OnProgress(new TestEventArgs("Passed private key serialization")); MemoryStream pristr = pri.ToStream(); using (RLWEPrivateKey pri2 = RLWEPrivateKey.From(pristr)) { if (!pri.Equals(pri2)) { throw new Exception("EncryptionKey: private key comparison test failed!"); } if (pri.GetHashCode() != pri2.GetHashCode()) { throw new Exception("EncryptionKey: private key hash test failed!"); } } pristr.Dispose(); OnProgress(new TestEventArgs("Passed private key stream test")); using (RLWEEncrypt mpe = new RLWEEncrypt(mpar)) { mpe.Initialize(akp.PublicKey); int sz = mpe.MaxPlainText; byte[] data = new byte[sz]; new VTDev.Libraries.CEXEngine.Crypto.Prng.CSPPrng().GetBytes(data); enc = mpe.Encrypt(data); mpe.Initialize(akp.PrivateKey); byte[] dec = mpe.Decrypt(enc); if (!Evaluate.AreEqual(dec, data)) { throw new Exception("EncryptionKey: decryption failure!"); } OnProgress(new TestEventArgs("Passed encryption test")); } pri.Dispose(); pub.Dispose(); }
/// <summary> /// 设置评阅到界面。 /// </summary> /// <param name="cbb"></param> /// <param name="evaluate"></param> public static void SetEvaluateToWin(ComboBox cbb, Evaluate evaluate, ToolTipHandler toolTipHandler) { if (cbb != null && evaluate != null) { if (evaluate.Type == EnumEvaluateType.Score) { if (toolTipHandler != null) { toolTipHandler(cbb, "分数制"); } cbb.BeginUpdate(); cbb.DropDownStyle = ComboBoxStyle.DropDown; cbb.Text = string.Format("{0}", evaluate.MinValue + 1); cbb.TextChanged += new EventHandler(delegate(object o, EventArgs args) { ComboBox box = o as ComboBox; if (box != null) { try { int result = 0; if (int.TryParse(box.Text.Trim(), out result)) { if (result < evaluate.MinValue || result > evaluate.MaxValue) { MessageBox.Show(string.Format("评阅分数无效,须在[{0}-{1}]之间!", evaluate.MinValue, evaluate.MaxValue)); box.Text = string.Format("{0}", evaluate.MinValue); } } else { MessageBox.Show("评阅分数不能转化为数字!"); } } catch (Exception) { } } }); cbb.EndUpdate(); } else { if (toolTipHandler != null) { toolTipHandler(cbb, "等级制"); } cbb.BeginUpdate(); cbb.DropDownStyle = ComboBoxStyle.DropDownList; cbb.DataSource = evaluate.Items; cbb.DisplayMember = "ItemName"; cbb.ValueMember = "ItemValue"; cbb.SelectedIndex = -1; cbb.EndUpdate(); } } }
public Builder Require(Evaluate evalFunc, params ICombatLogic[] conditions) { foreach (ICombatLogic condLogic in conditions) { builder.AddLogic(condLogic); } conditionBlob = new ConditionBlob(conditions, evalFunc); return builder; }
internal ConditionBlob(ICombatLogic[] conditions, Evaluate evalFunc) { this.conditions = conditions; this.evalFunc = evalFunc; }
/// <summary> /// Sets the query, overwriting the value if name exists. /// </summary> /// <param name="ignoreCase">true to ignore case; otherwise, false.</param> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <param name="values">The query key value pairs.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient SetQuery(bool ignoreCase, Evaluate <bool> canProceed, params KeyValuePair <string, Evaluate <object>[]>[] values) { this._urlBuilder.SetQuery(ignoreCase, canProceed, values); return(this); }
/// <summary> /// Removes the query. /// </summary> /// <param name="ignoreCase">true to ignore case; otherwise, false.</param> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <param name="names">The query names.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient RemoveQuery(bool ignoreCase, Evaluate <bool> canProceed, params Evaluate <string>[] names) { this._urlBuilder.RemoveQuery(ignoreCase, canProceed, names); return(this); }
public void BesselK1Approx([Range(0.20, 2.0, 0.20)] double x) { // Approx by Abramowitz/Stegun 9.8.7 Assert.AreEqual(Evaluate.Polynomial(x / 2.0, x * Math.Log(x / 2.0) * SpecialFunctions.BesselI1(x) + 1.0, 0.0, 0.15443144, 0.0, -0.67278579, 0.0, -0.18156897, 0.0, -0.01919402, 0.0, -0.00110404, 0.0, -0.00004686), SpecialFunctions.BesselK1(x) * x, 1e-8); }
public void CleanUp() { anEvaluate = null; }
public void BesselI0Approx([Range(-3.75, 3.75, 0.25)] double x) { // Approx by Abramowitz/Stegun 9.8.1 Assert.AreEqual(Evaluate.Polynomial(x / 3.75, 1.0, 0.0, 3.5156229, 0.0, 3.0899424, 0.0, 1.2067492, 0.0, 0.2659732, 0.0, 0.0360768, 0.0, 0.0045813), SpecialFunctions.BesselI0(x), 1e-7); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(EntityLocation other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
public void BesselI1Approx([Range(-3.75, 3.75, 0.25)] double x) { // Approx by Abramowitz/Stegun 9.8.3 Assert.AreEqual(Evaluate.Polynomial(x / 3.75, 0.5, 0.0, 0.87890594, 0.0, 0.51498869, 0.0, 0.15084934, 0.0, 0.02658733, 0.0, 0.00301532, 0.0, 0.00032411) * x, SpecialFunctions.BesselI1(x), 1e-8); }
/// <summary> /// Sets the URL. /// </summary> /// <param name="urlBuilder">The UrlBuilder instance.</param> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient SetUrl(Evaluate <UrlBuilder> urlBuilder, Evaluate <bool> canProceed = null) { this._urlBuilder.SetUrl(urlBuilder, canProceed); return(this); }
public void BesselK0Approx([Range(0.20, 2.0, 0.20)] double x) { // Approx by Abramowitz/Stegun 9.8.5 Assert.AreEqual(Evaluate.Polynomial(x / 2.0, -Math.Log(x / 2.0) * SpecialFunctions.BesselI0(x) - 0.57721566, 0.0, 0.42278420, 0.0, 0.23069756, 0.0, 0.03488590, 0.0, 0.00262698, 0.0, 0.00010750, 0.0, 0.00000740), SpecialFunctions.BesselK0(x), 1e-8); }
/// <summary> /// Sets the port number of the UrlBuilder. /// </summary> /// <param name="port">The port.</param> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient SetPort(Evaluate <int> port, Evaluate <bool> canProceed = null) { this._urlBuilder.SetPort(port, canProceed); return(this); }
public static int MinMaxEx(ChessBoard currentPos, bool WhiteToMove, int currentDepth, int DepthToSearch, int alpha, int beta, Evaluate evalFunction) { /*supposed to be the improved version with the inclusion of alpha beta */ /*Say if all the moves are loosing moves.. all nodes return -iNFINITY according to the algorithm.. we still need to play a move * This flag detects whether a move has been selected for the UI*/ bool UIMoveSelected = false; int current_move_score; int best_score = -INFINITY;; if (WhiteToMove) { /*if a white pawn is in the 6th rank its a win for white! no need to check anything else*/ if ((RANK_6_MASK & currentPos.UserPawns) != 0) { return(INFINITY); } /*if a black pawn is in the first rank its a win for black*/ if ((RANK_1_MASK & currentPos.SystemPawns) != 0) { return(-INFINITY); } } else { /*if a black pawn is in the first rank its a win for black*/ if ((RANK_1_MASK & currentPos.SystemPawns) != 0) { return(INFINITY); } /*if a white pawn is in the 6th rank its a win for white! no need to check anything else*/ if ((RANK_6_MASK & currentPos.UserPawns) != 0) { return(-INFINITY); } } if (currentDepth == 0) { return(evalFunction(currentPos, WhiteToMove)); } //return EvaluatePositionEx(currentPos, UserToMove); ChessBoard[] moves = GenerateMoves(currentPos, WhiteToMove); /*if the side to move doesnt have any moves to play it has lost*/ if (moves == null) { return(-INFINITY); } //----------------------END OF TERMINAL NODE DETECTION AREA------------------------------------------- for (int i = 0; i < moves.Length; i++) { current_move_score = -MinMaxEx(moves[i], !WhiteToMove, currentDepth - 1, DepthToSearch, -beta, -alpha, evalFunction); if (current_move_score > best_score) { best_score = current_move_score; /* ----------------START OF UI MOVE SELECTION CODE-THIS IS SPECIFIC TO THIS APPLICATION AND IS NOT PART OF THE STANDARD ALPHA-BETA NEGAMAX ALGORITHM*/ if (currentDepth == DepthToSearch) { /*update the global variable that is used by the UI to update the bitboard * Update the Move Selected flag to true */ ReplyMove = moves[i]; UIMoveSelected = true; } /* ---------------------------------------END OF UI SELECTION CODE-------------------------------------------------------------- ------------------*/ } /* ----------------START OF UI MOVE SELECTION CODE-THIS IS SPECIFIC TO THIS APPLICATION AND IS NOT PART OF THE STANDARD ALPHA-BETA NEGAMAX ALGORITHM*/ /*if we're are on the last move on the moves[] array and we still haven't picked a move to play, * We need to do it NOW! */ if (currentDepth == DepthToSearch) { if (i == (moves.Length - 1)) { if (!UIMoveSelected) { /*select the first move for now; later we could do a evaluation * function and scientifically select the least worst move */ MinMaxEx(currentPos, WhiteToMove, 1, 1, -INFINITY, INFINITY, new Evaluate(EvaluatePositionEx)); // ReplyMove = moves[0]; UIMoveSelected = true; } } } /* ---------------------------------------END OF UI SELECTION CODE-------------------------------------------------------------- ------------------*/ if (best_score > alpha) { alpha = best_score; } /*Beta cut off*/ if (alpha >= beta) { break; } } return(best_score); }
/// <summary> /// Removes the authority. /// </summary> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient RemoveAuthority(Evaluate <bool> canProceed = null) { this._urlBuilder.RemoveAuthority(canProceed); return(this); }
public EvaluationModeFeature(Evaluate evaluationMode) { this.evaluationMode = evaluationMode; }
/// <summary> /// Removes the last occurrence of path segments. /// </summary> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <param name="paths">The paths.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient RemoveLastPath(Evaluate <bool> canProceed, params Evaluate <string>[] paths) { this._urlBuilder.RemoveLastPath(canProceed, paths); return(this); }
public void StartingPositionHasZeroScore() { Evaluate eval = new Evaluate(); Assert.AreEqual(0, eval.EvaluatePosition(new Lichen.Model.Position())); }
/// <summary> /// Appends the query. /// </summary> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <param name="values">The query key value pairs.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient AppendQuery(Evaluate <bool> canProceed, params KeyValuePair <string, Evaluate <object>[]>[] values) { this._urlBuilder.AppendQuery(canProceed, values); return(this); }
/// <summary> /// Serves as the default hash function. /// </summary> /// <returns> /// A hash code for the current object. /// </returns> public override int GetHashCode() { return(Evaluate.GenerateHashCode(this, ComparisonProperties)); }
/// <summary> /// Sets the query string, overwriting all values. /// </summary> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <param name="queryStrings">The query strings.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient SetQueryString(Evaluate <bool> canProceed, params Evaluate <string>[] queryStrings) { this._urlBuilder.SetQueryString(canProceed, queryStrings); return(this); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(DomainIdentity other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Set the URL fragment. /// </summary> /// <param name="fragment">The part of the URL after #.</param> /// <param name="canProceed">The delegate to check if can proceed or not.</param> /// <returns>The current HttpWebClient instance.</returns> public HttpWebClient SetFragment(Evaluate <string> fragment, Evaluate <bool> canProceed = null) { this._urlBuilder.SetFragment(fragment, canProceed); return(this); }
/// <summary> /// Compares the equality of two values of the same type. /// </summary> /// <param name="valueA"> /// The first value to compare. /// </param> /// <param name="valueB"> /// The second value to compare. /// </param> /// <returns> /// <c>true</c> if the values are equal; otherwise, <c>false</c>. /// </returns> public static bool operator ==(EntityLocation valueA, EntityLocation valueB) { return(Evaluate.Equals(valueA, valueB)); }
/// <summary> /// Initializes a new instance of the <see cref="LazyReturnAction"/> class. /// </summary> /// <param name="evaluate">The delegate used to aquire the return value.</param> public LazyReturnAction(Evaluate evaluate) { this.evaluate = evaluate; }
/// <summary> /// Compares the current instance with another object of the same type and returns an integer that indicates /// whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. /// </summary> /// <returns> /// A value that indicates the relative order of the objects being compared. The return value has these meanings: /// Value Meaning Less than zero This instance precedes <paramref name="obj"/> in the sort order. Zero This instance /// occurs in the same position in the sort order as <paramref name="obj"/>. Greater than zero This instance follows /// <paramref name="obj"/> in the sort order. /// </returns> /// <param name="obj"> /// An object to compare with this instance. /// </param> /// <exception cref="ArgumentException"> /// <paramref name="obj"/> is not the same type as this instance. /// </exception> public int CompareTo(object obj) { return(Evaluate.Compare(this, obj)); }
public void Initialize() { anEvaluate = new Evaluate(); }
/// <summary> /// Indicates whether this instance and a specified object are equal. /// </summary> /// <returns> /// true if <paramref name="obj"/> and this instance are the same type and represent the same value; otherwise, false. /// </returns> /// <param name="obj"> /// The object to compare with the current instance. /// </param> public override bool Equals(object obj) { return(Evaluate.Equals(this, obj)); }