public override bool DoMatch(INode other, Match match) { if (other == null) { match.AddNull(this.groupName); } else { match.Add(this.groupName, other); } return true; }
public override bool DoMatch(INode other, Match match) { if (other == null) { match.AddNull(this.groupName); } else { match.Add(this.groupName, other); } return(true); }
public List <Match> GetVerticalMatches(Cell[][] grid, int colCount, int rowCount) { List <Match> matches = new List <Match>(); BitType type; Match match; for (int x = 0; x < colCount; x++) { type = grid[x][0].AssignedBit.BitType; match = new Match(); for (int y = 0; y < rowCount; y++) { Bit bit = grid[x][y].AssignedBit; if (type == bit.BitType) { match.Add(new Point(x, y)); match.Type = type; } else { if (match.Count >= 3) { matches.Add(match); } type = bit.BitType; match = new Match(); match.Add(new Point(x, y)); match.Type = type; } } if (match.Count >= 3) { matches.Add(match); } } return(matches); }
public override bool DoMatch(INode other, Match match) { match.Add(this.groupName, other); return other != null && !other.IsNull; }
protected internal override bool DoMatch(AstNode other, Match match) { match.Add(this.groupName, other); return(base.DoMatch(other, match)); }
bool FindNextMatchLHS(PhoneticShapeNode node, Direction dir, out Match match) { for (; node != node.Owner.GetLast(dir); node = node.GetNext(dir)) { VariableValues instantiatedVars = new VariableValues(m_alphaVars); if (m_lhs.Count == 0) { // epenthesis rules always match the LHS match = new Match(instantiatedVars); match.Add(node); return true; } else { IList<Match> matches; if (m_lhs.IsMatch(node, dir, ModeType.SYNTHESIS, instantiatedVars, out matches)) { match = matches[0]; return true; } } } match = null; return false; }
bool FindNextMatchRHS(PhoneticShapeNode node, Direction dir, out Match match) { for (; node != node.Owner.GetLast(dir); node = node.GetNext(dir)) { if (node.Type == PhoneticShapeNode.NodeType.BOUNDARY) continue; if (m_analysisTarget.Count == 0) { // if the analysis target is empty (deletion rule), // just check environment VariableValues instantiatedVars = new VariableValues(m_rule.m_alphaVars); if (MatchEnvEmpty(node, dir, ModeType.ANALYSIS, instantiatedVars)) { match = new Match(instantiatedVars); match.Add(node); return true; } } else { // analysis target is non-empty, check everything if (MatchAnalysisTarget(node, dir, out match)) return true; } } match = null; return false; }
protected internal override bool DoMatch(AstNode other, Match match) { match.Add(this.groupName, other); return base.DoMatch(other, match); }
public override bool DoMatch(INode other, Match match) { match.Add(this.groupName, other); return childNode.DoMatch(other, match); }
public override bool DoMatch(INode other, Match match) { match.Add(this.groupName, other); return(other != null && !other.IsNull); }
public override void FindMatches() { matches = new List <Match> (); //Horizontal Match activeMatch = null; for (int y = 0; y < board.Height; y++) { activeMatch = null; for (int x = 0; x < board.Width; x++) { var p = board.GetPiece(x, y); if (activeMatch != null) { if (p.color != activeMatch.color) { if (activeMatch.Size >= minMatchSize) { matches.Add(activeMatch); } activeMatch = new Match(p.color); activeMatch.Add(new Vector2Int(x, y)); } else { activeMatch.Add(new Vector2Int(x, y)); } } else { activeMatch = new Match(p.color); activeMatch.Add(new Vector2Int(x, y)); } } if (activeMatch.Size >= minMatchSize) { matches.Add(activeMatch); } } //Vertical for (int x = 0; x < board.Width; x++) { activeMatch = null; for (int y = 0; y < board.Height; y++) { var p = board.GetPiece(x, y); if (activeMatch != null) { if (p.color != activeMatch.color) { if (activeMatch.Size >= minMatchSize) { matches.Add(activeMatch); } activeMatch = new Match(p.color); activeMatch.Add(new Vector2Int(x, y)); } else { activeMatch.Add(new Vector2Int(x, y)); } } else { activeMatch = new Match(p.color); activeMatch.Add(new Vector2Int(x, y)); } } if (activeMatch.Size >= minMatchSize) { matches.Add(activeMatch); } } }
/// <summary> /// Process the action/choice of the user /// </summary> /// <param name="Method"></param> public void ProcessAction(string CommandMethod) { try { switch (CommandMethod) { case "CommandTerminate": Match.Terminate(); break; case "CommandEnd": Match.End(TennisMatch.MatchStatus.Terminated); break; case "CommandResign": Match.End(TennisMatch.MatchStatus.Resigned); break; case "CommandUndo": if (CurrentPoint == null || CurrentPoint.Point.Winner == 0 && CurrentPoint.Point.Serve != TennisPoint.PointServe.SecondServe) { //Undo the last played point if the current point is not present, or if it has not been played yet. Match.Undo(); } NewPoint(); break; case "CommandSwitchServer": Match.SwitchServer(); NewPoint(); break; case "CommandExtend": Match.Extend(); NewPoint(); break; default: CurrentPoint.ProcessAction(CommandMethod); if (CurrentPoint.PossibleActions.Count <= 1) { //no choices to make; start a new point Match.Add(CurrentPoint.Point); NewPoint(); } break; } NotifyPropertyChanged("CurrentPoint"); NotifyPropertyChanged("Duration"); NotifyPropertyChanged("IsExtendPossible"); NotifyPropertyChanged("SetScores"); NotifyPropertyChanged("ScorePlayer1"); NotifyPropertyChanged("ScorePlayer2"); NotifyPropertyChanged("Server"); NotifyPropertyChanged("InProgress"); NotifyPropertyChanged("Winner"); NotifyPropertyChanged("Completed"); NotifyPropertyChanged("Undo"); NotifyPropertyChanged("Sets"); NotifyPropertyChanged("Switch"); NotifyPropertyChanged("MatchType"); NotifyPropertyChanged("Status"); CurrentSetScore.Notify(); TotalSets.Notify(); StatisticsCollection.Notify(); } catch (Exception e) { ExtendedEventArgs eaa = new ExtendedEventArgs(); eaa.Error = "A fatal error occurred. Please try again or stop this match to preserve the statistics."; #if DEBUG eaa.Error = String.Format("A fatal error occurred. {1}:{0}", e.Message, e.Source); #endif OnFatalError(eaa); } }
public Match GetMatchFor(BoardPiece movedPiece) { var horizontalMatch = new Match(movedPiece.Type) { movedPiece }; var verticalMatch = new Match(movedPiece.Type) { movedPiece }; // check left for (int i = movedPiece.X - 1; i >= 0; i--) { if (_board[i, movedPiece.Y] == null || !_board[i, movedPiece.Y].Matches(movedPiece)) { break; } horizontalMatch.Add(_board[i, movedPiece.Y]); } // check right for (int i = movedPiece.X + 1; i < _board.GetLength(0); i++) { if (_board[i, movedPiece.Y] == null || !_board[i, movedPiece.Y].Matches(movedPiece)) { break; } horizontalMatch.Add(_board[i, movedPiece.Y]); } // check up for (int j = movedPiece.Y + 1; j < _board.GetLength(1); j++) { if (_board[movedPiece.X, j] == null || !_board[movedPiece.X, j].Matches(movedPiece)) { break; } verticalMatch.Add(_board[movedPiece.X, j]); } // check down for (int j = movedPiece.Y - 1; j >= 0; j--) { if (_board[movedPiece.X, j] == null || !_board[movedPiece.X, j].Matches(movedPiece)) { break; } verticalMatch.Add(_board[movedPiece.X, j]); } if (horizontalMatch.Count >= MinMatchSize && verticalMatch.Count >= MinMatchSize) { horizontalMatch.UnionWith(verticalMatch); return(horizontalMatch); } else if (horizontalMatch.Count >= MinMatchSize) { return(horizontalMatch); } else if (verticalMatch.Count >= MinMatchSize) { return(verticalMatch); } return(null); }
public ActionResult Create(Match model) { Match.Add(model); return(RedirectToAction("Index")); }