Introduce using directive for map type

This sets up for quick testing of different maps with the same interface
This commit is contained in:
Maximilian Keßler 2024-02-07 18:59:08 +01:00
parent 3985ffaac4
commit 5507f8e5dc
Signed by: max
GPG key ID: BCC5A619923C0BA5
4 changed files with 9 additions and 6 deletions

View file

@ -4,7 +4,6 @@
#include <cstddef>
#include <iosfwd>
#include <vector>
#include <unordered_map>
#include <memory>
#include "hanabi_types.hpp"
@ -71,7 +70,7 @@ namespace Hanabi
[[nodiscard]] virtual std::uint64_t enumerated_states() const = 0;
[[nodiscard]] virtual const std::unordered_map<unsigned long, probability_t> & position_tablebase() const = 0;
[[nodiscard]] virtual const map_type<unsigned long, probability_t> & position_tablebase() const = 0;
virtual void init_backtracking_information() = 0;

View file

@ -9,7 +9,6 @@
#include <optional>
#include <ostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <memory>
@ -117,7 +116,7 @@ namespace Hanabi
[[nodiscard]] std::uint64_t enumerated_states() const final;
[[nodiscard]] const std::unordered_map<unsigned long, probability_t> & position_tablebase() const final;
[[nodiscard]] const map_type<unsigned long, probability_t> & position_tablebase() const final;
void init_backtracking_information() final;
@ -258,7 +257,7 @@ namespace Hanabi
RelativeRepresentationData _relative_representation;
// Lookup table for states. Uses the ids calculated using the relative representation
std::unordered_map<unsigned long, probability_t> _position_tablebase;
map_type<unsigned long, probability_t> _position_tablebase;
std::uint64_t _enumerated_states{};
};

View file

@ -1336,7 +1336,7 @@ namespace Hanabi
}
template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
const std::unordered_map<unsigned long, probability_t> &
const map_type<unsigned long, probability_t> &
HanabiState<num_suits, num_players, hand_size>::position_tablebase() const
{
return _position_tablebase;

View file

@ -8,6 +8,8 @@
#include <boost/rational.hpp>
#include <unordered_map>
namespace Hanabi
{
@ -20,6 +22,9 @@ namespace Hanabi
using probability_base_type = unsigned long;
using rational_probability = boost::rational<probability_base_type>;
template<class Key, class Value>
using map_type = std::unordered_map<Key, Value>;
/**
* Define macro
* NUSE_RATIONAL_PROBABILITIES