private MovementRules GetMovementRules(IReadOnlyDictionary <Point, char> view) { var route = GetRoute(view); var routeCsv = string.Join(",", route); Console.WriteLine(routeCsv); var movementRules = new MovementRules { MainRoutine = routeCsv }; var remainingRoute = new List <string>(route); remainingRoute = FindFunction(movementRules, remainingRoute, (value) => movementRules.FunctionA = value, "A"); remainingRoute = FindFunction(movementRules, remainingRoute, (value) => movementRules.FunctionB = value, "B"); remainingRoute = FindFunction(movementRules, remainingRoute, (value) => movementRules.FunctionC = value, "C"); if (remainingRoute.Count > 0) { throw new InvalidOperationException("Movement Rules not calculated"); } return(movementRules); }
public override bool TryMove(Location target, Table table, out IStone willEated) { willEated = null; if (CheckMove(target, table) == false) { return(false); } var span = target - Location; // yatay - dikey hareket if (span.XDiff == 0 || span.YDiff == 0) { if (MovementRules.HorizontalOrVerticalCheck(Location, target, table) == false) { return(false); } } // çapraz else { if (MovementRules.DiagonalCheck(Location, target, table) == false) { return(false); } } willEated = table.Stones.GetFromLocation(target); return(true); }
public void InitializeTests() { this.Board = new Game.Data.Contract.Board(); this.RowController = new RowController(); this.Recognizer = new PatternRecognizer(this.Board, this.RowController); this.Analyzer = new BoardAnalyzer(this.Board); this.Controller = new BoardController(this.Board, this.Analyzer, this.Recognizer); this.Controller.Initialize(); this.Player = new Player("Nerzal") { Color = Colors.White }; this.Player2 = new Player("Wr4thon") { Color = Colors.Black }; IMovementRules movementRules = new MovementRules(this.Analyzer, this.Board); IGameOverRules gameOverRules = new GameOverRules(this.Analyzer); IRuleSet ruleSet = new RuleSet(movementRules, gameOverRules); IHistory history = new History(); this.MillRuleEvaluator = new Evaluator(ruleSet, this.Analyzer); IRowController rowController = new RowController(); IPatternRecognizer patternRecognizer = new PatternRecognizer(this.Board, rowController); this.GameController = new GameController(this.MillRuleEvaluator, this.Board, history, this.Controller, patternRecognizer, rowController); }
/// <summary> /// Creates a new instance of the Pawn class. /// </summary> /// <param name="tile">The location of the Pawn on the chess board.</param> /// <param name="team">The team that the Pawn is on.</param> /// <param name="parent">The chess board to allow referencing other Piece objects.</param> public Pawn(string tile, Team team, Board parent) : base(tile, team, parent) { IsFirstMove = true; MovementRules.Add(STANDARD_RULE, r => r.Horizonal == 0 && r.Vertical == 1 && r.Direction == (team == Team.Black ? CardinalDirection.South : CardinalDirection.North)); MovementRules.Add(FIRST_MOVE_RULE, r => r.Horizonal == 0 && r.Vertical.IsBetween(1, 2) && r.Direction == (team == Team.Black ? CardinalDirection.South : CardinalDirection.North)); MovementRules.Add(TAKE_PIECE_RULE, r => r.Horizonal == r.Vertical && r.Vertical == 1 && r.Direction == (team == Team.Black ? CardinalDirection.SouthWest : CardinalDirection.NorthWest) || r.Direction == (team == Team.Black ? CardinalDirection.SouthEast : CardinalDirection.NorthEast)); MovementRules.Add(QUEENS_RULE, r => (r.Vertical == r.Horizonal) || (r.Horizonal > 0 && r.Vertical == 0) || (r.Horizonal == 0 && r.Vertical > 0)); }
public void Initialize() { MovementRules moveValidationRules = new MovementRules(this.Analyzer, this.Board); GameOverRules gameOverRules = new GameOverRules(this.Analyzer); RuleSet ruleSet = new RuleSet(moveValidationRules, gameOverRules); this._evaluator = new Evaluator(ruleSet, this.Analyzer); }
private List <RuleResult <MovementRules> > CreateRule(MovementRules rule) { List <RuleResult <MovementRules> > rules = new List <RuleResult <MovementRules> >(); RuleResult <MovementRules> ruleResult = new RuleResult <MovementRules>(rule, MessageLevel.Error); rules.Add(ruleResult); return(rules); }
public override bool TryMove(Location target, Table table, out IStone willEated) { willEated = default; if (CheckMove(target, table) == false) { return(false); } //int currentX = Location.X; //int currentY = Location.Y; //var span = target - Location; //for (int i = 1; i <= span.XDiff; i++) //{ // currentX += span.XMovement == MovementDirection.Forward ? 1 : -1; // currentY += span.YMovement == MovementDirection.Forward ? 1 : -1; // var checkLocation = table.GetLocation(currentX, currentY); // if (checkLocation == null) // { // return false; // } // var checkLocationStone = table.Stones.GetFromLocation(checkLocation); // if (checkLocationStone != null) // { // if (i != span.XDiff) // { // // son nokta değil arada taş var // return false; // } // else // { // willEated = checkLocationStone; // break; // } // } //} if (MovementRules.DiagonalCheck(Location, target, table) == false) { return(false); } willEated = table.Stones.GetFromLocation(target); if (willEated == this) { willEated = null; } return(true); }
public override bool TryMove(Location target, Table table, out IStone willEated) { willEated = default; if (CheckMove(target, table) == false) { return(false); } if (MovementRules.HorizontalOrVerticalCheck(Location, target, table) == false) { return(false); } willEated = table.Stones.GetFromLocation(target); return(true); }
public override bool TryMove(Location target, Table table, out IStone willEated) { willEated = default; if (CheckMove(target, table) == false) { return(false); } var targetLocationStone = table.Stones.GetFromLocation(target); var span = target - Location; // çapraz gidiş if (span.XDiff == span.YDiff) { var result = MovementRules.DiagonalCheck(Location, target, table); if (result == false) { return(result); } if (targetLocationStone != null) { willEated = targetLocationStone; } } // yatay || dikey gidiş if (span.XDiff == 0 || span.YDiff == 0) { var result = MovementRules.HorizontalOrVerticalCheck(Location, target, table); if (result == false) { return(result); } if (targetLocationStone != null) { willEated = targetLocationStone; } } return(true); }
bool BlockedAt(IntVector2 t) { MapTerrain mt = Obstructions.Instance.TerrainAt(t); MapObject o = Obstructions.Instance.MobileAt(t); if (mt && (mt.water || mt.wall)) { return(true); } if (o) { MovementRules mr = o.GetComponent <MovementRules>(); if (mr) { if (mr.team == team) { return(false); } } return(true); // unit block } return(false); }
/// <summary> /// Creates a new instance of the King class. /// </summary> /// <param name="tile">The location of the King on the chess board.</param> /// <param name="team">The team that the King is on.</param> /// <param name="parent">The chess board to allow referencing other Piece objects.</param> public King(string tile, Team team, Board parent) : base(tile, team, parent) { MovementRules.Add(STANDARD_RULE, r => r.Vertical == 1 || r.Horizonal == 1); }
/// <summary> /// Creates a new instance of the Queen class. /// </summary> /// <param name="tile">The location of the Queen on the chess board.</param> /// <param name="team">The team that the Queen is on.</param> /// <param name="parent">The chess board to allow referencing other Piece objects.</param> public Queen(string tile, Team team, Board parent) : base(tile, team, parent) { MovementRules.Add(STANDARD_RULE, r => (r.Vertical == r.Horizonal) || (r.Horizonal > 0 && r.Vertical == 0) || (r.Horizonal == 0 && r.Vertical > 0)); }
/// <summary> /// Creates a new instance of the Knight class. /// </summary> /// <param name="tile">The location of the Knight on the chess board.</param> /// <param name="team">The team that the Knight is on.</param> /// <param name="parent">The chess board to allow referencing other Piece objects.</param> public Knight(string tile, Team team, Board parent) : base(tile, team, parent) { MovementRules.Add(STANDARD_RULE, r => (r.Horizonal == 1 && (r.Vertical == r.Horizonal * 2)) || (r.Vertical == 1 && (r.Horizonal == r.Vertical * 2))); }
public Creature(ObjectType type, ObjectGuid guid, string name, ushort weenieClassId, ObjectDescriptionFlag descriptionFlag, WeenieHeaderFlag weenieFlag, Position position) : base(type, guid, name, weenieClassId, descriptionFlag, weenieFlag, position) { this.movementStateMachine.Initialize(MovementRules.GetRules(), MovementRules.GetInitState()); }
public void SetUp() { rules = new MovementRules(true, true); }