private void LogMove(WalkerMove move, bool ilegalAttemp, string illegalReason = "") { if (ilegalAttemp) { movesLog.AppendLine(logCount.ToString() + ". ***Illegal attemp***" + illegalReason); } else { movesLog.AppendLine(logCount.ToString() + ". " + move.ToString()); logCount++; } OnPropertyChange("MovesLog"); }
private bool IsMoveLegal(WalkerMove move) { if (move.type == WalkerMoveType.MainAxisRotate || move.type == WalkerMoveType.MainAxisTranslate) { if (CanPincersBeLocked(GetSecAxisPincerPoints())) { return(true); } return(false); } else { if (CanPincersBeLocked(GetMainAxisPincerPoints())) { return(true); } return(false); } }
//MovingChecks private bool DidWorkHeadWentOutsideOfSheet(WalkerMove move) { if (move.type != WalkerMoveType.MainAxisRotate) { return(false); } //Check whether it went out during the rotation double d = (MainAxisLenght / 2 + 1 - SecAxisTranslation) * Math.Sqrt(2); int i = (int)Math.Ceiling(d); switch (SecAxisAngle) { case AxisPosition.Right: if (RotationCenterPosition.Y + i >= _tubeSheet.MaxRows) { return(true); } return(false); case AxisPosition.Left: if (RotationCenterPosition.Y - i < 0) { return(true); } return(false); case AxisPosition.Down: if (RotationCenterPosition.X + i >= _tubeSheet.MaxRows) { return(true); } return(false); case AxisPosition.Up: if (RotationCenterPosition.X - i < 0) { return(true); } return(false); } return(false); }
public bool WalkerMakeMove(WalkerMove move, bool undo = false) { if (!IsMoveLegal(move)) { LogMove(move, true, "Can't Lock the pincers"); return(false); } switch (move.type) { case WalkerMoveType.MainAxisRotate: DoMainAxisRotation(); break; case WalkerMoveType.MainAxisTranslate: DoMainAxisTranslation(move.translation); break; case WalkerMoveType.SecondaryAxisRotate: DoSecAxisRotation(); break; case WalkerMoveType.SecondaryAxisTranslate: DoSecAxisTranslation(move.translation); break; } //if head leaves the tubeSheet do the undo but dont undo the undo if ((IsPointOutsideOfSheet(GetWorkHeadPosition()) || DidWorkHeadWentOutsideOfSheet(move)) && !undo) { LogMove(move, true, "WorkHead Outside of TubeSheet"); UndoMove(move); return(false); } if (!undo) { LogMove(move, false); } OnPropertyChange("WalkerMakeMove");//temp return(true); }
private void UndoMove(WalkerMove move) { move.translation = -move.translation; WalkerMakeMove(move, true); }