zoukankan      html  css  js  c++  java
  • 龙虎斗控制

    //	int代表一张牌, 
    //	低16位代表牌的数字	1-13 A-K
    //	高16位代表花色		1-4	 黑红梅方	
    class  PokerInfo
    {
    public:
    	PokerInfo();
    	~PokerInfo();
    
    	void			clear();
    	
    	void			RandomPoker();
    	void			randPokerType(bool notSameType = false);
    	void			randPokerPoint(INT32 index);
    
    	INT32			GetLongPoker() { return m_longPoker; }
    	INT32			GetHuPoker() { return m_huPoker; }
    
    	INT32			GetLongPokerPoint() { return m_longPoker & 0xFFFF; }
    	INT32			GetHuPokerPoint() { return m_huPoker & 0xFFFF; }
    
    	void			SetLHDInfo(INT64 longGold, INT64 heGold, INT64 huGold);
    
    private:
    	INT32			m_longPoker;
    	INT32			m_huPoker;
    
    	INT64			m_allLongGold;
    	INT64			m_allHuGold;
    	INT64			m_allHeGold;
    };
    
    PokerInfo::PokerInfo()
    {
    	m_longPoker = 0;
    	m_huPoker = 0;
    	m_allLongGold = 0;
    	m_allHuGold = 0;
    	m_allHeGold = 0;
    }
    
    PokerInfo::~PokerInfo(){}
    
    void	PokerInfo::clear()
    {
    	m_longPoker = 0;
    	m_huPoker = 0;
    }
    
    
    void	PokerInfo::SetLHDInfo(INT64 longGold, INT64 heGold, INT64 huGold)
    {
    	m_allLongGold = longGold;
    	m_allHuGold = huGold;
    	m_allHeGold = heGold;
    }
    
    void	PokerInfo::randPokerType(bool notSameType)
    {
    	INT32	pokerTypeLong = rand() % 4 + 1;
    	INT32	pokerTypeHu = rand() % 4 + 1;
    	if (notSameType) {
    		while (pokerTypeLong == pokerTypeHu) {
    			pokerTypeHu = rand() % 4 + 1;
    		}
    	}
    	
    	m_longPoker = m_longPoker & 0xFFFF;
    	m_huPoker = m_huPoker & 0xFFFF;
    
    	m_longPoker = m_longPoker + (pokerTypeLong << 16);
    	m_huPoker = m_huPoker + (pokerTypeHu << 16);
    }
    
    void	PokerInfo::randPokerPoint(INT32 index)
    {
    	INT32	pokerLongPoint = 0;
    	INT32	pokerHuPoint = 0;
    
    	while (true)
    	{
    		pokerLongPoint = rand() % 13 + 1;
    		pokerHuPoint = rand() % 13 + 1;
    
    		if (index == 1) {
    			if (pokerLongPoint > pokerHuPoint) {
    				break;
    			}
    		}
    		else if (index == 2) {
    			pokerLongPoint = pokerHuPoint;
    			break;
    		}
    		else {
    			if (pokerLongPoint < pokerHuPoint) {
    				break;
    			}
    		}
    	}
    	
    	m_longPoker = m_longPoker & 0xFFFF0000;
    	m_huPoker = m_huPoker & 0xFFFF0000;
    
    	m_longPoker = m_longPoker + pokerLongPoint;
    	m_huPoker = m_huPoker + pokerHuPoint;
    }
    
    void	PokerInfo::RandomPoker()
    {
    	clear();
    	
    	randPokerPoint(1);
    
    	randPokerType();
    }
    

      

    根据控制确定

    void	CGSGameRoom::RandomPoker()
    {
    	m_pokerInfo.clear();
    	INT32	result = ClacResult();  //根据控制计算龙和虎那个牌大
    	m_pokerInfo.randPokerPoint(result);
    	m_pokerInfo.randPokerType(result == 2 ? true : false);
    	
    	m_awardRecords.push_back(result);
    	while (m_awardRecords.size() > 18) {
    		m_awardRecords.erase(m_awardRecords.begin());
    	}
    
    }
    

     

    策略是根据血池和玩家下注配牌的,没有人押注系统随机发牌 8:1:8

    INT32	CGSGameRoom::ClacResult()
    {
    	INT32	plan = 0;
    
    	if (0 == g_cGSGameHallInstance.SelectPlan(4, plan)) {  //选择具体策略
    		WYYTools_LogMgr->Warning("CGSGameRoom::ClacResult select plan = 0");
    	}
    
    	INT64	n64AllSumGolds = 0;
    	INT64	n64AllTigerGolds = 0;
    	INT64	n64AllDragonGolds = 0;
    
    	for (auto iter = m_GameUserBets.begin(); iter != m_GameUserBets.end(); iter++)
    	{
    		if ( UserIDInRobotVec(iter->first) )
    		{
    			continue;
    		}
    		n64AllSumGolds += iter->second.sumGolds;
    		n64AllTigerGolds += iter->second.tigerGolds;
    		n64AllDragonGolds += iter->second.dragonGolds;
    	}
    
    	INT64	n64AllGolds = n64AllSumGolds + n64AllTigerGolds + n64AllDragonGolds;
    	INT64	planGolds = n64AllGolds  * plan / 10000;
    
    
    	INT64	allWinDragonGolds = n64AllDragonGolds + n64AllDragonGolds;
    	INT64	allWinTigerGolds = n64AllTigerGolds + n64AllTigerGolds;
    	INT64	allWinSumGolds = n64AllSumGolds * 9 + n64AllDragonGolds + n64AllTigerGolds;
    
    	if (allWinDragonGolds == 0 && allWinTigerGolds == 0 && allWinSumGolds== 0) 
    	{
    		INT32	randIcon = rand() % 17;
    		if (randIcon < 8) {
    			return 1;
    		}else if (randIcon == 8) {
    			return 2;
    		}else {
    			return 3;
    		}
    	}
    
    	INT64	absWinSumGolds = abs(allWinSumGolds - planGolds);
    	INT64	absWinDragonGolds = abs(allWinDragonGolds - planGolds);
    	INT64	absWinTigerGolds = abs(allWinTigerGolds - planGolds);
    
    	if (absWinDragonGolds <= absWinTigerGolds && absWinDragonGolds <= absWinSumGolds) {
    		return 1;
    	}
    
    	if (absWinSumGolds <= absWinDragonGolds && absWinSumGolds <= absWinTigerGolds) {
    		return 2;
    	}
    
    	if (absWinTigerGolds <= absWinDragonGolds && absWinTigerGolds <= absWinSumGolds) {
    		return 3;
    	}
    
    	return 1;
    }
    

      

    配置文件json:

     

    [{
        "threshold": 5000000,
        "info": [{
            "plan": 82000,
            "weights": 0
        }, {
            "plan": 60000,
            "weights": 0
        }, {
            "plan": 50000,
            "weights": 0
        }, {
            "plan": 30000,
            "weights": 0
        }, {
            "plan": 10000,
            "weights": 200
        }, {
            "plan": 9400,
            "weights": 300
        }, {
            "plan": 7500,
            "weights": 500
        }, {
            "plan": 6400,
            "weights": 1000
        }, {
            "plan": 4500,
            "weights": 1000
        }, {
            "plan": 3400,
            "weights": 500
        }, {
            "plan": 1500,
            "weights": 500
        }, {
            "plan": 0,
            "weights": 6000
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }]
    }, {
        "threshold": 8000000,
        "info": [{
            "plan": 82000,
            "weights": 0
        }, {
            "plan": 60000,
            "weights": 0
        }, {
            "plan": 50000,
            "weights": 100
        }, {
            "plan": 25000,
            "weights": 200
        }, {
            "plan": 10000,
            "weights": 1500
        }, {
            "plan": 9400,
            "weights": 500
        }, {
            "plan": 7500,
            "weights": 500
        }, {
            "plan": 6400,
            "weights": 600
        }, {
            "plan": 4500,
            "weights": 600
        }, {
            "plan": 3400,
            "weights": 2000
        }, {
            "plan": 1500,
            "weights": 2500
        }, {
            "plan": 0,
            "weights": 1500
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }]
    }, {
        "threshold": 10000000,
        "info": [{
            "plan": 82000,
            "weights": 100
        }, {
            "plan": 60000,
            "weights": 200
        }, {
            "plan": 50000,
            "weights": 200
        }, {
            "plan": 30000,
            "weights": 400
        }, {
            "plan": 10000,
            "weights": 1200
        }, {
            "plan": 9400,
            "weights": 300
        }, {
            "plan": 7500,
            "weights": 500
        }, {
            "plan": 6400,
            "weights": 800
        }, {
            "plan": 4500,
            "weights": 800
        }, {
            "plan": 3400,
            "weights": 2000
        }, {
            "plan": 1500,
            "weights": 2500
        }, {
            "plan": 0,
            "weights": 1000
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }]
    }, {
        "threshold": 15000000,
        "info": [{
            "plan": 82000,
            "weights": 100
        }, {
            "plan": 60000,
            "weights": 400
        }, {
            "plan": 50000,
            "weights": 400
        }, {
            "plan": 34000,
            "weights": 500
        }, {
            "plan": 12000,
            "weights": 800
        }, {
            "plan": 9000,
            "weights": 500
        }, {
            "plan": 8100,
            "weights": 500
        }, {
            "plan": 7200,
            "weights": 800
        }, {
            "plan": 5500,
            "weights": 1000
        }, {
            "plan": 3500,
            "weights": 2000
        }, {
            "plan": 2200,
            "weights": 2000
        }, {
            "plan": 0,
            "weights": 1000
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }]
    }, {
        "threshold": 20000000,
        "info": [{
            "plan": 82000,
            "weights": 400
        }, {
            "plan": 60000,
            "weights": 400
        }, {
            "plan": 50000,
            "weights": 400
        }, {
            "plan": 34000,
            "weights": 600
        }, {
            "plan": 12000,
            "weights": 800
        }, {
            "plan": 9000,
            "weights": 400
        }, {
            "plan": 8100,
            "weights": 400
        }, {
            "plan": 7200,
            "weights": 800
        }, {
            "plan": 5500,
            "weights": 1000
        }, {
            "plan": 3500,
            "weights": 1800
        }, {
            "plan": 2200,
            "weights": 2000
        }, {
            "plan": 0,
            "weights": 1000
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }]
    }, {
        "threshold": 25000000,
        "info": [{
            "plan": 100000,
            "weights": 500
        }, {
            "plan": 90000,
            "weights": 500
        }, {
            "plan": 80000,
            "weights": 1000
        }, {
            "plan": 70000,
            "weights": 500
        }, {
            "plan": 55000,
            "weights": 1000
        }, {
            "plan": 40000,
            "weights": 500
        }, {
            "plan": 30000,
            "weights": 500
        }, {
            "plan": 20000,
            "weights": 1000
        }, {
            "plan": 15000,
            "weights": 500
        }, {
            "plan": 5000,
            "weights": 500
        }, {
            "plan": 2000,
            "weights": 500
        }, {
            "plan": 0,
            "weights": 1000
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }, {
            "plan": 0,
            "weights": 0
        }]
    }]
  • 相关阅读:
    nginx添加新模块
    nginx rewrite规则last与break的区别
    tomcat调优的几个方面
    Servlet 中文乱码问题及解决方案剖析
    Nginx 启动脚本/重启脚本
    Nginx的启动、停止、平滑重启
    轻量级HTTP服务器Nginx(配置与调试Nginx)
    Nginx配置文件详细说明
    提高Java代码质量的Eclipse插件之Checkstyle的使用详解
    你会用shuffle打乱列表吗?
  • 原文地址:https://www.cnblogs.com/hailong88/p/11045775.html
Copyright © 2011-2022 走看看