Summary of the invention
In order to solve traditional fighting landlord computer player single, problem that degree of intelligence is low of strategy of playing a card, the invention provides the implementation method of computer player intelligent algorithm in a kind of fighting landlord recreation, make computer player can according to own in recreation the difference of identity of living in, take the different strategies of playing a card, and make this intelligent algorithm itself in game process, constantly to develop by means of genetic algorithm, produce the strategy of playing a card of intelligence more.Simultaneously because computer player can be learnt board in other staff by the mode of cheating, so that the strategy of playing a card of computer player will be more pointed.
The present invention solves above-mentioned technical matters by following technical proposals: the implementation method of computer player intelligent algorithm in a kind of fighting landlord recreation is characterized in that this method may further comprise the steps:
S1, produce three gene pools at random, every group of gene pool is made up of chromosome, and the data in the gene pool are carried out persistent storage;
After S2, the recreation beginning, computer player is according to different corresponding intelligent algorithm and the chromosomes chosen of residing role in recreation;
S3, take turns to computer player when playing a card at every turn,, jump to step S6 if can't play a card then selected board; Otherwise play a card, calculate all legal playing mode, and calculate the recreation situation after playing a card according to every kind of playing mode;
S4, all recreation situations that obtain among the step S3 are marked;
S5, play a card according to the playing mode of the highest recreation situation correspondence of score;
S6, whenever taking turns to when oneself playing a card repeated execution of steps S3 to S5;
After S7, the game over, the chromosome that uses in the local exchange recreation is marked;
S8, after the access times of certain gene pool surpass setting value, the minimum chromosome of score in the deletion gene pool, remaining chromosome is hybridized and made a variation, and chromosome number is amplified to original number, the chromosome number in the gene pool is remained unchanged;
S9, recreation in a single day restart repeated execution of steps S2 to S8.
Preferably, respectively corresponding three kinds of different intelligent algorithm types of described three gene pools.
Preferably, described three kinds of different intelligent algorithm types are landlord player, landlord's seller and the landlord player whose turn comes next.
Preferably, the data storage in the described gene pool is in database or file.
Preferably, will abide by recreation situation code of points to recreation situation scoring among the described step S4, recreation situation code of points comprises for landlord player's algorithm with for the landlord's seller and the landlord player whose turn comes next's algorithm.
Preferably, described step S7 abides by the rule of chromosome being marked after the game over to chromosome scoring.
Positive progressive effect of the present invention is: the algorithm of playing a card of computing machine of the present invention can obtain constantly progressive in recreation, makes the player feel more and more to have challenge in recreation, makes recreation have playability and recreational more.
Embodiment
Provide preferred embodiment of the present invention below in conjunction with accompanying drawing, to describe technical scheme of the present invention in detail.
As shown in Figure 1, the implementation method of computer player intelligent algorithm may further comprise the steps in the fighting landlord recreation of the present invention:
Step 1, produce three gene pools at random, the respectively corresponding three kinds of different intelligent algorithm types of these three gene pools, three kinds of different intelligent algorithm types are landlord player, landlord's seller and the landlord player whose turn comes next.Every group of gene pool is made up of S bar chromosome.Every ordered sequence (value of n can be different according to the algorithm specific implementation, gets n=10 in this example) that chromosome is n gene.Each gene is the floating number of value between 0 to 1, and promptly each chromosome can be expressed as { G1, G2, G3 to Gn}.Data in the gene pool are carried out persistent storage, can be put in the database or and preserve with document form.
After step 2, the recreation beginning, computer player is chosen corresponding intelligent algorithm and chromosome according to residing role in recreation is different, promptly chooses a chromosome and use in the local exchange recreation from corresponding gene pool.Write down the number of times that this gene pool was used at last.
Step 3, take turns to computer player when playing a card at every turn,, jump to step 6 if can't play a card then selected board.Otherwise play a card, calculate all legal playing mode, and calculate the recreation situation after playing a card according to every kind of playing mode, be about to board in the hand and deduct the board that oneself will go out.
Step 4, all recreation situations that obtain in the step 3 are marked.Code of points is referring to back described " recreation situation code of points ".
Step 5, play a card, promptly select the highest recreation situation of score, play a card, making recreation proceed to this kind situation according to its corresponding playing mode according to the playing mode of the highest recreation situation correspondence of score.
Step 6, whenever taking turns to when oneself playing a card, repeated execution of steps three is to step 5.
After step 7, the game over, the chromosome that uses in the local exchange recreation is marked.Code of points is referring to back described " rule of after the game over chromosome being marked ".This chromosomal total points (total points=former score+score in the local exchange recreation) is set at last, score information is carried out persistent storage.
Step 8, after the access times of certain gene pool surpass setting value K time, the minimum P% chromosome of score in the deletion gene pool is hybridized remaining chromosome, variation, and chromosome number is amplified to original number S, the chromosome number in the gene pool is remained unchanged.At last with the access times zero clearing of this gene pool.
Step 9, recreation in a single day restart, and repeated execution of steps two is to step 8.
Wherein, above-mentioned S, K, the value of P can constantly be adjusted with the debugging situation.
Recreation situation code of points comprises for landlord player's algorithm with for the landlord's seller and the landlord player whose turn comes next's algorithm, and is specific as follows:
For landlord player's algorithm, the score * G1+ of the board of recreation situation score=own suppose the score * that the player whose turn comes next beat the bridge queen who oneself has just gone out and remain board (G2)+suppose that seller beat score * that the bridge queen who oneself has just gone out remains board (G3);
For the landlord's seller and the landlord player whose turn comes next's algorithm, the score * G1+ hypothesis federation of the board of recreation situation score=own beat the bridge queen who oneself has just gone out and remained score * that bridge queen that the leading hypothetically mistake oneself of score * G2+ of board just gone out remains board (G3);
Wherein, when calculating " suppose seller/player whose turn comes next/landlord/federation beat the score that the bridge queen who oneself has just gone out remains board ",, then calculate the mean value of various situations if there is multiple mode to beat " board that oneself has just gone out ".If can't beat " board that oneself has just gone out ", then calculated the score of the board in bridge queen's hand.First three gene on the chromosome of choosing when the value of G1, G2, G3 corresponds respectively to the recreation beginning.
Code of points to board is as follows:
If the quantity of board is zero, then must be divided into best result.Otherwise count the score in such a way:
Trump card is according to continuous three, antithetical phrase continuously, and along son, three, antithetical phrase, the board type order of single board is divided into corresponding board type (continuous three, antithetical phrase can also continue segmentation along these board types of son continuously, only it is divided into 6 kinds in this example for convenience of description) successively.
The weights of this board type of quantity * of all boards in the weights summation of every one card/this board type in the score of each board type=this board type.
Wherein, the pairing weights of every one card are respectively:
Square/red heart/spade/showy flowers of herbaceous plants 3, weights are 3;
Square/red heart/spade/showy flowers of herbaceous plants 4, weights are 4;
Square/red heart/spade/showy flowers of herbaceous plants 5, weights are 5;
Square/red heart/spade/showy flowers of herbaceous plants 6, weights are 6;
Square/red heart/spade/showy flowers of herbaceous plants 7, weights are 7;
Square/red heart/spade/showy flowers of herbaceous plants 8, weights are 8;
Square/red heart/spade/showy flowers of herbaceous plants 9, weights are 9;
Square/red heart/spade/showy flowers of herbaceous plants 10, weights are 10;
Square/red heart/spade/showy flowers of herbaceous plants J, weights are 11;
Square/red heart/spade/showy flowers of herbaceous plants Q, weights are 12;
Square/red heart/spade/showy flowers of herbaceous plants K, weights are 13;
Square/red heart/spade/showy flowers of herbaceous plants A, weights are 14;
Square/red heart/spade/showy flowers of herbaceous plants 2, weights are 15;
Xiao Wang, weights are 16;
King, weights are 17;
The weights of board type are respectively:
Continuous three, G4;
Continuous antithetical phrase, G5;
Along son, G6;
Article three,, G7;
Antithetical phrase, G8;
Single board, G9;
Wherein, the gene of correspondence position in the corresponding selected chromosome of G4, G5 to G9 difference.If it is thinner that the board type divides, then can corresponding more gene.For convenience of description, this example is only selected the gene of 4 to 9 positions.
The score of board=(quantity of the score sum/board type of all board types)/(the quantity * Gn of board type).Wherein Gn is the gene of selected chromosomal last position.
The rule of after the game over chromosome being marked comprises the value of chromosome score and Y, and is specific as follows:
Chromosome score=Y-(during beginning in the hand weights sum of every board)/(during beginning in the hand number of board);
The value of Y: if the recreation triumph, Y=20; If failure game, Y=0.
Though more than described the specific embodiment of the present invention, it will be understood by those of skill in the art that these only illustrate, under the prerequisite that does not deviate from principle of the present invention and essence, can make numerous variations or modification to these embodiments.Therefore, protection scope of the present invention is limited by appended claims.