aozhiwei ec3a94d9ef 1
2022-12-23 11:33:58 +08:00

129 lines
3.9 KiB
C++

#include "precompile.h"
#include "mt/AI.h"
IMPL_TABLE(mt::AI)
namespace mt
{
void AI::Init1()
{
_param1 = a8::XValue(param1()).GetDouble();
_param2 = a8::XValue(param2()).GetDouble();
_param3 = a8::XValue(param3()).GetDouble();
_param4 = a8::XValue(param4()).GetDouble();
_param5 = a8::XValue(param5()).GetDouble();
_int_param1 = a8::XValue(param1());
_int_param2 = a8::XValue(param2());
_int_param3 = a8::XValue(param3());
_int_param4 = a8::XValue(param4());
_int_param5 = a8::XValue(param5());
{
std::vector<std::string> strings;
a8::Split(param1(), strings, '|');
for (auto& str : strings) {
_int_list_param1.push_back(a8::XValue(str).GetInt());
_int_set_param1.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(param2(), strings, '|');
for (auto& str : strings) {
_int_list_param2.push_back(a8::XValue(str).GetInt());
_int_set_param2.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(param3(), strings, '|');
for (auto& str : strings) {
_int_list_param3.push_back(a8::XValue(str).GetInt());
_int_set_param3.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(param4(), strings, '|');
for (auto& str : strings) {
_int_list_param4.push_back(a8::XValue(str).GetInt());
_int_set_param4.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(param5(), strings, '|');
for (auto& str : strings) {
_int_list_param5.push_back(a8::XValue(str).GetInt());
_int_set_param5.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(random_move_idle_time(), strings, ';');
if (!random_move_idle_time().empty()) {
_random_move_idle_time = std::make_tuple
(
a8::XValue(strings[0]).GetInt(),
a8::XValue(strings[1]).GetInt()
);
} else {
_random_move_idle_time = std::make_tuple
(
2,
3
);
}
}
{
std::vector<std::string> strings;
a8::Split(random_move_time(), strings, ';');
if (!random_move_time().empty()) {
_random_move_time = std::make_tuple
(
a8::XValue(strings[0]).GetInt(),
a8::XValue(strings[1]).GetInt()
);
} else {
_random_move_time = std::make_tuple
(
3,
5
);
}
}
if (ai_kind() == kAI_MineSweeper) {
for (int n : _int_list_param2) {
if (n <= 0 || n > 63) {
A8_ABORT();
}
a8::SetBitFlag(_bits_param2, n);
}
}
}
void AI::Init2()
{
}
int AI::GetMoveIdleTime()
{
return a8::RandEx(
std::get<0>(_random_move_idle_time),
std::get<1>(_random_move_idle_time)
);
}
int AI::GetMoveTime()
{
return a8::RandEx(
std::get<0>(_random_move_time),
std::get<1>(_random_move_time)
);
}
}