/* AvoidObject A task to avoid objects. Whenever SonarSensor() returns true it will stop task follow(). It will turn left , the robot will then drive forward for a certain amount of rotations. The robot will turn right and stop. It will ask for input from SonarSensor(), while it returns true the robot will take small steps forward, turning and checking if the object is still there. If the object is cleared, the robot will take a small step forward to make sure its body width doesn't chip the object. It will do the same for the length of the object. If the robot clears the length of the object, it drives along the width of the object untill the line is found. When found, follow() is activated. */ task AvoidObject(){ stopTask(Follow); LeftTurnAxis(); wait1Msec(100); SetDistanceFwd(500,1500); Straight(0); wait1Msec(100); RightTurnAxis(); wait1Msec(100); Straight(0); wait1Msec(100); while(SonarSensor()){ LittleDriveForward(); wait1Msec(100); } if(!SonarSensor()){ TinyDriveForward(); wait1Msec(100); } SetDistanceFwd(1800,3500); Straight(0); wait1Msec(100); RightTurnAxis(); wait1Msec(100); while(SonarSensor()){ LittleDriveForward(); wait1Msec(100); } if(!SonarSensor()){ TinyDriveForward(); wait1Msec(100); } while((Convert(SensorValue[S3],minlight,maxlight) > 70) && (Convert(SensorValue[S4],mincolor,maxcolor) > 70)){ Straight(15); } nMotorEncoderTarget[motorB]=(nMotorEncoderTarget[motorC]=85); motor[motorB]=(motor[motorC]=-10); while((nMotorRunState[motorB] != runStateIdle) && (nMotorRunState[motorC] != runStateIdle)) wait1Msec(1); LeftTurn(); startTask(Follow); }
/* Stops the robot. Plays a sound. Makes the robot charge straight ahead untill it is either interrupted, the pressure sensor gets triggered or a certain amount of time has passed. */ void Charge(){ int ccounter = 0; Straight(0); playSoundFile("charge.rso"); wait1Msec(3000); Straight(100); while ((ccounter <2000)&&( s=="B")&& (SensorValue(S1)==0)){ ccounter ++; wait1Msec(1); CheckString(); } s = ""; Straight(0); }
int Straight_Flust(vector<int> & number,vector<int> & coler,HandleMsg *handlemsg) { //函数返回同花顺中最大的牌,若没有则返回0 vector<int>MyBufferNumber; int flust=Flust(coler); int straight,i; if(flust>=5)//同花 { if(coler.size() ==5) straight=Straight(number); else if(coler.size() ==6) { for( i=0;i<=1;i++) if(handlemsg->holdCard[i].color ==coul) MyBufferNumber.push_back(handlemsg->holdCard[i].num ); for(i=0;i<3;i++) if(handlemsg->flopCard[i].color ==coul) MyBufferNumber.push_back(handlemsg->flopCard[i].num); if(handlemsg->turnCard.color==coul) MyBufferNumber.push_back(handlemsg->turnCard.num); sort(MyBufferNumber.begin(),MyBufferNumber.end()); straight=Straight(MyBufferNumber); } else { for( i=0;i<=1;i++) if(handlemsg->holdCard[i].color ==coul) MyBufferNumber.push_back(handlemsg->holdCard[i].num); for(i=0;i<3;i++) if(handlemsg->flopCard[i].color ==coul) MyBufferNumber.push_back(handlemsg->flopCard[i].num); if(handlemsg->turnCard.color==coul) MyBufferNumber.push_back(handlemsg->turnCard.num); if(handlemsg->riverCard.color ==coul) MyBufferNumber.push_back(handlemsg->riverCard.num); sort(MyBufferNumber.begin(),MyBufferNumber.end()); straight=Straight(MyBufferNumber); } return straight; } else//不是同花顺 return 0; }
//************************************************** // NAME: Straight // DESCRIPTION: Robot goes straight forward // PARAMETERS: - speed->Motors speed // - distance->Distance //************************************************** void Motor::Straight(byte speed, int distance) { unsigned long time,timeout; int count; byte encoder; ReduceInertia(); count = distance/ENCODER_DISTANCE; encoder = digitalRead(ENC_R); time=millis(); Straight(speed); while (count > 0) { while (encoder == digitalRead(ENC_R)) { timeout=millis(); if (timeout - time > MAX_TIMEOUT) { return; } } encoder=digitalRead(ENC_R); count--; time=millis(); } ReduceInertia(); }
int score(int color){ int outScore=0; if (outScore==0) { outScore = StraightFlush(color); outScore += (outScore>0?8*15:0); //cout << "os8:" << outScore << endl; } if (outScore==0) { outScore = FourOfAKind(color); outScore += (outScore>0?7*15:0); //cout << "os7:" << outScore << endl; } if (outScore==0) { outScore = FullHouse(color); outScore += (outScore>0?6*15:0); //cout << "os6:" << outScore << endl; } if (outScore==0) { outScore = Flush(color); outScore += (outScore>0?5*15:0); //cout << "os5:" << outScore << endl; } if (outScore==0) { outScore = Straight(color); outScore += (outScore>0?4*15:0); //cout << "os4:" << outScore << endl; } if (outScore==0) { outScore = ThreeOfAKind(color); outScore += (outScore>0?3*15:0); //cout << "os3:" << outScore << endl; } if (outScore==0) { outScore = TwoPair(color); outScore += (outScore>0?2*15:0); //cout << "os2:" << outScore << endl; } if (outScore==0) { outScore = Pair(color); outScore += (outScore>0?1*15:0); //cout << "os1:" << outScore << endl; } if (outScore==0) { outScore = highCard(color); outScore += (outScore>0?0*15:0); //cout << "os0:" << outScore << endl; } return outScore; }
/* TinyDriveForward() A function that makes the robot do a standard move. In this case it turns left, followed by a very short distance straight and finally it turns right again. This function is used by AvoidObject, mostly to make sure the robot gets a little bit extra space between itself and the object its trying to clear. */ void TinyDriveForward(){ LeftTurnAxis(); wait1Msec(100); nMotorEncoderTarget[motorB]=(nMotorEncoderTarget[motorC]=250); motor[motorB]=15; motor[motorC]=15; wait1Msec(1300); Straight(0); wait1Msec(100); RightTurnAxis(); wait1Msec(100); }
/* LittleDriveForward() A function that makes the robot do a standard move. In this case it turns left, followed by a short distance straight and finally it turns right again. This function is used by AvoidObject. It is mostly used to clear bigger objects and get into a position to ask for input from SonarSensor() again. */ void LittleDriveForward(){ LeftTurnAxis(); wait1Msec(100); nMotorEncoderTarget[motorB]=(nMotorEncoderTarget[motorC]=450); motor[motorB]=15; motor[motorC]=15; wait1Msec(2000); Straight(0); wait1Msec(100); RightTurnAxis(); wait1Msec(100); }
// Brake that lets te robot just go straigt while braking. int EmergencyBrake( int speed){ int i; while(speed >0){ i++; if(i % 20 == 0 ){ speed--; Straight(speed); } wait1Msec(1); } return speed; }
std::vector<Card> Hand::StraightFlush() { std::vector<Card> cards; std::vector<Card> cardsFlush = Flush(); if(!cardsFlush.size()) return cards; std::vector<Card> cardsStraight = Straight(); if(!cardsStraight.size()) return cards; if(Intersection(cardsFlush, cardsStraight).size() >= 5) return Intersection(cardsFlush, cardsStraight); return cards; }
/* This task makes the robot follow the line, turn around corners, handle crossings and detect an obstacle. */ task Follow(){ int i = 0; startTask(Sound); while (true){ status = "active"; /* Objects are detected below here. When an object is detected the user can either choose to avoid it or charge. */ if(SonarSensor()){ while(speed > 0){ speed = Brake(i,speed); i--; Straight(speed); } status = "engage"; StopSound(); s = ""; while((s != "FIRE")&&(s != "B")){ } if (s == "FIRE"){ startTask(Sound); startTask(AvoidObject); } } else if(speed < max_Speed){ speed = Accelerate(i,speed); i++; } Straight(speed); /* Crossings are handled below here. Once both lightsensors detect the line at the same time the robot will brake unless it was told to go straight. It will then drive backward to find the line again after which it will continue untill it has crossed it. The robot will then look at the last given command to determine which way it will go. */ if((Convert(SensorValue[S3],minlight,maxlight) < 70) && (Convert(SensorValue[S4],mincolor,maxcolor) < 70)){ if (command != "straight"){ speed = EmergencyBrake(speed); wait1Msec(1000); while(Convert(SensorValue[S3],minlight,maxlight) > 30 || Convert(SensorValue[S4],mincolor,maxcolor) > 30){ Straight((-10)); } if (Convert(SensorValue[S3],minlight,maxlight) < 70 || Convert(SensorValue[S4],mincolor,maxcolor) < 70){ nMotorEncoderTarget[motorB]=(nMotorEncoderTarget[motorC]=105); motor[motorB]=(motor[motorC]=-10); while((nMotorRunState[motorB] != runStateIdle) && (nMotorRunState[motorC] != runStateIdle)) wait1Msec(1); } if ((s == "FIRE")||(s == "")){ StopSound(); while ((s == "FIRE")||(s == "")){ Straight(0); } startTask(Sound); } if (command == "left"){ LeftTurn(); } else if (command == "right"){ RightTurn(); } } else{ wait1Msec(200); } } //The code below here makes sure the robot stays on the line. if(Convert(SensorValue[S3],minlight,maxlight) < 80){ Left(Convert(SensorValue[S3],minlight,maxlight),speed); } if(Convert(SensorValue[S4],mincolor,maxcolor) < 80){ Right(Convert(SensorValue[S4],mincolor,maxcolor),speed); } wait1Msec(1.5); } }
task main() { // "power" will be used to manipulate the flywheel's power while it is spinning. // General threshold value. // Variable "x" used to gradually increase flywheel power in the first 0.35 seconds. // "flypower" is a manipulated value used to gradually reduce the flywheel's power when Button 5U is released. int power = 0; int threshold = 20; int x = 0; float flypower = 127.0; while(true) { // Buttons 7U and 7D will increase and decrease the flywheel's power. if(vexRT[Btn7U] == 1) { if(power >= 0) { power = 0; } else { power++; } } if(vexRT[Btn7D] == 1) { if(power <= -2) { power = -2; } else { power--; } } // Flywheel's power is affected by the value of "power", which is manipulated by buttons 7U and 7D. if((vexRT[Btn5U] == 1) && (motor[FW1] >= 70)) { if(power == 0) { Flywheel(127); } else if(power == -1) { Flywheel(100); } else if(power == -2) { Flywheel(80); } } // When Button 5U is pressed, flywheel starts at 60 power for 2.5 seconds. else if(vexRT[Btn5U] == 1) { x = x+10; Flywheel(x); wait1Msec(50); } // When Button 5U is released, flywheel's power is divided by 1.2 every 0.5 seconds. else if(motor[FW1] >= 8) { flypower = flypower/1.2; Flywheel(flypower); wait1Msec(500); } else { Flywheel(0); flypower = 127.0; power = 0; x = 0; } // Slide drive: Arcade if(abs(vexRT[Ch3]) > threshold) { Straight(vexRT[Ch3]); } else if(abs(vexRT[Ch1]) > threshold) { Rotate(vexRT[Ch1]); } else { Straight(0); } // Conveyor intake if(vexRT[Btn6U] == 1) { motor[conveyor] = 75; } else if(vexRT[Btn6D] == 1) { motor[conveyor] = -75; } else { motor[conveyor] = 0; } /* Strafing, lateral movement w/ middle motor (seems to be too weak) */ if(abs(vexRT[Ch4]) > threshold) { Lateral(vexRT[Ch4]); } else { Lateral(0); } } }
void Player::addStraight(uint8_t cubeTripStart, uint8_t straihtStep, uint8_t straightLength) { _straights.push(Straight(cubeTripStart, straihtStep, straightLength, getColor())); }
int StraightFlush(int color){ int straightHigh = Straight(color); int flushHigh = Flush(color); if (straightHigh > 0 && flushHigh > 0) return straightHigh; else return 0; }
/* The consequenses of giving commands through the app are happening here. Several statusses are used to determine the possibl commands that can be given. */ task main(){ while (true){ /* Standby The robot stays still untill it is told to either follow the line or go over to manual mode. FIRE: Status goes to active. A: Status goes to manual. */ while (status == "standby"){ CheckString(); if( s == "FIRE"){ startTask(Follow); status = "active"; } if (s == "A"){ status = "manual"; } } /* Active The robot is following the line untill it is told to go standby or if it sees an object. UP: Command to make the robot go straight on the next crossing. LEFT: Command to make the robot go left on the next crossing. RIGHT:Command to make the robot go right on the next crossing. FIRE: Command to make the robot wait for a command on the next crossing. C: Status goes to standby. */ while (status == "active"){ CheckString(); if( s == "C") { status = "standby"; speed = 0; stopTask(Follow); StopSound(); Straight(speed); } if (s == "RIGHT"){ command = "right"; } if (s == "LEFT"){ command = "left"; } if (s == "UP"){ command = "straight"; } } /* Engage The robot has seen an object and is waiting for a command that decides if it will charge or evade said object. FIRE: Robot evades the object. (Evasion handled in task Follow) B: The robot Charges. C: Status goes to standby. */ while (status == "engage"){ CheckString(); if(s == "FIRE"){ } if(s == "B"){ stopTask(Follow); StopSound(); Charge(); s = ""; status = "standby"; } if (s == "C"){ CheckString(); status = "standby"; speed = 0; stopTask(Follow); stopTask(AvoidObject); StopSound(); Straight(speed); } if (SensorValue[S1] == 1){ status = "standby"; speed = 0; stopTask(Follow); stopTask(AvoidObject); StopSound(); Straight(speed); } } /* Manual The robot can be manually controlled untill it is told to go back to standby. UP: The robot moves forward. RIGHT:Turn right. LEFT: Turn left. DOWN: The robot moves backward. FIRE: Brake. B: The robot charges. C: Status goes to standby. */ while(status == "manual"){ CheckString(); Straight(0); while (s == "UP"){ startTask(Sound); CheckString(); Straight(max_Speed); } while (s == "DOWN"){ startTask(Sound); CheckString(); Straight((max_Speed/2)*-1); } while (s == "LEFT"){ CheckString(); startTask(Sound); motor[motorB]= 0; motor[motorC]= max_Speed/2; } while (s == "RIGHT"){ startTask(Sound); CheckString(); motor[motorC]= 0; motor[motorB]= max_Speed/2; } if (s == "C"){ CheckString(); status = "standby"; speed = 0; stopTask(Follow); StopSound(); Straight(speed); } while (s == "FIRE"){ StopSound(); CheckString(); motor[motorB]= 0; motor[motorC]= 0; } if (s == "B"){ StopSound(); Charge(); } } wait1Msec(1); } }
ActionEnum ReverCard_Action(HandleMsg *handlemsg){ if(0 == handlemsg->count){ HandleColor.push_back(handlemsg->riverCard.color); HandleNumber.push_back(handlemsg->riverCard.num); MyColor.push_back(handlemsg->riverCard.color); MyNumber.push_back(handlemsg->riverCard.num); sort(MyColor.begin(),MyColor.end()); sort(MyNumber.begin(),MyNumber.end()); sort(HandleNumber.begin(),HandleNumber.end()); sort(HandleColor.begin(),HandleColor.end()); } //当金币大于很多的时候,完全可以弃牌直到比赛满500局 int mytotal=handlemsg->otherPlayer [handlemsg->mySeat ].jetton +handlemsg->otherPlayer [handlemsg->mySeat ].money ; int throd= (MaxInning-handlemsg->inning)*BigBlind+(handlemsg->regPlayerNum)*EveryDollar/2; if( mytotal> throd ) return FOLD; //400局以后并且处于劣势的策略 if(pHandle.inning>=ChangeActionNum && pHandle.ranking>=ChangeRank){ if(King_Straight_Flust(MyNumber,MyColor,handlemsg))//皇家通话孙 return ALLIN; else if(Straight_Flust(MyNumber,MyColor,handlemsg)){ //同花顺 if(Straight_Flust(HandleNumber,HandleColor,handlemsg)){ if(MyNumber.back()==14){ pHandle.raiseNum=pHandle.myPlayer.jetton/10; return RAISE; } else return CHECK; } else{ pHandle.raiseNum=pHandle.myPlayer.jetton/2; return RAISE; // 1/2*MaxDollar??? } } else if(Four_OF_A_KIND(MyNumber)){ //四条 if(Four_OF_A_KIND(HandleNumber)){ if(Four_OF_A_KIND(MyNumber)==14){ pHandle.raiseNum=pHandle.myPlayer.jetton/4; return RAISE; } else return CHECK; } else{ pHandle.raiseNum=pHandle.myPlayer.jetton/2; return RAISE; // 1/2*MaxDollar??? } } else if(Full_House(MyNumber)){ //葫芦 if(Full_House(HandleNumber)){ if(Full_House(MyNumber)==14){ pHandle.raiseNum=pHandle.myPlayer.jetton/5; return RAISE; } else return CHECK; } else{ pHandle.raiseNum=pHandle.myPlayer.jetton/3; return RAISE; // 1/2*MaxDollar??? } } else if(Flust(MyColor)>=5){ //同花 if(Flust(HandleNumber)>=5){ return CHECK; } else{ pHandle.raiseNum=pHandle.myPlayer.jetton/4; return RAISE; // 1/2*MaxDollar??? } } else if(Straight(MyNumber)>=5){ //顺子 if(Flust(HandleNumber)>=5) return FOLD; if(Straight(HandleNumber)>=5){ return CHECK; } else{ pHandle.raiseNum=pHandle.myPlayer.jetton/5; return RAISE; // 1/2*MaxDollar??? } } else if(Three_OF_A_KIND(MyNumber)){ //3条 if(Straight(HandleNumber)>=5 || Flust(HandleNumber)>=5 ) return FOLD; if(Straight(HandleNumber)>=4 || Flust(HandleNumber)>=4 ) if(pHandle.minCallNum>=8*BigBlind || pHandle.myPlayer.ebet>=16*BigBlind) return FOLD; if(Three_OF_A_KIND(HandleNumber)){ if(Three_OF_A_KIND(MyNumber)==14){ pHandle.raiseNum=4*BigBlind; return RAISE; } else return CHECK; } else{ pHandle.raiseNum=6*BigBlind;; return RAISE; // 1/2*MaxDollar??? } } else if(Two_Pair(MyNumber)){ //两对 if(Straight(HandleNumber)>=5 || Flust(HandleNumber)>=5 ) return FOLD; if(Straight(HandleNumber)>=4 || Flust(HandleNumber)>=4 ) if(pHandle.minCallNum>=8*BigBlind || pHandle.myPlayer.ebet>=16*BigBlind) return FOLD; if(Two_Pair(HandleNumber)){ if(Two_Pair(MyNumber)>=12 && Two_Pair(HandleNumber)<Two_Pair(MyNumber)){ pHandle.raiseNum=BigBlind; return RAISE; } else return CHECK; } else{ pHandle.raiseNum=3*BigBlind; return RAISE; // 1/2*MaxDollar??? } } else if(One_Pair(MyNumber)){ //1对 if(Straight(HandleNumber)>=5 || Flust(HandleNumber)>=5 ) return FOLD; if(Straight(HandleNumber)>=4 || Flust(HandleNumber)>=4 ) if(pHandle.minCallNum>=4*BigBlind || pHandle.myPlayer.ebet>=10*BigBlind) return FOLD; if((pHandle.minCallNum>=6*BigBlind || pHandle.myPlayer.ebet>=26*BigBlind) && pHandle.alivePlayerNum>=4) return FOLD; if((One_Pair(HandleNumber)<One_Pair(MyNumber)) || MyNumber.back()>=13) return CHECK; else return FOLD; } else if(MyNumber.back()>=11){ if(pHandle.remainPlayerNum>2){ return FOLD; } else if(pHandle.remainPlayerNum==2){ if(MyNumber.back()>=13){ if(pHandle.minCallNum>=5*BigBlind || pHandle.myPlayer.ebet>=12*BigBlind) return FOLD; else return CHECK; } else if(handlemsg->remainPlayerNum==1) return CHECK; else return FOLD; } else //有可能只有自己的情况,或者出bug情况(主要是怕前面返回值有漏洞) return FOLD ; } else if(handlemsg->remainPlayerNum==1) return CHECK; else return FOLD; } //其他相对于自己还比较有利的情况 else{ if(King_Straight_Flust(MyNumber,MyColor,handlemsg))//皇家通话孙 return ALLIN; else if(Straight_Flust(MyNumber,MyColor,handlemsg)){ //同花顺 if(Straight_Flust(HandleNumber,HandleColor,handlemsg)){ if(MyNumber.back()==14){ pHandle.raiseNum=pHandle.myPlayer.jetton/10; return RAISE; } else return CHECK; } else{ pHandle.raiseNum=pHandle.myPlayer.jetton/2; return RAISE; // 1/2*MaxDollar??? } } else if(Four_OF_A_KIND(MyNumber)){ //四条 if(Four_OF_A_KIND(HandleNumber)){ if(Four_OF_A_KIND(MyNumber)==14){ pHandle.raiseNum=pHandle.myPlayer.jetton/4; return RAISE; } else return CHECK; } else{ pHandle.raiseNum=pHandle.myPlayer.jetton/2; return RAISE; // 1/2*MaxDollar??? } } else if(Full_House(MyNumber)){ //葫芦 if(Full_House(HandleNumber)){ if(Full_House(MyNumber)==14){ pHandle.raiseNum=pHandle.myPlayer.jetton/5; return RAISE; } else return CHECK; } else{ pHandle.raiseNum=pHandle.myPlayer.jetton/3; return RAISE; // 1/2*MaxDollar??? } } else if(Flust(MyColor)>=5){ //同花 if(Flust(HandleNumber)>=5){ return CHECK; } else{ pHandle.raiseNum=pHandle.myPlayer.jetton/4; return RAISE; // 1/2*MaxDollar??? } } else if(Straight(MyNumber)>=5){ //顺子 if(Flust(HandleNumber)>=5) return FOLD; if(Straight(HandleNumber)>=5){ return CHECK; } else{ pHandle.raiseNum=pHandle.myPlayer.jetton/5; return RAISE; // 1/2*MaxDollar??? } } else if(Three_OF_A_KIND(MyNumber)){ //3条 if(Straight(HandleNumber)>=5 || Flust(HandleNumber)>=5 ) return FOLD; if(Straight(HandleNumber)>=4 || Flust(HandleNumber)>=4 ) if(pHandle.minCallNum>=8*BigBlind || pHandle.myPlayer.ebet>=16*BigBlind) return FOLD; if(Three_OF_A_KIND(HandleNumber)){ if(Three_OF_A_KIND(MyNumber)==14){ pHandle.raiseNum=4*BigBlind; return RAISE; } else return CHECK; } else{ pHandle.raiseNum=6*BigBlind;; return RAISE; // 1/2*MaxDollar??? } } else if(Two_Pair(MyNumber)){ //两对 if(Straight(HandleNumber)>=5 || Flust(HandleNumber)>=5 ) return FOLD; if(Straight(HandleNumber)>=4 || Flust(HandleNumber)>=4 ) if(pHandle.minCallNum>=8*BigBlind || pHandle.myPlayer.ebet>=16*BigBlind) return FOLD; if(Two_Pair(HandleNumber)){ if(Two_Pair(MyNumber)>=12 && Two_Pair(HandleNumber)<Two_Pair(MyNumber)){ pHandle.raiseNum=BigBlind; return RAISE; } else return CHECK; } else{ pHandle.raiseNum=3*BigBlind; return RAISE; // 1/2*MaxDollar??? } } else if(One_Pair(MyNumber)){ //1对 if(Straight(HandleNumber)>=5 || Flust(HandleNumber)>=5 ) return FOLD; if(Straight(HandleNumber)>=4 || Flust(HandleNumber)>=4 ) if(pHandle.minCallNum>=4*BigBlind || pHandle.myPlayer.ebet>=10*BigBlind) return FOLD; if((pHandle.minCallNum>=6*BigBlind || pHandle.myPlayer.ebet>=26*BigBlind) && pHandle.alivePlayerNum>=4) return FOLD; if((One_Pair(HandleNumber)<One_Pair(MyNumber)) || MyNumber.back()>=13) return CHECK; else return FOLD; } else if(MyNumber.back()>=11){ if(pHandle.remainPlayerNum>2){ return FOLD; } else if(pHandle.remainPlayerNum==2){ if(MyNumber.back()>=13){ if(pHandle.minCallNum>=5*BigBlind || pHandle.myPlayer.ebet>=12*BigBlind) return FOLD; else return CHECK; } else if(handlemsg->remainPlayerNum==1) return CHECK; else return FOLD; } else //有可能只有自己的情况,或者出bug情况(主要是怕前面返回值有漏洞) return FOLD ; } else if(handlemsg->remainPlayerNum==1) return CHECK; else return FOLD; } }
ActionEnum HoldCard_Action(HandleMsg *handlemsg){ if(0 == handlemsg->count){ MyColor.push_back(handlemsg->holdCard[0].color); MyColor.push_back(handlemsg->holdCard[1].color); MyNumber.push_back(handlemsg->holdCard[0].num); MyNumber.push_back(handlemsg->holdCard[1].num); sort(MyColor.begin(),MyColor.end()); sort(MyNumber.begin(),MyNumber.end()); } //当金币大于很多的时候,完全可以弃牌直到比赛满500局 int mytotal=handlemsg->otherPlayer [handlemsg->mySeat ].jetton +handlemsg->otherPlayer [handlemsg->mySeat ].money ; int throd= (MaxInning-handlemsg->inning)*BigBlind+(handlemsg->regPlayerNum)*EveryDollar/2; if( mytotal> throd ) return FOLD; //400局以后并且处于劣势的策略 if(pHandle.inning>=ChangeActionNum && pHandle.ranking>=ChangeRank){ //两张牌都>J才跟,或者只剩下自己,这个地方也许需要改进,比如两个AA时,是否Riase? if( MyNumber.back()>=13 || One_Pair(MyNumber)>=8 || (Straight(MyNumber)>=2 && MyNumber.back()>=10) || (Flust(MyColor)>=2 && MyNumber.back()>=10)) return CHECK; else if(handlemsg->remainPlayerNum==1) return CHECK; else return FOLD; } //其他自己还处于相对优势情况的策略 else{ //两张牌都>J才跟,或者只剩下自己,这个地方也许需要改进,比如两个AA时,是否Riase? if(pHandle.alivePlayerNum>4){ if(pHandle.minCallNum>=4*BigBlind || pHandle.myPlayer.ebet>=8*BigBlind){ return FOLD; } if(MyNumber.front()<11){ if(handlemsg->remainPlayerNum==1) return CHECK; else return FOLD; } else{ return CHECK; } } else if(pHandle.alivePlayerNum>=3 && pHandle.alivePlayerNum<=4){ if(MyNumber.front()>=13 || One_Pair(MyNumber)>=10 || (Straight(MyNumber)>=2 && MyNumber.back()>=10) || (Flust(MyColor)>=2 && MyNumber.back()>=10) ){ //当手牌很大时,和别人拼,此时人少可以拼一下 return CHECK; } if(pHandle.minCallNum>=4*BigBlind || pHandle.myPlayer.ebet>=10*BigBlind){ return FOLD; } else if(MyNumber.front()>=8 && MyNumber.back()>=13) return CHECK; else if(handlemsg->remainPlayerNum==1) return CHECK; else return FOLD; } else if(pHandle.remainPlayerNum==2){ if(MyNumber.front()>=13 || One_Pair(MyNumber)>=10){ pHandle.raiseNum=pHandle.myPlayer.jetton/10; return RAISE; } if( MyNumber.back()>=12 || One_Pair(MyNumber) || Straight(MyNumber)>=2 || Flust(MyColor)>=2) return CHECK; else if(handlemsg->remainPlayerNum==1) return CHECK; else return FOLD; } else //有可能只有自己的情况,或者出bug情况(主要是怕前面返回值有漏洞) return FOLD; } }