麻将游戏算法深入理会及实当代码
发布时间:2020-12-31 21:47:41 所属栏目:创业 来源:网络整理
导读:麻将游戏算法深入理会及实当代码 这两天为了器材箱的完美,清算了这些年引擎开拓的一些资料,有时中发明06年写的一个麻将算法,编译运行了一下,照旧有点意思的,拿出来清算一下分享给各人。 麻将是一种各人最喜欢的娱乐勾当之一,信托全部人都有打仗过。我
OUTPai2:
cout<<"请打牌(输入牌序号)";
int PaiIndex;
cin>>PaiIndex;
if(t_MyPlayer.DelPai(PaiIndex)==false)
{
cout<<"没有此牌"<<endl;
goto OUTPai2;
}
//=================================牌面革新=============================================
cout<<"牌面革新============================"<<endl;
t_MyPlayer.PrintAllPai();
cout<<endl;
//==============================================================================
//======================包听========================================================
if(t_MyPlayer.CheckAllPai(MJPAI_PUTPAI))
{
char t_BTing;
cout<<"要包听吗?:(Y/N)";
cin>>t_BTing;
if(t_BTing=='y'||t_BTing=='Y')
{
t_Ting = true;
}
}
//==============================================================================
//该我下家
j = -1;
}
else if(t_Result =='2')//碰牌
{
t_MyPlayer.PrintPengChosePai();
t_MyPlayer.DoPengPai(t_Pai2.m_NewPai.m_Type,t_Pai2.m_NewPai.m_Value);
//==============================================================================
cout<<"牌面革新============================"<<endl;
t_MyPlayer.PrintAllPai();
cout<<endl;
//==============================================================================
OUTPai3:
cout<<"请打牌(输入牌序号)";
int PaiIndex;
cin>>PaiIndex;
if(t_MyPlayer.DelPai(PaiIndex)==false)
{
cout<<"没有此牌"<<endl;
goto OUTPai3;
}
//==========================牌面革新====================================================
cout<<"牌面革新============================"<<endl;
t_MyPlayer.PrintAllPai();
cout<<endl;
//==============================================================================
//======================包听========================================================
if(t_MyPlayer.CheckAllPai(MJPAI_PUTPAI))
{
char t_BTing;
cout<<"要包听吗?:(Y/N)";
cin>>t_BTing;
if(t_BTing=='y'||t_BTing=='Y')
{
t_Ting = true;
}
}
//==============================================================================
j = -1;
}
else if(t_Result =='3')//杠牌
{
t_MyPlayer.PrintGangChosePai();
t_MyPlayer.DoGangPai(t_Pai2.m_NewPai.m_Type,t_Pai2.m_NewPai.m_Value);
cout<<"起杠底牌"<<endl;
t_MyPlayer.AddPai(t_Pai2.m_NewPai.m_Type,t_Pai2.m_NewPai.m_Value);
//==============================================================================
cout<<"牌面革新============================"<<endl;
t_MyPlayer.PrintAllPai();
cout<<endl;
//==============================================================================
stPAIEx t_Pai2 = t_MJManage.GetAPai();
//起牌后胡牌判定
t_Finish = t_MyPlayer.CheckAllPai(MJPAI_GETPAI);
if(t_Finish)
{
cout<<"杠底花吗?(Y/N)"<<endl;
char t_Result;
cin>>t_Result;
if(t_Result =='Y'||t_Result=='y')
{
cout<<endl;
printf("胡啦!!!:%s-%d",t_MyPlayer.GetInfo()->m_GoodValue);
t_Score += t_MyPlayer.GetInfo()->m_GoodValue;
::_sleep(1000);
break;
}
}
if(t_Pai2.m_IsHZ)//假如起牌数已到达上限
{
cout<<"黄庄了!!!!!!!!!!!!!"<<endl;
t_Finish = true;
break;
}
OUTPai4:
cout<<"请打牌(输入牌序号)";
int PaiIndex;
cin>>PaiIndex;
if(t_MyPlayer.DelPai(PaiIndex)==false)
{
cout<<"没有此牌"<<endl;
goto OUTPai4;
}
//===========================牌面革新===================================================
cout<<"牌面革新============================"<<endl;
t_MyPlayer.PrintAllPai();
cout<<endl;
//==============================================================================
//======================包听========================================================
if(t_MyPlayer.CheckAllPai(MJPAI_PUTPAI))
{
char t_BTing;
cout<<"要包听吗?:(Y/N)";
cin>>t_BTing;
if(t_BTing=='y'||t_BTing=='Y')
{
t_Ting = true;
}
}
//==============================================================================
//该我下家
j = -1;
}
else if(t_Result =='4')//胡牌
{
//起牌
t_MyPlayer.AddPai(t_Pai2.m_NewPai.m_Type,t_Pai2.m_NewPai.m_Value);
//起牌后胡牌判定
t_Finish = t_MyPlayer.CheckAllPai(MJPAI_GETPAI);
if(t_Finish)
{
printf("胡啦!!!:%s-合计%d番",t_MyPlayer.GetInfo()->m_GoodValue);
t_Score += t_MyPlayer.GetInfo()->m_GoodValue;
::_sleep(1000);
break;
}
else
{
if(t_Pai2.m_IsHZ)//假如起牌数已到达上限
{
cout<<"黄庄了!!!!!!!!!!!!!"<<endl;
t_Finish = true;
break;
}
//起牌
int iPaiIndex = t_MyPlayer.GetPaiIndex(t_Pai2.m_NewPai.m_Type,t_Pai2.m_NewPai.m_Value);
cout<<endl;
t_MyPlayer.DelPai(iPaiIndex);
}
}
}
}
cout<<"我的分数:"<<t_Score<<endl;
::_sleep(3000);
goto GameStart;//从头开始一局
return 0;
}
OK,麻迁就这样实现了,你可以将其恣意修改一下变形成你喜好的麻将游戏,我很开心这个代码能再次抖擞芳华,在此感谢你。 (编辑:湖南网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |

