void Start() { turnOver = GetComponent <TurnOver>(); gameSpace = GameObject.FindObjectOfType <GameSpace>(); ActionMenu = GameObject.FindObjectOfType <Menu>(); moveChecker = GameObject.FindObjectOfType <MoveChecker>(); }
private void Awake() { pawnMoveValidator = GetComponent <PawnMoveValidator>(); moveChecker = GetComponent <MoveChecker>(); promotionChecker = GetComponent <PromotionChecker>(); tileGetter = GetComponent <TileGetter>(); }
private void CheckForMoves() { if (!MoveChecker.AvailableMove()) { rage.InvokeRage(); } }
public static List <Move> GetValidMoves(int startY, int startX, bool isWhite, King friendlyKing, Cell[,] board) { List <Move> validMoves = new List <Move>(); bool moveFurther = true; for (int y = startY + 1; y <= 7 && moveFurther; y++) { MoveChecker.CheckMove(startY, startX, y, startX, isWhite, board[y, startX], validMoves, friendlyKing, ref moveFurther); } moveFurther = true; for (int y = startY - 1; y >= 0 && moveFurther; y--) { MoveChecker.CheckMove(startY, startX, y, startX, isWhite, board[y, startX], validMoves, friendlyKing, ref moveFurther); } moveFurther = true; for (int x = startX + 1; x <= 7 && moveFurther; x++) { MoveChecker.CheckMove(startY, startX, startY, x, isWhite, board[startY, x], validMoves, friendlyKing, ref moveFurther); } moveFurther = true; for (int x = startX - 1; x >= 0 && moveFurther; x--) { MoveChecker.CheckMove(startY, startX, startY, x, isWhite, board[startY, x], validMoves, friendlyKing, ref moveFurther); } return(validMoves); }
public void False_NoPieces() { var pieces = new List <ISquarePiece>(); PieceManager.Instance.Setup(pieces, new float[0], new float[0]); Assert.IsFalse(MoveChecker.AvailableMove()); }
private void Awake() { pawnMoveValidator = GetComponent <PawnMoveValidator>(); moveChecker = GetComponent <MoveChecker>(); promotionChecker = GetComponent <PromotionChecker>(); turnHandler = GetComponent <TurnHandler>(); cpuPlayer = GetComponent <CPUPlayer>(); }
private void Awake() { moveChecker = GetComponent <MoveChecker>(); aiPawnMover = GetComponent <AIPawnMover>(); tileGetter = GetComponent <TileGetter>(); if (PlayerPrefs.HasKey("Difficulty")) { moveTreeDepth = PlayerPrefs.GetInt("Difficulty"); } }
public void ReciveMove(Move m) { MoveChecker moveCheck = RegisterMove(m); if (moveCheck.CheckResult == MoveChecker.ResultType.Negative) { Console.WriteLine(moveCheck.Description); Play(); } }
public void False_NoMatchingPieces_AboveBelow() { var pieces = new List <ISquarePiece> { BuildPiece(0, 0, "1"), BuildPiece(0, 1, "0") }; PieceManager.Instance.Setup(pieces, new float[1], new float[2]); Assert.IsFalse(MoveChecker.AvailableMove()); }
public void True_TwoMatchingPieces_Adjancent() { var pieces = new List <ISquarePiece> { BuildPiece(0, 0, "1"), BuildPiece(1, 0, "1") }; PieceManager.Instance.Setup(pieces, new float[2], new float[1]); Assert.IsTrue(MoveChecker.AvailableMove()); }
private void MakeDiceMove(Player player) { roll = gameset.DiceRoll(); MoveChecker moveCheck = RegisterNewDice(); if (moveCheck.CheckResult == MoveChecker.ResultType.Negative) { Console.WriteLine(moveCheck.Description); } Play(); }
public void True_TwoMatchingPieces_Diagonal_BottomRight() { var pieces = new List <ISquarePiece> { BuildPiece(0, 0, "2"), BuildPiece(0, 1, "1"), BuildPiece(1, 0, "1"), BuildPiece(1, 1, "0") }; PieceManager.Instance.Setup(pieces, new float[2], new float[2]); Assert.IsTrue(MoveChecker.AvailableMove()); }
public Package Analyze( PackageSyntax packageSyntax, FixedDictionary <string, Package> references) { // First pull over all the lexer and parser errors from the compilation units var diagnostics = AllDiagnostics(packageSyntax); var scopesBuilder = new LexicalScopesBuilder(diagnostics, packageSyntax, references); scopesBuilder.BuildScopesInPackage(packageSyntax); // Make a list of all the member declarations (i.e. not namespaces) var memberDeclarations = packageSyntax.CompilationUnits .SelectMany(cu => cu.AllMemberDeclarations).ToFixedList(); // TODO we can't do full type checking without some IL gen and code execution, how to handle that? // Do type checking TypeResolver.Check(memberDeclarations, diagnostics); #if DEBUG TypeResolutionValidator.Validate(memberDeclarations); // TODO validate that all ReferencedSymbols lists have a single value non-errored code #endif MoveChecker.Check(memberDeclarations, diagnostics); ShadowChecker.Check(memberDeclarations, diagnostics); // TODO we need to check definite assignment as part of this BindingMutabilityChecker.Check(memberDeclarations, diagnostics); // -------------------------------------------------- // This is where the representation transitions to IR ControlFlowAnalyzer.BuildGraphs(memberDeclarations); // -------------------------------------------------- var liveness = LivenessAnalyzer.Analyze(memberDeclarations); DeleteInserter.Transform(memberDeclarations, liveness); BorrowChecker.Check(memberDeclarations, diagnostics); // Build final declaration objects and find the entry point var declarationBuilder = new DeclarationBuilder(); var declarations = declarationBuilder.Build(memberDeclarations); var entryPoint = DetermineEntryPoint(declarations, diagnostics); return(new Package(packageSyntax.Name, diagnostics.Build(), references, declarations, entryPoint)); }
void Start() { ai = GameObject.FindObjectOfType <AI>(); anim = GetComponent <Animator>(); turnover = GameObject.FindObjectOfType <TurnOver>(); atri = GetComponent <CharacterAtributes>(); gather = GameObject.FindObjectOfType <InformationGatherer>(); moveChecker = GameObject.FindObjectOfType <MoveChecker>(); healthBar.maxValue = atri.health; healthBar.value = atri.health; ActionMenu = GameObject.FindObjectOfType <Menu>(); canvas = GameObject.Find("ActionMenu").GetComponentInChildren <Canvas>(); canvas.enabled = false; menu = GameObject.Find("ActionMenu").GetComponentInChildren <Dropdown>(); menu.ClearOptions(); menu.AddOptions(DropOptions1); menu.Hide(); orginalMoves = moves; ps = GetComponent <ParticleSystem>(); gameSpace = GameObject.FindObjectOfType <GameSpace>(); }
private void GetPlayerMove(Player player) { if (gameLogic.PossibleMoves.Length > 0) { int source = 0; int target = 0; gameset.PrintCurrentDiceOption(gameLogic); Console.WriteLine(); gameset.PrintMovesAvailable(gameLogic); AskForMove(player, ref source, ref target); Move newMove = new Move(source - 1, target - 1, player.playerCheckerType); ReciveMove(newMove); } else { Move newMove = new Move(0, 0, gameLogic.CurrentChecker); Console.WriteLine("Thre is no possiable moves you lose yourTurn"); MoveChecker moveCheck = RegisterMove(newMove); if (moveCheck.CheckResult != MoveChecker.ResultType.Positive) { Console.WriteLine("Eror"); } } }
public char?[,] OtherHardMoves() { var moveGenerator = new MoveChecker(GameState); if (moveGenerator.IsChanceToWin(GameState, 'O', 'X')) { int[] finalMovePosition = moveGenerator.FinalMovePosition(); GameState[finalMovePosition[0], finalMovePosition[1]] = 'O'; } else if (moveGenerator.IsDefendNeeded() && moveGenerator.IsChanceToWin(GameState, 'X', 'O')) { int[] dangerPosition = moveGenerator.DangerPosition(); GameState[dangerPosition[0], dangerPosition[1]] = 'O'; } else if (moveGenerator.PerspectiveMovePosition() != null) { GameState[moveGenerator.PerspectiveCoordinates[0], moveGenerator.PerspectiveCoordinates[1]] = 'O'; } else //random move { return(EasyModeLogic.EasyModeMove(GameState)); } return(GameState); }
void Start() { moveChecker = GameObject.FindObjectOfType <MoveChecker>(); players = GameObject.FindObjectsOfType <Player>(); }
public ChessGame MoveChessPiece(ChessGame game, Position startPosition, Position targetPosition) { var chessBoard = new ChessBoard(game.Board); if (!chessBoard.IsValidPosition(startPosition)) { var errorMessage = $"The starting position ({startPosition}) is not on the board"; throw new InvalidOperationException(errorMessage); } if (!chessBoard.IsValidPosition(targetPosition)) { var errorMessage = $"The target position ({targetPosition}) is not on the board"; throw new InvalidOperationException(errorMessage); } if (startPosition.Equals(targetPosition)) { var errorMessage = $"The starting position ({startPosition}) was the same as the target position ({targetPosition})"; throw new InvalidOperationException(errorMessage); } var pieceInSource = chessBoard.GetPiece(startPosition); var pieceInTarget = chessBoard.GetPiece(targetPosition); if (pieceInSource == null) { var errorMessage = $"There is no piece in the starting position ({startPosition})"; throw new InvalidOperationException(errorMessage); } var moveChecker = new MoveChecker(); var move = new Move(startPosition, targetPosition); if (!moveChecker.IsValidMovement(chessBoard, pieceInSource, move)) { var errorMessage = $"This move (Rows: {move.X}, Cols: {move.Y}) is not valid for this piece ({pieceInSource})."; throw new InvalidOperationException(errorMessage); } if (moveChecker.MoveIsBlocked(chessBoard, pieceInSource, pieceInTarget, targetPosition, move)) { var errorMessage = $"This move (Rows: {move.X}, Cols: {move.Y}) is blocked by another piece."; throw new InvalidOperationException(errorMessage); } if (moveChecker.WouldLeaveInCheck()) { var errorMessage = $"This move (Rows: {move.X}, Cols: {move.Y}) would leave the current player in check."; throw new InvalidOperationException(errorMessage); } chessBoard.SetPosition(startPosition, null); if (pieceInSource.Type == "Pawn") { switch (pieceInSource.Colour) { case Player.Black when targetPosition.Row == 7: chessBoard.SetPosition(targetPosition, new Queen(Player.Black)); game.RemovedPieces.Add(pieceInSource); break; case Player.White when targetPosition.Row == 0: chessBoard.SetPosition(targetPosition, new Queen(Player.White)); game.RemovedPieces.Add(pieceInSource); break; } } else { chessBoard.SetPosition(targetPosition, pieceInSource); } if (pieceInTarget != null) { game.RemovedPieces.Add(pieceInTarget); } return(new ChessGame { Board = new ChessBoard().GetBoard(), ActivePlayer = game.ActivePlayer == Player.White ? Player.Black : Player.White, GameState = "", RemovedPieces = game.RemovedPieces }); }
/// <summary> /// Create new chess game object /// </summary> public ChessGame(ChessProtocol Protocol, PlayerColor MyColor) { _ChessProtocol = Protocol; _MyColor = MyColor; _MoveChecker = new MoveChecker(this); }
private void Begin() { Creator.StartGame(grid, (Style)FindResource("CustomLabel"), (Style)FindResource("RoundButtonTemplate"), scoreLabel, bestScoreLabel); _moveChecker = new MoveChecker(); }