📄 compute.c
字号:
#include "derivative.h" /* include peripheral declarations */
#include <stdlib.h>
#include "global.h"
#include <math.h>
#include <float.h>
#include "ISD4002.h"
#define MAX_MACHINE_FAIL (100)
extern long long Machine_Total_Win;
extern long long Gamer_Total_Win;
unsigned int i_rand;
static unsigned int WinFailDrawTable[10][2] = { {0,0},
{50000,60000}, {10000,20000}, {100,200}, {100,30000}, {10922,21844},
{10000,30000}, {10000,30000}, {10000,15000}, {10000,20000} };
byte Compute_GameResult(byte input, byte count, byte *mac_output, byte IsRandOut)
{
byte output_order[3];
/*
if(IsRandOut)
{
i_rand = 2*rand();
}
else
{
i_rand = TPM2CNT; // TPM2MOD = 0xFFFF;
}
*/
i_rand = 2*rand();
if(Gamer_Total_Win-Machine_Total_Win >= MAX_MACHINE_FAIL)
{
if( input == CINKER )
{
*mac_output = CLOTH;
}
else if( input == CUT )
{
*mac_output = CINKER;
}
else
{
*mac_output = CUT;
}
return GAME_FAIL;
}
if( input == CINKER )
{
output_order[0] = CLOTH;
output_order[1] = CUT;
output_order[2] = CINKER;
}
else if( input == CUT )
{
output_order[0] = CINKER;
output_order[1] = CLOTH;
output_order[2] = CUT;
}
else
{
output_order[0] = CUT;
output_order[1] = CINKER;
output_order[2] = CLOTH;
}
if(i_rand <= WinFailDrawTable[count][0])
{
*mac_output = output_order[0];
return GAME_FAIL;
}
else if(i_rand <= WinFailDrawTable[count][1])
{
*mac_output = output_order[1];
return GAME_WIN;
}
else
{
// machine
*mac_output = output_order[2];
return GAME_EVEN;
}
}
#define DATALENGTH 65535
#define DIPSW 9 //等于拨码开关的值
float drawRate[9]={0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6};
float coinReturnRateForRound[9];
float machineWinRateForRound[9];
float totalCoinOutToInRatio[9]={0.97, 0.94, 0.91, 0.88, 0.84, 0.81, 0.78, 0.75, 0.72};
//float winFailDrawTable[9][2];
float coinInOutSet[9][2]={{1,2}, {2,4}, {3,6}, {4,8}, {5,10}, {6,15}, {7,20}, {8,30}, {9,50}} ;
// test
unsigned int test[100];
void compute_win_rate()
{
byte i;
for(i=0; i<9; i++)
{
coinReturnRateForRound[i] = (coinInOutSet[i][0])/(coinInOutSet[i][1]);
machineWinRateForRound[i] = (1-coinReturnRateForRound[i]*totalCoinOutToInRatio[DIPSW])*(1-drawRate[i]); //right
//machineWinRateForRound[i] = coinReturnRateForRound[i]*(1-totalCoinOutToInRatio[DIPSW])*(1-drawRate[i]); //wrong
WinFailDrawTable[i+1][0] = (machineWinRateForRound[i]*DATALENGTH);
WinFailDrawTable[i+1][1] = (DATALENGTH*(1-drawRate[i]));
}
/*
for(i=0; i<100; i++)
{
test[i] = 2*rand();
}
while(1);
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -