public QuantumChessEngine() { QuantumChessboard_ = QuantumChessboard.StartingQuantumChessboard(); ActivePlayer_ = Player.White; CreationTime_ = DateTime.Now; LastMovePositions_ = new Position[0]; }
public QuantumChessEngine(QuantumChessboard quantum_chessboard, Player active_player, DateTime creation_time, Position[] last_move_positions) { QuantumChessboard_ = quantum_chessboard; ActivePlayer_ = active_player; CreationTime_ = creation_time; LastMovePositions_ = last_move_positions; }
public static Game Deserialize(BsonDocument document) { ObjectId id = document["_id"].AsObjectId; Player active_player = PlayerUtils.FromString(document["active_player"].AsString); GameState game_state = GameStateUtils.FromString(document["game_state"].AsString); DateTime creation_time = document["creation_time"].ToLocalTime(); var harmonics = new List <QuantumHarmonic>(); foreach (BsonValue bson_harmonic_val in document["harmonics"].AsBsonArray) { BsonDocument bson_harmonic = bson_harmonic_val.AsBsonDocument; GameState harmonic_state = GameStateUtils.FromString(bson_harmonic["harmonic_state"].AsString); ulong degeneracy = Convert.ToUInt64(bson_harmonic["degeneracy"].AsInt64); BsonArray bson_chessboard = bson_harmonic["chessboard"].AsBsonArray; var chessboard = Chessboard.EmptyChessboard(harmonic_state); for (int i = 0; i < 64; i++) { BsonValue bson_square_val = bson_chessboard[i]; if (bson_square_val.IsBsonNull) { chessboard[i] = null; } else { BsonDocument bson_square = bson_square_val.AsBsonDocument; Player square_player = PlayerUtils.FromString(bson_square["player"].AsString); PieceType square_piece = PieceTypeUtils.FromString(bson_square["piece"].AsString); chessboard[i] = new Piece(square_player, square_piece); } } harmonics.Add(new QuantumHarmonic(chessboard, degeneracy)); } var quantum_chessboard = new QuantumChessboard(harmonics, game_state); var last_move_positions = new List <Position>(); foreach (BsonValue pos_val in document["last_move_positions"].AsBsonArray) { last_move_positions.Add(Position.Parse(pos_val.AsString)); } var engine = new QuantumChessEngine(quantum_chessboard, active_player, creation_time, last_move_positions.ToArray()); return(new Game(id, engine)); }
public static void DisplayQuantumChessboard(QuantumChessboard qboard, int cols) { int n = qboard.Harmonics.Count; int rows = (n + cols - 1) / cols; for (int row = 0; row < rows; row++) { var harmonics = new List <QuantumHarmonic>(); for (int col = 0; col < cols; col++) { int ind = row * cols + col; if (ind < n) { harmonics.Add(qboard.Harmonics[ind]); } } DisplayHarmonics(harmonics); if (row != rows - 1) { Console.WriteLine(); } } }