/* * Returns true if a move is valid for a given position */ public static Boolean isMoveValid(Move move, Position position) { if (move == null) { return false; } ArrayList moves = new MoveGenerator().legalMoves(position); foreach (Move listMove in moves) { //Move is only valid if it appears in legal moves list if (move.Equals(listMove)) { return true; } } return false; }
public GameController(bool b, Position pos, bool blackIsAI, bool whiteIsAI) { this.board = new Board(b, pos, this, !blackIsAI); board.setup(); this.position = pos; this.movegen = new MoveGenerator(); this.Subscribe(this); this.blackIsAI = blackIsAI; this.whiteIsAI = whiteIsAI; TurnGenerator = SetupTurnGenerator(); if (blackIsAI & whiteIsAI) { bw = new BackgroundWorker(); bwSetup(); }else{ AI = new ComputerPlayer(engine.engineProcess.StandardOutput, engine.engineProcess.StandardInput); ResetEngineDifficulty(); } }
/** * GameController Constructors * Create and Setup Board, initialise class variables. */ public GameController(bool b, Position pos) { this.board = new Board(b, pos, this); board.setup(); this.position = pos; this.movegen = new MoveGenerator(); this.tutorialFlag = false; this.Subscribe(this); }
static MoveGenerator() { mgInstance = new MoveGenerator(); }