资源简介
斗地主机器人AI源码,实现自动叫地主、抢地主,出牌等功能
代码片段和文件信息
#include “AI_Normal.h“
bool NormalAI::can_press(const vector& cards const vector& presscards)
{
pair cards_type = get_cards_type(cards);
if (cards_type.first != 0)
{
pair press_type = get_cards_type(presscards);
if (cards_type.first >= BOMB_TYPE && press_type.first < BOMB_TYPE)
{
return true;
}
if (cards_type.first == press_type.first && cards_type.second > press_type.second && cards.size() == presscards.size())
{
return true;
}
return false;
}
return false;
}
pair NormalAI::get_cards_type(const vector& cards)
{
int cardlen = cards.size();
switch (cardlen)
{
case 1:
{
return make_pair(SINGLE_TYPE cards[0]);
}
case 2:
{
if (cards[0] == cards[1])
{
return make_pair(PAIR_TYPE cards[0]);
}
else if (cards[0] == 14 && cards[1] == 15)
{
return make_pair(NUKE_TYPE 0);
}
break;
}
case 3:
{
if (cards[0] == cards[1] && cards[1] == cards[2])
{
return make_pair(TRIO_TYPE cards[0]);
}
break;
}
case 4:
{
if (cards[0] == cards[1] && cards[1] == cards[2] && cards[2] == cards[3])
{
return make_pair(BOMB_TYPE cards[0]);
}
else if (cards[0] != cards[1] && cards[1] == cards[2] && cards[2] == cards[3])
{
return make_pair(TRIOSINGLE_TYPE cards[1]);
}
else if (cards[0] == cards[1] && cards[1] == cards[2] && cards[2] != cards[3])
{
return make_pair(TRIOSINGLE_TYPE cards[0]);
}
break;
}
case 5:
{
if (cards[0] == cards[1] && cards[1] != cards[2] && cards[2] == cards[3] && cards[3] == cards[4])
{
return make_pair(TRIODOUBLE_TYPE cards[2]);
}
else if (cards[0] == cards[1] && cards[1] == cards[2] && cards[2] != cards[3] && cards[3] == cards[4])
{
return make_pair(TRIODOUBLE_TYPE cards[0]);
}
pair judgetype = is_straight(cards);
if (judgetype.first)
{
return make_pair(STRAIGHT_TYPE judgetype.second);
}
break;
}
case 6:
{
pair judgetype = is_straight(cards);
if (judgetype.first)
return make_pair(STRAIGHT_TYPE judgetype.second);
judgetype = is_consecutive_pair(cards);
if (judgetype.first)
return make_pair(CONPAIR_TYPE judgetype.second);
judgetype = is_aeroplane(cards);
if (judgetype.first)
{
return make_pair(AEROPLANE_TYPE judgetype.second);
}
judgetype = is_four_single(cards);
if (judgetype.first)
{
return make_pair(FOURSINGLE_TYPE judgetype.second);
}
break;
}
case 7:
{
pair judgetype = is_straight(cards);
if (judgetype.first)
{
return make_pair(STRAIGHT_TYPE judgetype.second);
}
break;
}
case 8:
{
pair judgetype = is_straight(cards);
if (judgetype.first)
{
return make_pair(STRAIGHT_TYPE judgetype.second);
}
judgetype = is_consecutive_pair(cards);
if (judgetype.first)
{
return make_pair(CONPAIR_TYPE judgetype.second);
}
judgetype =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 55035 2014-12-13 17:28 斗地主机器人\AI.cpp
文件 7985 2014-12-12 16:01 斗地主机器人\AI.h
目录 0 2018-12-10 18:54 斗地主机器人
----------- --------- ---------- ----- ----
63020 3
- 上一篇:Il2CppDumper-v3.5.0
- 下一篇:2018汽车之家车型数据
评论
共有 条评论