public List <BoardNode> Parse(string record) { List <BoardNode> GameBuilder = new List <BoardNode>(); BoardNode FirstNode; record = ExecuteFirstInstructions(record, out FirstNode); GameBuilder.Add(FirstNode.Place(new Stone(Color.None), new Coordinates(0, 0))); while (true) { string temp = GetNextInstruction(record); GameBuilder.Add(ExecuteMove(temp)); record = record.Remove(0, temp.Length); if (record[0] == ')') { break; } } return(GameBuilder); }
public override void animate() { if (!enabled) { return; } float power = 0; frameInit(); // percent, percentAfter, delta and enabled are now set if (!enabled) { // if frame init finished the animation FirstNode.SetPosition(initialPosition.x, initialPosition.y, initialPosition.z); } float amplitude = animationFunction(percentAfter * cycleLength.ValueRadians); startNewLoop = false; // Console.WriteLine("Amplitude: " + amplitude); foreach (SceneNode node in Nodes) { node.Translate(amplitude * Math.RangeRandom(-maxPower, maxPower), amplitude * Math.RangeRandom(-maxPower, maxPower), amplitude * Math.RangeRandom(-maxPower, maxPower)); } lastAmplitude = amplitude; }
public Node GetLeftNode() { if (IsVertical) { return(null); } return(FirstNode.OnOrLeftThan(SecondNode) ? FirstNode : SecondNode); }
public Node GetRightNode() { if (IsVertical) { return(null); } return(FirstNode.OnOrRightOf(SecondNode) ? FirstNode : SecondNode); }
public Node GetTopNode() { if (IsHorizontal) { return(null); } return(FirstNode.OnOrHigherThan(SecondNode) ? FirstNode : SecondNode); }
public Node GetBottomNode() { if (IsHorizontal) { return(null); } return(FirstNode.OnOrLessThan(SecondNode) ? FirstNode : SecondNode); }
/// <summary> /// 現在のオブジェクトを表す文字列を返します。 /// </summary> /// <returns>文字列</returns> public override IReadOnlyList <string> ToDebugStringList() { var result = new List <string>(); result.Add($"{ExpressionType}:"); result.AddRange(FirstNode.ToDebugStringList().Select(p => "| " + p)); result.AddRange(SecondNode.ToDebugStringList().Select(p => "| " + p)); return(result); }
public string GetLexBiggerNode() { if (FirstNode.CompareTo(SecondNode) <= 0) { return(SecondNode); } else { return(FirstNode); } }
protected virtual QueryNode VisitFirst(FirstNode node, ElasticSearchQueryOptimizerState state) { var node2 = Visit(node.SourceNode, state); var node3 = Visit(node.PredicateNode, state); if (node3.NodeType == QueryNodeType.MatchAll) { return(new FirstNode(node2, node3, node.AllowDefaultValue)); } return(new FirstNode(VisitAnd(new AndNode(node2, node3), state), new MatchAllNode(), node.AllowDefaultValue)); }
protected virtual QueryNode VisitFirst(FirstNode node, AzureQueryOptimizerState state) { QueryNode queryNode1 = this.Visit(node.SourceNode, state); QueryNode queryNode2 = this.Visit(node.PredicateNode, state); if (queryNode2.NodeType == QueryNodeType.MatchAll) { return((QueryNode) new FirstNode(queryNode1, queryNode2, node.AllowDefaultValue)); } return((QueryNode) new FirstNode(this.VisitAnd(new AndNode(queryNode1, queryNode2), state), (QueryNode) new MatchAllNode(), node.AllowDefaultValue)); }
public Node GetOtherNode(Node node) { if (FirstNode.Equals(node)) { return(SecondNode); } if (SecondNode.Equals(node)) { return(FirstNode); } return(null); }
/// <summary> /// 输入参考值范围进行解析,构造函数 /// </summary> /// <param name="text">参考值文本</param> public Reference(string text) { string[] splitFirstNodeName; //第二次分割,按冒号分割,得到第一节点的名称 string[] splitFirstNode; //第一次分割,按分号分割 string[] splitSecondNode; //第三次分割,按照空格分割,得到第二节点的块 string[] splitSecondNodeName; //第四次划分,按照逗号划分,得到二级节点的名称 string[] splitIncludeNumAndUnit; //分割后剩下单位和数字的部分 string temp = string.Empty; //临时变量 splitFirstNode = text.Split(';'); for (int i = 0; i < splitFirstNode.Length; i++) { splitFirstNodeName = splitFirstNode[i].Split(':'); FirstNode firstnode_temp = new FirstNode(); if (splitFirstNodeName.Length > 1) { firstnode_temp.nameOfNode = splitFirstNodeName[0]; splitSecondNode = splitFirstNodeName[1].Split(' '); } else { splitSecondNode = splitFirstNodeName[0].Split(' '); } firstnode.Add(firstnode_temp); for (int j = 0; j < splitSecondNode.Length; j++) { splitSecondNodeName = splitSecondNode[j].Split(','); SecondNode secondNode_temp = new SecondNode(); secondNode_temp.nameOfNode = splitSecondNodeName[0]; firstnode[i].secondNode.Add(secondNode_temp); splitIncludeNumAndUnit = splitSecondNodeName[1].Split('|'); for (int k = 0; k < splitIncludeNumAndUnit.Length; k++) { Interval intervalTemp = new Interval(); intervalTemp.unit = splitIncludeNumAndUnit[k].Split(new char[] { '(', ')' })[1]; if (splitIncludeNumAndUnit[k].Split(new char[] { '(', ')' })[0].Split('-')[1] == "#") { intervalTemp.up = 999999;//用这个数字表示正无穷 } else { intervalTemp.up = Convert.ToDouble(splitIncludeNumAndUnit[k].Split(new char[] { '(', ')' })[0].Split('-')[1]); } intervalTemp.down = Convert.ToDouble(splitIncludeNumAndUnit[k].Split(new char[] { '(', ')' })[0].Split('-')[0]); firstnode[i].secondNode[j].Interval.Add(intervalTemp); } } } }
public override Boolean Equals(Object obj) { if (obj == null) { return(false); } var wall = obj as Wall; if (wall == null) { return(false); } return(FirstNode.Equals(wall.FirstNode) && SecondNode.Equals(wall.SecondNode) || FirstNode.Equals(wall.SecondNode) && SecondNode.Equals(wall.FirstNode)); }
/** * Commit changes to all loaded grammars and all changes of grammar since * the last commitChange * * @throws JSGFGrammarParseException * @throws JSGFGrammarException */ public override void CommitChanges() { try { if (LoadGrammar) { if (Manager == null) { GetGrammarManager(); } LoadXML(); LoadGrammar = false; } RuleStack = new RuleStack(); NewGrammar(); FirstNode = CreateGrammarNode("<sil>"); var finalNode = CreateGrammarNode("<sil>"); finalNode.SetFinalNode(true); // go through each rule and create a network of GrammarNodes // for each of them foreach (var entry in _rules) { var publicRuleGraph = new GrammarGraph(this); RuleStack.Push(entry.Key, publicRuleGraph); var graph = ProcessRule(entry.Value); RuleStack.Pop(); FirstNode.Add(publicRuleGraph.StartNode, 0.0f); publicRuleGraph.EndNode.Add(finalNode, 0.0f); publicRuleGraph.StartNode.Add(graph.StartNode, 0.0f); graph.EndNode.Add(publicRuleGraph.EndNode, 0.0f); } PostProcessGrammar(); } catch (UriFormatException mue) { throw new IOException("bad base grammar URL " + BaseUrl + ' ' + mue); } }
/// <summary> /// Run through the track and for each node find the direction on the node /// </summary> void FindNodeOrientations() { // Node orientations are determined based on the track leading to the node // This makes it easier to extend the path (in case the last node is not known) // Only for the start node this is not possible. But hey, that is anyway up to the user. // start of path TrainpathNode currentMainNode = FirstNode; while (currentMainNode.NextMainNode != null) { // If there is a siding starting here, go through it until it ends. TrainpathNode currentSidingNode = currentMainNode; while (currentSidingNode.NextSidingNode != null) { TrainpathNode nextSidingNode = currentSidingNode.NextSidingNode; nextSidingNode.DetermineOrientation(currentSidingNode, currentSidingNode.NextSidingTvnIndex); currentSidingNode = nextSidingNode; } // In case a main node has two nodes leading to it (siding and main), then // the main track will override. TrainpathNode nextMainNode = currentMainNode.NextMainNode; nextMainNode.DetermineOrientation(currentMainNode, currentMainNode.NextMainTvnIndex); currentMainNode = nextMainNode; } if (currentMainNode is TrainpathVectorNode) { // Only vector nodes can be a real end! HasEnd = true; currentMainNode.NodeType = TrainpathNodeType.End; } else { HasEnd = false; } //Determine direction of first point. By using second point, the direction will be reversed FirstNode.DetermineOrientation(FirstNode.NextMainNode, FirstNode.NextMainTvnIndex); FirstNode.ReverseOrientation(); }
public Boolean ContainsNode(Node node) => FirstNode.Equals(node) || SecondNode.Equals(node);
T IQueue <T> .Dequeue() => FirstNode.Delete();
public T RemoveFirst() => FirstNode.Delete();
public override string ToString() { return(FirstNode.ToString() + " " + Compare + " " + SecondNode); }
public override Int32 GetHashCode() => FirstNode.GetHashCode() | SecondNode.GetHashCode();
protected virtual void StripFirst(FirstNode node, HashSet <QueryMethod> additionalQueryMethods) { additionalQueryMethods.Add(new FirstMethod(node.AllowDefaultValue)); }