• 欢迎访问小杰博客网站
  • 欢迎访问小杰博客网站哦

【小杰体育彩票】软件模拟体育彩票投注的利润和风险(php)

未分类 小杰 4年前 (2015-03-01) 124次浏览 未收录 0个评论

今天小杰心血来潮,写了模拟投注体育彩票赢了-1,输了+1的研究代码,来模拟利润和风险的关系,先上代码,报告后面贴上:

注:主要是风险的模型要优化下!

<?php

//$game_results[] = array(‘one’=>1,’two’=>1,’total’=>0);
//$game_results[] = array(‘one’=>1,’two’=>0,’total’=>1);
//$game_results[] = array(‘one’=>0,’two’=>0,’total’=>0);

$caipiaoMethod = new caipiaoMethod;
//$game_results = $caipiaoMethod->get_C32_game_results();
//var_dump(‘get_odd_C32_game_result’);
//$caipiaoMethod->get_odd_C32_and_fill_game_result($game_results);
//$caipiaoMethod->get_odd_C32_game_result($game_results);

$game_results = $caipiaoMethod->get_single_game_results();

$caipiaoMethod->get_single_game_result($game_results);

class caipiaoMethod {
function get_single_game_results() {
$game_results = array();
$count = 1200;
$odd = $even = 0;
for($i=0;$i<$count;$i++) {
$one = rand(1,100)%2;
$game_results[] = $one;
if($one) {
$odd++;
}else {
$even++;
}
}
var_dump(‘胜:’);var_dump($odd);
var_dump(‘负:’);var_dump($even);
var_dump(‘胜率:’);var_dump($odd/$count);

return $game_results;
}

function get_C32_game_results() {
$game_results = array();
$count = 1200;
for($i=0;$i<$count;$i++) {
$one = rand(1,100)%2;
$two = rand(1,100)%2;
$total = ($one+$two)%2;

$game = array();
$game[‘one’] = $one;
$game[‘two’] = $two;
$game[‘total’] = $total;
$game_results[] = $game;
}

return $game_results;
}

function get_format_game_results($game_results,$num) {
$count = 1;
$datas = array();
$data = array();
foreach($game_results as $game_result) {
$data[] = $game_result;
if($count % $num == 0) {
$datas[] = $data;
$data = array();
}
$count++;
}

return $datas;
}

function get_odd_C32_and_fill_game_result($game_results) {

// 分组,3个随机数一组
// var_dump(‘before’);var_dump($game_results);
$game_results = caipiaoMethod::get_format_game_results($game_results,3);
// var_dump(‘after’);var_dump($game_results);
$total_win_money = 0;
foreach($game_results as $game_result) {
caipiaoMethod::get_single_odd_C32_and_fill_game_result($game_result,&$total_win_money);
}
}

function get_single_odd_C32_and_fill_game_result($game_results,&$total_win_money) {

$base_money = 9; // 本金
$get_money = 0; // 赢的钱
$win_count = 0;// 赢的盘数
foreach($game_results as $game_result) {
if($game_result[‘one’] == 1) {
$get_money += 1.9;
}
if($game_result[‘two’] == 1) {
$get_money += 1.9;
}
if($game_result[‘total’] == 1) {
$win_count ++;
}
}

if($win_count == 2) {
$get_money += 3.6;
}
if($win_count == 3) {
$get_money += 10.8;
}
$win_money = $get_money-$base_money;
var_dump($game_results);
$total_win_money += $win_money;
echo “base_money:”.$base_money.” get_money:”.$get_money.” win_money:”.$win_money.” total_win_money:”.$total_win_money.” win_count:”.$win_count.” \n”;

}

function get_odd_C32_game_result($game_results) {

// 分组,3个随机数一组
var_dump(‘before’);var_dump($game_results);
$game_results = caipiaoMethod::get_format_game_results($game_results,3);
var_dump(‘after’);var_dump($game_results);
$total_win_money = 0;
foreach($game_results as $game_result) {
caipiaoMethod::get_single_odd_C32_game_result($game_result,&$total_win_money);
}
}

function get_single_odd_C32_game_result($game_results,&$total_win_money) {

$base_money = 3; // 本金
$get_money = 0; // 赢的钱
$win_count = 0;// 赢的盘数
foreach($game_results as $game_result) {
if($game_result[‘total’] == 1) {
$win_count ++;
}
}

if($win_count == 2) {
$get_money += 3.6;
}
if($win_count == 3) {
$get_money += 10.8;
}
$win_money = $get_money-$base_money;
var_dump($game_results);
$total_win_money += $win_money;
echo “base_money:”.$base_money.” get_money:”.$get_money.” win_money:”.$win_money.” total_win_money:”.$total_win_money.” win_count:”.$win_count.” \n”;

}

// C32 输了+1,赢了-1
function get_single_odd_C32_v2_game_result($game_results,&$total_win_money,&$base_money,&$type=null) {

if(!isset($base_money)) {
$base_money = 3;
}
if($type==’add’) {
$base_money += 3;
} else if($type==’minus’) {
$base_money -= 3;
}

$get_money = 0; // 赢的钱
$win_count = 0;// 赢的盘数
foreach($game_results as $game_result) {
if($game_result[‘total’] == 1) {
$win_count ++;
}
}
if($win_count == 0 || $win_count == 1) {
$type=’add’;
}

if($win_count == 2) {
$get_money += 3.6;
$type=null;
}
if($win_count == 3) {
$get_money += 10.8;
$type=’minus’;
}
$win_money = $get_money-$base_money;
var_dump($game_results);
$total_win_money += $win_money;
echo “base_money:”.$base_money.” get_money:”.$get_money.” win_money:”.$win_money.” total_win_money:”.$total_win_money.” win_count:”.$win_count.” \n”;

if($base_money == 3 && $type==’minus’) {
$type = null;
}
}

function get_single_game_result($game_results) {

// 分组,1个随机数一组
var_dump(‘before’);var_dump($game_results);
$total_win_money = 0;
$base_money = 5;
$loop_total_win_money = 0;
$last_loop_pos = 0;
$all_over = false;// 标识投注结束时期
$the_top_num = 5;
foreach($game_results as $key=>$game_result) {
caipiaoMethod::get_single_v2_game_result($game_result,&$total_win_money,&$base_money,&$loop_total_win_money,&$last_loop_pos,$key,&$all_over,&$the_top_num);
}
}
// 单注输了+1,赢了-1
function get_single_v2_game_result($game_result,&$total_win_money,&$base_money,&$loop_total_win_money,&$last_loop_pos,$cur_loop_pos,&$all_over,&$the_top_num) {
$the_basic_money = 5;
$the_win_money_top = 10;
$get_money = 0;

if($all_over) {
var_dump(‘all over cur foot:’.$cur_loop_pos);
return false;
}

if(!isset($base_money)) {
$base_money = $the_basic_money;
}
$origin_base_money = $base_money;
// 输,1.11的系数是因为外围赔率1.9,要保证每次都能赢一个基本点5块
if($game_result == 0) {
$get_money -= $the_basic_money;
$win_money = -$base_money;
$total_win_money -= $base_money;
$loop_total_win_money -= $base_money;
$base_money = ($base_money+$the_basic_money)*1.11;

} else {
$get_money += $the_basic_money;
$win_money = $base_money;
$total_win_money += $base_money;
$loop_total_win_money += $base_money;
$base_money = $base_money/1.11 – $the_basic_money;
}

// 一轮结束
if($base_money <= $the_basic_money) {
var_dump(‘loop over’);
$base_money = $the_basic_money;
}

if($base_money > $the_top_num) {
$the_top_num = $base_money;
}

// 风险考虑,为了避免1.11效应把基数变大,当每个小圈盈利超过30时候,从5重新开始
if($loop_total_win_money >= $the_win_money_top) {
var_dump(‘$loop_total_win_money over:’);var_dump($loop_total_win_money);
var_dump(‘cur_pos:’);var_dump($cur_loop_pos);
var_dump(‘cost foot:’);var_dump($cur_loop_pos-$last_loop_pos);
$last_loop_pos = $cur_loop_pos;
$base_money = $the_basic_money;
$loop_total_win_money = 0;

// 以一次loop周期结束作为整个周期的结束
if($cur_loop_pos >= 1000) {
$all_over = true;
}
}

$message = “base_money:”.$origin_base_money.” next_base_money:”.$base_money.” get_money:”.$get_money.” win_money:”.$win_money.” loop_total_win_money:”.$loop_total_win_money.” total_win_money:”.$total_win_money.” is_win:”.$game_result.” the_top_num:”.$the_top_num.” loop count”.($cur_loop_pos-$last_loop_pos).” now foot:”.$cur_loop_pos.” \n”;
        var_dump($message);
}
}

?>


小杰博客 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:【小杰体育彩票】软件模拟体育彩票投注的利润和风险(php)
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址