<commit_before>// Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OPEN_SPIEL_GAMES_DARK_HEX_H_
#define OPEN_SPIEL_GAMES_DARK_HEX_H_

#include <array>
#include <map>
#include <memory>
#include <string>
#include <vector>

#include "open_spiel/games/hex.h"
#include "open_spiel/spiel.h"

// Dark Hex (Some versions also called Phantom Hex or Kriegspiel Hex) is an imperfect
// information version of the classic game of Hex. Players are not exposed to oppsite
// sides piece information. Only a refree has the full information of the board. When
// a move fails due to collision the player gets the information of the cell (stone
// exists), and is allowed to make another move until success. 
// 
// There are slightly different versions of the game exists depending on the level of
// information being exposed to the opponent and what happens in the event of a
// collision. Right now we only have the Classic Dark Hex (Phantom Hex) implemented 
// with player:
//        - Replays after a collision
//        - Exposed(information on opponent) only to number of turns or nothing
//
// Common phantom games include Kriegspiel (Phantom chess), e.g. see
// https://en.wikipedia.org/wiki/Kriegspiel_(chess), and Phantom Go.
// See also http://mlanctot.info/files/papers/PhD_Thesis_MarcLanctot.pdf, Ch 3.
//
// Parameters:
///    "obstype", string, "reveal-nothing" (default) or "reveal-numturns"

namespace open_spiel {
  namespace dark_hex {
  
    // kDefaultObsType decide if we will reveal any info. to other player xx
    inline constexpr const char* kDefaultObsType = "reveal-nothing"; 
    // do we need inline & constexpr here ? I feel like it's not 
    // necessary as they dont add any value here ??

    inline const int kNumOfCells = hex::kDefaultBoardSize * hex::kDefaultBoardSize;
    // EDIT Hex, to have x, y as board size not x, x
    inline constexpr int kLongestSequence = 2 * kNumOfCells - 1;
    inline constexpr int kBitsPerAction = 10;

    // Add here if anything else is needed to be revealed
    enum class ObservationType {
      kRevealNothing,
      kRevealNumTurns,
    };

    class DarkHexState: public State {
      public: 
        DarkHexState(std::shared_ptr<const Game> game, int board_size, 
                     ObservationType obs_type);

        Player CurrentPlayer() const override {return state_.CurrentPlayer(); }

        std::string ActionToString(Player player, Action action_id) const override {
          return state_.ActionToString(player, action_id);
        }
        std::string ToString() const override {return state_.ToString();}
        bool IsTerminal() const override {return state_.IsTerminal();}
        std::vector<double> Returns() const override {return state_.Returns();}
        std::string ObservationString(Player player) const override;
        void ObservationTensor(Player player,
                               absl::Span<float> values) const override;
        
        // Dark games funcs.<commit_msg>comment fixed<commit_after>// Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OPEN_SPIEL_GAMES_DARK_HEX_H_
#define OPEN_SPIEL_GAMES_DARK_HEX_H_

#include <array>
#include <map>
#include <memory>
#include <string>
#include <vector>

#include "open_spiel/games/hex.h"
#include "open_spiel/spiel.h"

// Dark Hex (Some versions also called Phantom Hex or Kriegspiel Hex) is an imperfect
// information version of the classic game of Hex. Players are not exposed to oppsite
// sides piece information. Only a refree has the full information of the board. When
// a move fails due to collision the player gets the information of the cell (stone
// exists), and is allowed to make another move until success. 
// 
// There are slightly different versions of the game exists depending on the level of
// information being exposed to the opponent and what happens in the event of a
// collision. Right now we only have the Classic Dark Hex (Phantom Hex) implemented 
// with player:
//        - Replays after a collision
//        - Exposed(information on opponent) only to number of turns or nothing
//
// Common phantom games include Kriegspiel (Phantom chess), e.g. see
// https://en.wikipedia.org/wiki/Kriegspiel_(chess), and Phantom Go.
// See also http://mlanctot.info/files/papers/PhD_Thesis_MarcLanctot.pdf, Ch 3.
//
// Parameters:
///    "obstype", string, "reveal-nothing" (default) or "reveal-numturns"

namespace open_spiel {
  namespace dark_hex {
  
    inline constexpr const char* kDefaultObsType = "reveal-nothing"; 

    inline const int kNumOfCells = hex::kDefaultBoardSize * hex::kDefaultBoardSize;
    // EDIT Hex, to have x, y as board size not x, x
    inline constexpr int kLongestSequence = 2 * kNumOfCells - 1;
    inline constexpr int kBitsPerAction = 10;

    // Add here if anything else is needed to be revealed
    enum class ObservationType {
      kRevealNothing,
      kRevealNumTurns,
    };

    class DarkHexState: public State {
      public: 
        DarkHexState(std::shared_ptr<const Game> game, int board_size, 
                     ObservationType obs_type);

        Player CurrentPlayer() const override {return state_.CurrentPlayer(); }

        std::string ActionToString(Player player, Action action_id) const override {
          return state_.ActionToString(player, action_id);
        }
        std::string ToString() const override {return state_.ToString();}
        bool IsTerminal() const override {return state_.IsTerminal();}
        std::vector<double> Returns() const override {return state_.Returns();}
        std::string ObservationString(Player player) const override;
        void ObservationTensor(Player player,
                               absl::Span<float> values) const override;
        
        // Dark games funcs.
{'fraction_non_alphanumeric': 0.08532176428054954, 'fraction_numerical': 0.0037599421547360808, 'mean_word_length': 3.219646125686394, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5600969', 'n_tokens_mistral': 1952, 'n_tokens_neox': 1846, 'n_words': 771}