📄 suoha_algri.c
字号:
/********************************************************************************
$History: Suoha_algri.c
Date .................. Modification ......................................
08/14/2002 version 1.1.0 zhangzg
08/22/2002 version 1.1.2 zhangzg change the table of possibility
$End
*******************************************************************************/
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"
#else /* NEW_FRAME */
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif /* NEW_FRAME */
#include "mfw_sys.h"
//#include "stddefs.h"
#include "p_sim.h"
#include "cus_aci.h"
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_edt.h"
#include "mfw_tim.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_sat.h"
#include "dspl.h"
#include "MmiMmi.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiSoftkeys.h"
#include "MmiIcons.h"
#include "MmiMenu.h"
#include "gdi.h"
#include "Audio.h"
#include "MmiSounds.h"
#include "MmiBookShared.h"
//#include "Mmigame.h"
#include "suoha_algri.h"
//GW 14/09/01 Disable game when not required.
#ifdef MMIGAME
//
EXTERN UBYTE focus_opp;
/****************************************************************************
varibles definition
*****************************************************************************/
/*这些数组元素中的数的个位数加8之后即为牌的大小,
十位数中的1、2、3、4分别对应方片、草花、红桃、黑桃。*/
static unsigned short cards[28] = {10, 20, 30, 40,
11, 21, 31, 41,
12, 22, 32, 42,
13, 23, 33, 43,
14, 24, 34, 44,
15, 25, 35, 45,
16, 26, 36, 46};
/* 以下数组保存了三张概率表常量,表示机器行动(下注、退出、跟、下注的数量等)
的概率分布,Poss32表示已知己方三张牌,对手2张牌情况下的概率表,opp1表示对手1。下面类推*/
static unsigned char Poss32_opp1[11][5] = {10,30,60,100,0,
20,50,30,100,0,
0,30,70,100,0,
20,40,40,100,0,
70,20,10,70,30,
10,50,40,100,0,
30,60,10,100,0,
60,30,10,90,10,
80,20,0,60,40,
30,40,30,100,0,
30,40,30,100,0
};
static unsigned char Poss43_opp1[25][5] = {0,30,70,100,0,
0,60,40,100,0,//1
0,40,60,100,0,//2
0,20,80,100,0,//3
0,60,40,100,0,//4
90,10,0,10,90,//5
0,40,60,100,0,//6
0,60,40,100,0,//7
0,30,70,100,0,//8
90,10,0,0,100,//9
90,10,0,0,100,//10
10,50,40,100,0,//11
20,50,30,100,0,//12
0,40,60,100,0,//13
100,0,0,0,100,//14
100,0,0,0,100,//15
20,60,20,100,0,//16
90,10,0,90,10,//17
10,50,40,100,0,//18
30,50,20,100,0,//19
100,0,0,0,100,//20
90,10,0,50,50,//21
100,0,0,100,0,//22
30,50,20,100,0,//23
70,20,10,100,0//24
};
//this is a common array for opp1,opp2,opp3!!
static unsigned char Poss54[26][5] = {0,20,80,100,0,//0
0,20,80,100,0,//1
0,30,70,100,0,//2
0,30,70,100,0,//3
0,70,30,100,0,//4
0,30,70,100,0,//5
0,40,60,100,0,//6
10,60,30,100,0,//7
0,30,70,100,0,//8
0,40,60,100,0,//9
10,60,30,100,0,//10
0,30,70,100,0,//11
10,50,40,100,0,//12
20,60,20,100,0,//13
0,30,70,100,0,//14
20,60,20,100,0,//15
0,30,70,100,0,//16
20,60,40,100,0,//17
20,60,40,100,0,//18
30,60,20,100,0,//19
0,30,70,100,0,//20
90,10,0,0,100,//21
20,60,20,100,0,//22
0,30,70,100,0,//23
20,50,30,100,0,//24
30,50,20,100,0//25
};
static unsigned char Poss32_opp2[11][5]={
10, 30, 60, 100, 0,
20, 30, 50, 100, 0,
0, 10, 90, 100, 0,
20, 30, 50, 100, 0,
40, 50, 10, 100, 0,
10, 30, 60, 100, 0,
10, 70, 20, 100, 0,
20, 70, 10, 90, 10,
60, 40, 0, 90, 10,
10, 60, 30, 100, 0,
20, 50, 30, 100, 0
};
static unsigned char Poss43_opp2[25][5]={
0, 30, 70, 100, 0,
0, 30, 70, 100, 0,
0, 10, 90, 100, 0,
0, 10, 90, 100, 0,
0, 40, 60, 100, 0,
80, 20, 0, 60, 40,
0, 60, 40, 100, 0,
0, 60, 40, 100, 0,
0, 30, 70, 100, 0,
30, 70, 0, 80, 20,
80, 20, 0, 20, 80,
10, 50, 40, 100, 0,
20, 50, 30, 100, 0,
0, 40, 60, 100, 0,
40, 60, 0, 80, 20,
100, 0, 0, 20, 80,
20, 40, 40, 100, 0,
40, 60, 0, 90, 10,
10, 40, 50, 100, 0,
10, 50, 40, 100, 0,
100, 0, 0 ,20, 80,
40, 60, 0 , 90, 10,
100, 0 , 0 , 80, 20,
30, 50 , 20, 100, 0,
30, 60 , 10, 100, 0
};
static unsigned char Poss32_opp3[11][5]={
10 , 50, 40 , 100, 0,
40 , 50 , 10 , 100, 0,
0 ,50 , 50, 100 , 0,
40 , 40 , 20 , 100, 0,
70 , 30 , 0 , 70 , 30,
50 , 50 , 0 , 100 , 0,
60, 40 ,0 , 80 , 20,
60, 30, 10, 70, 30,
80, 20, 0, 40, 60,
30, 50, 20, 100, 0,
40, 50, 10, 100, 0
};
static unsigned char Poss43_opp3[25][5]={
0, 50 , 50, 100 , 0,
0 , 60 , 40 , 100 , 0,
0 , 40 , 60 , 100 , 0,
0 , 50, 50 , 100 ,0,
0 , 60, 40 ,100, 0,
90 , 10 , 0 , 10 , 90,
0 , 50 , 50 , 100 , 0,
30, 60 , 10 , 100 , 0,
0, 40 , 60, 100 , 0,
90 ,10, 0 ,10 , 90,
90 , 10 , 0 ,10 , 90,
10 , 60 , 30 ,100, 0,
30 , 50 , 20 ,100, 0,
0 , 50 , 50 ,100, 0,
100 ,0, 0 ,80, 20 ,
100 ,0 , 0 , 0, 100,
30 , 60 , 10 , 100, 0,
90 , 10 , 0 , 90, 0,
40 , 50 , 10, 100, 0,
60, 40 , 0, 100, 0,
100, 0 , 0, 0 , 100,
90 , 10 , 0 , 90 , 10,
100 , 0 , 0 , 100, 0,
40 , 50 , 10 , 100, 0,
70 , 20, 10 ,100, 0
};
/* c_Cards保存机器手中的五张牌,p_Cards保存对手手中的五张牌*/
unsigned short c_Cards[5] = {0, 0, 0, 0, 0};
unsigned short p_Cards[5] = {0, 0, 0, 0, 0};
//int c_Two, c_Three, c_Four, c_Five;
//int p_Two, p_Three, p_Four, p_Five;
//int p_CStake,c_CStake;//the current stake the player and computer chip in
unsigned long desk_Stake;//4桌上总共的筹码;
unsigned long p_Stake, c_Stake;//4分别为对手和机器手中剩余的筹码
unsigned long p_M = PIM; //4 对手最初的筹码
unsigned long c_M = CIM; //4 机器最初的筹码
unsigned long p_PreviousM;//4 玩家前一局手中的筹码
unsigned long c_PreviousM;//4 机器前一局手中的筹码
unsigned long p_CurrStake=0, c_CurrStake=0, desk_CurrStake=0; //4 当前下的注
unsigned short curr_CardTh=0;//4 玩家和机器当前手中牌的数量,最多为5张
unsigned short turnPlayerorComputer=0; //4轮到谁下注
CardType SetDifficult;
extern unsigned long casenum;
/* //4好像每用上
CardType p1_Ct, c1_Ct,
p2_Ct, c2_Ct,
p3_Ct, c3_Ct, //4 curr_CardTh=3时,保存对手和玩家的牌型
p4_Ct, c4_Ct,
p5_Ct, c5_Ct;
*/
/****************************************************************************************
function definition
*****************************************************************************************/
void ShuffleCards();
void SendCards();
unsigned short FirstNum(unsigned short onecard); //返回一张牌的大小
unsigned short SecondNum(unsigned short onecard); //返回一张牌的花色
CardType Status_Two(unsigned short* whoCards);
CardType Status_Three(CardType twoStatus, unsigned short* whoCards);
CardType Status_Four(CardType threeStatus, unsigned short* whoCards);
CardType Status_Five(CardType fourStatus, unsigned short* whoCards);
//CardType GetLiangDui(int* whoCards);
//CardType GetDuiZi(int* whoCards);
CardType ClassifyShanPai(unsigned short* whoCards); //分类"散牌",这里散牌指的是五张牌中任何两张均不相同,因此还可能为同花、顺子、散牌等情况
unsigned long Two_Greater(CardType c_CT, unsigned short turnwho);
unsigned long Three_Greater(CardType c_CT, CardType p_CT, unsigned short turnwho);
unsigned long Three_Greater_Opp1(CardType c_CT, CardType p_CT, unsigned short turnwho, unsigned long pMoney); //zhangzg 08/23/2002
unsigned long Four_Greater_Opp1(CardType c_CT, CardType p_CT, unsigned short turnwho, unsigned long pMoney);//zhangzg 08/23/2002
unsigned long Four_Greater(CardType c_CT, CardType p_CT, unsigned short turnwho);
unsigned long Five_Greater(CardType c_CT, CardType p_CT, unsigned short turnwho);
unsigned short CompareTwo(unsigned short card1, unsigned short card2);
CardType CompareCards(CardType p_CardType, CardType c_CardType);
/////////////////////////////////////////////////
unsigned short Produce3Poss(unsigned char a1, unsigned char a2, unsigned char a3);
unsigned short Produce2Poss(unsigned char a1, unsigned char a2);
unsigned long ClassifyStake(unsigned short cardsnum, unsigned short classnum);
unsigned long ClassifyFollorQuit(unsigned short cardnum, unsigned short classnum);
CardType Stake_Two(unsigned short *whoCards);
CardType Stake_Three(CardType twoStatus, unsigned short *whoCards);
CardType Stake_Four(CardType threeStatus, unsigned short *whoCards);
void Set_Suohadifficulty();
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void ShuffleCards()
{
int b; UBYTE a[100]; USHORT i, j, k, c;
srand( (unsigned)rvf_get_tick_count() );
for ( i = 0; i < 100; i++ )
{
b = rand();
a[i] = b-(b/28)*28;
}
for (i = 0; i<99; i++)
{
c = cards[a[i]];
cards[a[i]] = cards[a[i+1]];
cards[a[i+1]] = c;
}
//shuffle
b = rand();
for (i=0; i<(b%50); i++)
{
for (j=0; j<=a[i]; j++)
{
c = cards[0];
for (k = 1; k<=27; k++)
{
cards[k-1] = cards[k];
}
cards[27] = c;
}
}
}
void SendCards()
{
int i, j, k;
j = k = 0;
for (i = 0; i<10; i++)
{
if ((i-(i/2)*2)==0)
{
p_Cards[j] = cards[i];
j++;
} else
{
c_Cards[k] = cards[i];
k++;
}
}
/* //add for test
switch(casenum)
{
case 0:
p_Cards[0]=11;
p_Cards[1]=20;
p_Cards[2]=10;
p_Cards[3]=35;
p_Cards[4]=25;
c_Cards[0]=10;
c_Cards[1]=32;
c_Cards[2]=22;
c_Cards[3]=12;
c_Cards[4]=14;
break;
case 1:
p_Cards[0]=10;
p_Cards[1]=11;
p_Cards[2]=12;
p_Cards[3]=34;
p_Cards[4]=14;
c_Cards[0]=21;
c_Cards[1]=22;
c_Cards[2]=23;
c_Cards[3]=24;
c_Cards[4]=25;
break;
case 2:
p_Cards[0]=10;
p_Cards[1]=11;
p_Cards[2]=33;
p_Cards[3]=13;
p_Cards[4]=14;
c_Cards[0]=21;
c_Cards[1]=22;
c_Cards[2]=23;
c_Cards[3]=42;
c_Cards[4]=25;
break;
case 3:
p_Cards[0]=10;
p_Cards[1]=11;
p_Cards[2]=33;
p_Cards[3]=13;
p_Cards[4]=14;
c_Cards[0]=21;
c_Cards[1]=22;
c_Cards[2]=35;
c_Cards[3]=45;
c_Cards[4]=25;
break;
case 4:
p_Cards[0]=10;
p_Cards[1]=11;
p_Cards[2]=33;
p_Cards[3]=13;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -