<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_PIG_H_
#define OPEN_SPIEL_GAMES_PIG_H_

#include <memory>
#include <string>
#include <vector>

#include "open_spiel/spiel.h"

// A simple jeopardy dice game that includes chance nodes.
// See http://cs.gettysburg.edu/projects/pig/index.html for details.
// Also https://en.wikipedia.org/wiki/Pig_(dice_game)
//
// For the Piglet variant, see http://cs.gettysburg.edu/~tneller/papers/pig.zip.
// The original Piglet variant described there is played with a fair coin and a
// winscore of 10. This behaviour can be achieved by setting diceoutcomes = 2,
// winscore = 10, piglet = true.
// Divide winscore by the average dice outcome != 1 (i.e. diceoutcomes/2 + 1)
// when enabling Piglet to have a game that's roughly equivalent to the
// corresponding Pig game. The main advantage of this variant is thus a greatly
// reduced state space, making the game accessible to tabular methods.
//
// Parameters:
//     "diceoutcomes"  int    number of outcomes of the dice  (default = 6)
//     "horizon"       int    max number of moves before draw (default = 1000)
//     "players"       int    number of players               (default = 2)
//     "winscore"      int    number of points needed to win  (default = 100)
//     "piglet"        bool   is piglet variant enabled?      (default = false)

namespace open_spiel {
namespace pig {

class PigGame;

class PigState : public State {
 public:
  PigState(const PigState&) = default;
  PigState(std::shared_ptr<const Game> game, int dice_outcomes, int horizon,
           int win_score, bool piglet);

  Player CurrentPlayer() const override;
  std::string ActionToString(Player player, Action move_id) const override;
  std::vector<std::pair<Action, double>> ChanceOutcomes() const override;
  std::string ToString() const override;
  bool IsTerminal() const override;<commit_msg>Explain Piglet variant vs Pig in header comment<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_PIG_H_
#define OPEN_SPIEL_GAMES_PIG_H_

#include <memory>
#include <string>
#include <vector>

#include "open_spiel/spiel.h"

// A simple jeopardy dice game that includes chance nodes.
// See http://cs.gettysburg.edu/projects/pig/index.html for details.
// Also https://en.wikipedia.org/wiki/Pig_(dice_game)
//
// Piglet variant: Instead of increasing the running total by the roll results,
// it is always increased by a fixed step size of 1 upon rolling anything higher
// than a 1. [Note: Internally, this behaviour is modelled with only two chance
// outcomes, rolling a 1 or rolling anything higher than that.]
// Divide winscore by the average dice outcome != 1 (i.e. by diceoutcomes/2 + 1)
// when enabling Piglet to play a game that's roughly equivalent to the
// corresponding Pig game. The main advantage of this variant is thus a greatly
// reduced state space, making the game accessible to tabular methods.
// See also http://cs.gettysburg.edu/~tneller/papers/pig.zip. The original Piglet
// variant described there is played with a fair coin and a winscore of 10. This
// behaviour can be achieved by setting diceoutcomes = 2, winscore = 10,
// piglet = true.
//
// Parameters:
//     "diceoutcomes"  int    number of outcomes of the dice  (default = 6)
//     "horizon"       int    max number of moves before draw (default = 1000)
//     "players"       int    number of players               (default = 2)
//     "winscore"      int    number of points needed to win  (default = 100)
//     "piglet"        bool   is piglet variant enabled?      (default = false)

namespace open_spiel {
namespace pig {

class PigGame;

class PigState : public State {
 public:
  PigState(const PigState&) = default;
  PigState(std::shared_ptr<const Game> game, int dice_outcomes, int horizon,
           int win_score, bool piglet);

  Player CurrentPlayer() const override;
  std::string ActionToString(Player player, Action move_id) const override;
  std::vector<std::pair<Action, double>> ChanceOutcomes() const override;
  std::string ToString() const override;
  bool IsTerminal() const override;
{'fraction_non_alphanumeric': 0.09274269557021678, 'fraction_numerical': 0.00999057492931197, 'mean_word_length': 3.4143094841930117, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '317928', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1464, 'n_words': 636}