加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ai.c 1.74 KB
一键复制 编辑 原始数据 按行查看 历史
buzhibujue 提交于 2021-12-16 00:32 . Add card J.
#include "zgs.h"
extern int player_number, MP;
extern Pig player[MAX_PLAYER];
void pick_card(int id,int time)
{
printf("Player[%d] pick up %d cards\n",id,time);
for(int i=1;i<=time;i++){
player[id].card[(player[id].card_number+1)] = get_a_card();
player[id].card_number++;
}
}
void cure(int id)
{
while(can_use(id,'P')&&player[id].health<4+(MP==id)){
//ues peach to player[id]
use_p(id);
}
}
int select_aim(int id,int is_f){
/*aim type*/
switch(player[id].id){
case 'Z':{
for(int i=id%player_number+1;i!=id;i=i%player_number+1)if(!is_dead(i)&&(is_fp(i)))
return i;
break;
}
case 'M':{
for(int i=id%player_number+1;i!=id;i=i%player_number+1)if(!is_dead(i)&&(is_fp(i)||player[i].Loyalty_or_opposition==2))
return i;
break;
}
case 'F':{
for(int i=id%player_number+1;i!=id;i=i%player_number+1)if(!is_dead(i)){
if(i==MP){
if(!is_f) return can_use_k(id,MP)?MP:-1;
else return MP;
}else if(is_zp(i)) return i;
}
break;
}
}
return -1;
}
void attack(int id){
if(game_end())return;
int i;
if(player[id].has_z==1){
while(can_use_k(id,select_aim(id,0)))
{
//use kiil
use_k(id,select_aim(id,0));
}
}else{
if(can_use_k(id,select_aim(id,0)))
{
//use kiil
use_k(id,select_aim(id,0));
}
}
while(can_use(id,'F')&&select_aim(id,1)!=-1){
//use 决斗
use_f(id,select_aim(id,1));
}
while(can_use(id,'N')){
//use 南蛮入侵
use_n(id);
}
while(can_use(id,'W')){
//use 万箭齐发
use_w(id);
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化