BitboardLayer validMoveOverlays = new BitboardLayer(); //layer containing info as to whether a square should be marked as valid #endregion Fields #region Constructors public MainForm(int gameMode) { this.gameMode = gameMode; // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); allTiles = new PictureBox[]{pictureBox1, pictureBox2, pictureBox3, pictureBox4, pictureBox5, pictureBox6, pictureBox7, pictureBox8, pictureBox9, pictureBox10, pictureBox11, pictureBox12, pictureBox13, pictureBox14, pictureBox15, pictureBox16, pictureBox17, pictureBox18, pictureBox19, pictureBox20, pictureBox21, pictureBox22, pictureBox23, pictureBox24, pictureBox25, pictureBox26, pictureBox27, pictureBox28, pictureBox29, pictureBox30, pictureBox31, pictureBox32, pictureBox33, pictureBox34, pictureBox35, pictureBox36, pictureBox37, pictureBox38, pictureBox39, pictureBox40, pictureBox41, pictureBox42, pictureBox43, pictureBox44, pictureBox45, pictureBox46, pictureBox47, pictureBox48, pictureBox49, pictureBox50, pictureBox51, pictureBox52, pictureBox53, pictureBox54, pictureBox55, pictureBox56, pictureBox57, pictureBox58, pictureBox59, pictureBox60, pictureBox61, pictureBox62, pictureBox63, pictureBox64}; for(int i = 0; i < allTiles.Length; i++){ this.allTiles[i].Click += new System.EventHandler(this.PictureBoxClick); } //set tiles to be light or dark for (int i = 0; i < baseTiles.Length; i++){ baseTiles[i] = (i / 8) % 2 == 0 ^ i % 2 == 1; } //populate piece arrays int divide = pieceOverlays.Length / 2; for (int i = 0; i < divide; i++) { pieceOverlays[i] = Image.FromFile(Path.Combine(imagePath, i.ToString() + ".png")); pieceOverlays[i + divide] = Image.FromFile(Path.Combine(imagePath, "B" + i + ".png")); } pieceOverlays[pieceOverlays.Length - 1] = Image.FromFile(Path.Combine(imagePath, "validMove.png")); c = new ChessBoardDisplay(this); if ((gameMode & 1) > 0) gameAIs[1] = new AI(c.getBoard(), true, defaultSearchDepth, this); if ((gameMode & 2) > 0) gameAIs[0] = new AI(c.getBoard(), false, defaultSearchDepth, this); isWhiteMove = true; paintTiles(); }
private void initializeGame(int myTeam) { Console.WriteLine("# Init: Thread ID: {0}", System.Threading.Thread.CurrentThread.ManagedThreadId); // Resume game? if (myTeam == (int)team.none) { Console.WriteLine("# Resuming Game."); Tuple<Gameboard, State> loadedGame = storage.LoadGame(); gameboard = loadedGame.Item1; currentState = loadedGame.Item2; gameboard.updateBoard(); currentState.updateState(currentState.getMyTeam()); } // Else initialize default else { Console.WriteLine("# Initializes new Game."); gameboard = new Gameboard(); gameboard.initialize(); currentState = new State(myTeam); storage.manuallyInitialize(gameboard, currentState); } AIOpponent = new AI(currentState.getOpponentTeam()); storage.getWatcher().SynchronizingObject = this; // Update GUI when database is changed storage.propertyChanged += new PropertyChangedEventHandler(OnDatabaseChanged); if (currentState.getOpponentTeam() == (int)team.white) { Console.WriteLine("# Computer will make first move."); AIOpponent.Move(gameboard, currentState); } updateBoard(); }