7 #ifndef AI_ANSWER_ARRAY_H
8 #define AI_ANSWER_ARRAY_H
12 #include <initializer_list>
15 template <
typename T, std::u
int8_t N = 6>
25 constexpr std::uint8_t
size() noexcept {
return N; }
28 constexpr std::uint8_t
position() noexcept {
return pos; }
33 auto max_it = std::max_element(
probs.begin(),
probs.end());
34 return static_cast<std::int8_t
>(std::distance(
probs.begin(), max_it));
41 sequence[pos] = value;
45 void push_back(std::initializer_list<T> values) noexcept
47 for(
auto value : values)
push_back(value);
50 constexpr T
at(
const std::uint8_t i) noexcept {
return sequence[i]; }
52 constexpr T
operator[](
const std::uint8_t i) noexcept {
return sequence[i]; }
57 if(
size() != 6)
return -1;
59 if(sequence[0] ==
cast(1))
addProb(2, 3, 4, 5, 6, 7);
68 if(sequence[3] ==
cast(1))
addProb(0, 1, 2, 3, 5, 6, 7);
74 if(sequence[5] ==
cast(1))
addProb(1, 2, 3, 4, 5, 6, 7);
82 if(
size() != 6)
return -1;
84 if(sequence[0] ==
cast(1))
addProb(0, 2, 3, 5, 6, 7);
96 if(sequence[4] ==
cast(1))
addProb(0, 1, 2, 3, 4, 7);
104 constexpr T
cast(
int i) {
return static_cast<T
>(i); }
107 template <
class... Args>
110 for(
int i : std::initializer_list<int>{ args... })
probs[i] += 1.0 /
size();
constexpr T at(const std::uint8_t i) noexcept
std::array< float, 8 > probs
void addProb(const Args &...args)
std::int8_t handwriting() noexcept
std::int8_t digitalNumber() noexcept
std::int8_t maxProbabilityNumber() noexcept
確率を入れた配列のうち、一番確率の高い要素のインデックスを返す
constexpr std::uint8_t position() noexcept
配列の要素を指し示すポインタを返す
void push_back(std::initializer_list< T > values) noexcept
constexpr T operator[](const std::uint8_t i) noexcept
constexpr std::uint8_t size() noexcept
配列のサイズを返す
void push_back(const T &value) noexcept
配列の要素を入れる