public State(QTile[] tiles, ushort position) : this() { this.Value = 0; //The first 16 bits are used to store a position value (between 0 and 143) this.Value |= (ulong)position; //The next 24 bits are used to store 12 2-bit values representing //the QTile value in each of the 12 tiles around the position. for (int i = 0; i < tiles.Length; ++i) { this.Value |= ((ulong)tiles[i] << (2 * i + 16)); } }
public void Test1_NewQTile() { var t = new QTile("D2"); Assert.IsTrue(t.Shape == 3 && t.Color == 1); }
/// <summary> /// Gets a State object representing the current state. /// </summary> /// <param name="state">The GameState.</param> /// <param name="location">The Location from which to generate a state.</param> /// <returns>A State object that repressents the current state given the location.</returns> public State GetState(IGameState gameState, Location location) { QTile[] tiles = new QTile[statePositions.Length]; for (int i = 0; i < statePositions.Length; ++i) { Location loc = gameState.GetDestination(location, statePositions[i]); tiles[i] = gameState[loc].ToQTile(); } ushort position = location.ToUShort(gameState.Width); return new State(tiles, position); }