CN105999689A - AI algorithm for game of the Amazons based on computer game playing - Google Patents

AI algorithm for game of the Amazons based on computer game playing Download PDF

Info

Publication number
CN105999689A
CN105999689A CN201610369682.2A CN201610369682A CN105999689A CN 105999689 A CN105999689 A CN 105999689A CN 201610369682 A CN201610369682 A CN 201610369682A CN 105999689 A CN105999689 A CN 105999689A
Authority
CN
China
Prior art keywords
tactics
chess
algorithm
valuation
search
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610369682.2A
Other languages
Chinese (zh)
Inventor
史继筠
宋鑫
赵峻瑶
孙云霄
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Institute of Technology BIT
Original Assignee
Beijing Institute of Technology BIT
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Institute of Technology BIT filed Critical Beijing Institute of Technology BIT
Priority to CN201610369682.2A priority Critical patent/CN105999689A/en
Publication of CN105999689A publication Critical patent/CN105999689A/en
Pending legal-status Critical Current

Links

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/60Generating or modifying game content before or while executing the game program, e.g. authoring tools specially adapted for game development or game-integrated level editor
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F3/00Board games; Raffle games
    • A63F3/00643Electric board games; Electric features of board games
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F3/00Board games; Raffle games
    • A63F2003/00996Board games available as video games

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • General Engineering & Computer Science (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

Disclosed is an AI algorithm for a game of the Amazons based on computer game playing. The AI algorithm comprises a search algorithm and an estimation algorithm, wherein according to the search algorithm, the generated feasible tricks are sorted; the tricks which can most possibly trigger pruning or the tricks with relatively good effects are obtained; whether the trick is good or not can be determined by valuation for each effect, and the good tricks are sorted in front; the search algorithm is also embodied in that different strategies are adopted in different stages; less of the generated tricks are pruned in the lower search depth; all tricks need to be expanded in the relatively deep layer, and the tricks are not pruned; according to the estimation algorithm, a regional occupy parameter (occupy) is added, so that the judgment on the occupied grid is more accurate; different estimated value parameters are adopted in different stages; the development degree of the game is determined based on the number of steps; then which kind of parameter needs to be used is determined; next, the estimated value parameters are dynamically adjusted according to the game situation; and in addition, optimized multithreading is adopted, so that the shared resource is to be the minimum, and value resources are shared among the multi-threads in a mutex manner.

Description

A kind of Amazon chess AI algorithm of game playing by machine
Technical field
The invention mainly relates to searching algorithm, multithreading uses and evaluation function, particularly relates to a kind of game playing by machine Amazon chess AI algorithm, belongs to artificial intelligence's game, searching algorithm, estimation algorithm field.
Background technology
1. game playing by machine
Computer game (also referred to as game playing by machine), is a challenge research field infinite, vivifying, is artificial intelligence The important research direction in field, is the important scientific research base of the artificial intelligence fields such as machine intelligence, war game simulation, intelligent decision system Plinth.Game playing by machine is considered as one of the most challenging research direction of artificial intelligence field.The computer game of chess Having had the longest history, and experienced by one massive " fighting with a weapon ", the mankind are also given in the triumph of Deep Blue computer Leave unforgettable memory.Even to this day, the man-machine battle of a lot of different chess and machinery compartment game is the most still had to exist Including the most periodically holding of China.The Amazon chess of our research is as domestic computer game championship and the world The contest accumulation the most for many years of the important games project of computer game contest (ICGA), the champion of two matches is also constantly Change constantly improves.
Amazon chess (Game of the Amazons), is to be pushed away in 1988 by Argentine Walter Zamkauska The two people's chess gone out, be Olympia computer game formula contest match specify chess-.
Owing to situation is the most complicated, the only first step just has more than a 2700 kind of way to get there, thus these chess be not used in more the mankind it Between compete, but for the match of computer game related fields and research.
10*10 checkerboard.
The each 4 pieces of chess pieces in every side, distinguish enemy and we, referred to as Amazon (Amazons) with black-and-white two color;92 pieces of chess piece both sides are altogether With, referred to as arrow (Arrows).
After initial placement, both sides take turns flowing, and oneself am sub, and direction can be towards in length and breadth the most from all directions, distance the most empty unrestricted chess position, in Must not there be son on way.Mobile to target chess position, inspect its mobile range from this chess position, then in arbitrary space of this scope Place one piece of arrow.After arrow blow-down, just must not move or remove.
Until a side play chess cannot then lose this game.
2.AlphaBeta pruning algorithms
AlphaBeta pruning algorithms (AlphaBeta pruning algorithm) is that a searching algorithm is intended to reduce In its search tree, by the nodes of minimax (Minimax) evaluation of algorithm.This is searching of conventional people's machine game antagonism Rope algorithm.Its basic thought is the current optimal result obtained according to last layer, determines whether current search continues Continue down.AlphaBeta pruning algorithms is the optimization to Minimax method, and the result that they produce is identical, the most not Cross operational efficiency different.The hypotheses of AlphaBeta pruning algorithms and Minimax are also the same, be embodied in as Lower three aspects:
1) optimal the method play chess that both sides think by oneself;
2) assessing given card with a score value, this assessed value is to evaluate from a side (search utility) forever , give a positive number when one's own side is favourable, when the other side is favourable, give a negative;When red is moved, if returned when red is favourable Positive number, when taking turns to black and moving, assessed value is transformed into again the viewpoint of black, if it is considered to black is favourable, also returns to positive number;
3) number that in general score value is big represents favourable to one's own side, and for the other side, it can select score value little Method.
AlphaBeta algorithm depends critically upon the searching order of method, if always first removal search the worst method, then Beta blocks and would not occur, i.e. AlphaBeta algorithm eventually seeks all over whole search tree, just as minimax algorithm, Efficiency is the lowest.
If program always can be chosen best method and first be searched for, then mathematically the effectively branch factor is just close to reality The square root of the branch factor, this is the best situation that AlphaBeta algorithm is likely to be breached.
3. multithreading
Multithreading (multithreading) refers to realize from software or hardware the technology that multiple thread concurrently performs. The computer with multithreading ability can perform more than one thread in the same time because there being hardware supported, and then promotes whole Body process performance.In a program, the usability of program fragments of these independent operatings is " thread " (Thread), and utilize that it programs is general Read and be just called " multithreading " or " multiple threads " (Multithreading processing).
4. evaluation function
Evaluation function for estimating the effect (favourable to us on the occasion of representing, be the bigger the better, negative value is contrary) of a situation, Evaluation function is the pith that AlphaBeta algorithm is indispensable, and on the one hand the quality of evaluation function determines beta pruning efficiency, On the other hand the good and bad degree of final tactics is also determined.
For the research of Amazon chess searching algorithm, through data-searching, following several classes:
A) " the entitled Amazon chess game based on minimax search algorithm that Northeastern University Zhang Liu delivered in 2010 Systematic research " academic dissertation in, utilize classical AlphaBeta algorithm, Nash Equilibrium principle and based on chess piece position Evaluation function devise the game program of an Amazon chess.But the search efficiency of this program is the most relatively low.And valuation Function is simpler, although can be time-consuming, but its valuation obtained can not accurately reflect the true value of tactics.
B) it is published in the exercise question in Computer Games Workshop 2007 forum at Julien Kloetzer et al. In paper for " The Monte-Carlo Approach in Amazons ", they utilize game playing by machine field, and another is classical Algorithm, Monte carlo algorithm design achieves an Amazon chess game program.Same, although have employed different algorithms, Its search efficiency is not significantly improved;And relative to AlphaBeta algorithm, use in the program of uct algorithm valuation Function is difficult to grasp, and is difficult to write an evaluation function adapting to search depth change, i.e. the effect of valuation is unstable.
Secondly, for the research of Amazon chess evaluation function, through data-searching, in addition to above-mentioned paper, also have following this Kind main flow valuation:
C) it is published in Theoretical Computer Science, the topic of Vol.349, No.2 at Jens Lieberum Mesh is in the paper of " An evaluation function for the game of amazons ", have employed based on manor and The valuation of position, and introduce the concept of flexibility ratio.This estimation algorithm has certain accuracy, but this algorithm to capture grid with Situation about being contained by chess piece considers not in place, causes easily defeating when seizing domain with the other side, or occurs being contained relatively by the other side Unfavorable situation in little scope;And this algorithm is not in place to the estimation of the coverage of chess piece, easily occur that certain chess piece is lonely Vertical, form the situation many with an enemy.
The application is devoted to overcome the above-mentioned inefficient and inaccurate problem of valuation, it is intended to propose the search of higher efficiency Algorithm, and more accurately for the evaluation function of Amazon chess game.
Summary of the invention
It is an object of the invention to overcome that existing searching algorithm search efficiency is relatively low, valuation is inaccurate, valuation effect is unstable, And containing, with chess piece, the problem that situation is inconsiderate to capturing grid, it is proposed that the Amazon chess AI of a kind of game playing by machine calculates Method.
The Amazon chess AI algorithm of a kind of game playing by machine includes searching algorithm and estimation algorithm two aspect;
Wherein, searching algorithm aspect, the feasible tactics sequence that will generate, the beta pruning that can cause of maximum possible maybe can obtain The tactics of better effects, concrete, by for each effect assignment with judge tactics quality, come before;Searching algorithm It is also embodied in different phase and uses Different Strategies: when search does not arrives the bottom, the tactics of generation can be cropped;And when search Need to launch full tactics when arriving the bottom, tactics is not carried out cutting;
Estimation algorithm aspect, on the one hand, capture parameter occupy by adding region, make the judgement to capturing grid more accurate Really;On the other hand, use different valuation parameter in different phase, judge which degree is chess game proceeded to based on step number, then determine Surely use which kind of parameter, further according to situation, valuation parameter is dynamically adjusted;
Additionally, searching algorithm also uses the multithreading of optimization: on the one hand make to share resource the fewest, to prevent from waiting money The time that source consumes;On the other hand, make each cross-thread have mutually exclusive and share valuable resource, thus promote AlphaBeta and calculate The efficiency of method;Concrete parameters optimization mainly includes global variable AlphaB, and variable i in MultiThread function, by variable best Introduce AlphaBeta function, and improve in AlphaBeta algorithm the mechanism returning and updating beta value;
It addition, the bottom at AlphaBeta uses more new sort, other layer uses valuation sequence;
The Amazon chess AI algorithm of a kind of game playing by machine, relates generally to such as minor function:
The Amazon chess AI algorithm of a kind of game playing by machine, specifically comprises the following steps that
Step one, statement global variable initialization step number of playing chess are 0;
Concrete, in step one, the global variable of statement is as follows:
1.1 statement AlphaB are for recording best valuation comprehensive in multithreading;
1.2 statement maxdepth define search depth;
1.3 statement MOVEi record the numbering of the respective best tactics of each thread;
The best tactics of the 1.4 statement BestMove record overall situations;
1.5 statement qstep and kstep are for evaluation function;
1.6 statement ST;
1.7 statement totalTime record overall situations start total used time up till now;
1.8 statement movestack are used for storing tactics, and movestack is also known as tactics stack;
Wherein, it is continuously traveling along single direction during the implication of qstep is four chess pieces needed for a certain grid of arrival Few step number;
The implication of kstep is the minimum step needed for a certain grid that in four chess pieces, at random single step traveling in direction arrives Number;Which tactics is the implication of ST searched for record top;
Step 2, search for and select the tactics that can use, specifically include again following steps:
Step 2.1 call entry function search_a_goodmove;
Step 2.2 is initialization section global variable in function search_a_goodmove: the wherein said part overall situation Variable mainly includes global variable AlphaB;
Described AlphaB initial value is-INF;
Step 2.3 draws search depth value M according to step number of playing chess;
Concretely comprise the following steps:
Step 2.3.1 is when step number step is less than K1, then search depth value M is 4;
Step 2.3.2 is less than K2 when step number step more than or equal to K1, then search depth value M is 5;
Step 2.3.3 is when step number step is more than or equal to K2, then search depth value M is 6;
Wherein, preferred K1 is 32, it is also possible to be greater than 20 integers less than 38;
Wherein, preferred K2 is 48, it is also possible to be greater than 30 integers less than 60;
Step 2.4 is called createMove_eval and is generated tactics;
Each tactics generated is called Evaluate function by step 2.5, and all tacticses are called Evaluate letter The return value of number is ranked up;
Step 2.6 according to step number and step 2.5 is called createMove_eval generate tactics carry out cutting, specifically For:
2.6.1 it is more than K4 when step number step less than K3 and tactics number, then retains the sequence tactics at front K4;
2.6.2 it is more than K5 when step number step more than or equal to K3 and tactics number, then retains the sequence tactics at front K5;
Wherein, preferred K3 is 32, it is also possible to be greater than 6 integers less than 36;
Wherein, preferred K4 is 300, it is also possible to be greater than 200 integers less than 400;
Wherein, preferred K5 is 400, it is also possible to be greater than 300 integers less than 500;
Search depth value M when total used time totalTime was more than 14 minutes, is then set to 4 by step 2.7;
Step 2.8 is called MultiThread function and is started multithreading;
Step 2.9 waits until all thread end of runs of step 2.7, deletes multithreading and returns;
Step 3, call createMove generate feasible tactics, the tactics meeting condition is stored in trick together with valuation Method stack returns:
The described condition that meets is that produced tactics is begun a little or at the obstacle that falls, and has within more at least meeting five steps To square chess;
Concrete, the execution process of step 3 includes:
Each chess piece in four chess pieces of we is done following 3.11 and 3.12 two operations by step 3.1, draws one Feasible tactics;
3.11 travel through four direction up and down from chess piece, then travel through most 10 feasible steps on each direction, look for To meeting the grid begun, then travel through all grid meeting and beginning, each grid is performed 3.12;
3.12 from each grid begun, and travels through four direction up and down, then travels through on each direction most 10 feasible steps, find the grid that can place obstacles;
Step 3.2 does following four generic operations respectively according to the feasible tactics that step 3.1 draws:
Step 3.2.1 is called after createMove obtains feasible tactics and is directly stored in tactics stack, continues search for other tacticses;
Step 3.2.2 is called createMove_eval and is performed tactics, calls evaluation function, obtains estimating after performing tactics Value (it is believed that being the valuation of this tactics), is all stored in tactics stack by valuation and tactics;
Step 3.2.3 is called createMove_select and is first checked tactics after producing tactics, if meet such as Lower condition:
Produced tactics is begun a little or at the obstacle that falls, and has square chess within more at least meeting five steps;
Again the tactics meeting condition is added tactics stack;
Step 3.2.4createMove_selecteval combines 3.2.2 and 3.2.3, will meet the tactics of condition together with estimating Value is stored in tactics stack together;
After step 3.3 traversal terminates, return;
Step 4, call process multithreading function MultiThread, particularly as follows:
Step 4.1 states variable i, arranges mutual exclusion lock for global variable ST, in mutual exclusion lock, the value of ST is assigned to i, and gives ST adds 1;Then the mutual exclusion lock of ST is discharged;
All top layer tacticses that step 4.2 traversal step three generates;
Step 4.2.1 each tactics to traversing, performs AlphaBeta search on simulation chessboard, returns this tactics Valuation;Cancel the execution of this tactics on simulation chessboard again;
If step 4.2.2 step 4.2.1 returns the valuation best valuation more than current thread of tactics, then front is worked as in amendment The best tactics of journey, and record new best valuation;
Step 4.2.3 is that global variable AlphaB arranges mutual exclusion lock, if judging that in mutual exclusion lock current thread is preferably estimated Value more than the overall situation preferably valuation AlphaB, is then revised the overall situation preferably tactics and AlphaB, and is updated the overall situation preferably tactics BestMove, then discharges the mutual exclusion lock of AlphaB;
Step 5, call AlphaBeta function and scan for;
Step 5.1 judges search depth, carries out corresponding operating:
If 5.11 search arrive the end, the most incoming parameter depth==0, then call evaluation function Evaluate, and return Return valuation;
5.12 otherwise, calls createMove_selecteval or createMove_eval and generates tactics, meanwhile, to often Individual generation tactics is called Evaluate and is carried out valuation, generates after whole tactics according to valuation, i.e. Evaluate return value is to tactics It is ranked up, particularly as follows:
5.12.1 within 20 steps, selectively generate tactics, i.e. call createMove_selecteval function Generate tactics;
The most otherwise generate whole tactics, i.e. call createMove_eval function to generate tactics;
Step 5.2 carries out cutting according to search depth to tactics, particularly as follows:
5.2.1 the not cutting tactics when search depth depth is 1;
5.2.2 it is 2 as search depth depth and tactics number is more than K6, then retains the sequence tactics at front K6;
5.2.3 it is 3 as search depth depth and tactics number is more than K7, then retains the sequence tactics at front K7;
5.2.4 it is 4 as search depth depth and tactics number is more than K8, then retains the sequence tactics at front K8;
Wherein, preferred K6 is 300, it is also possible to be greater than 250 integers less than 350;
Wherein, preferred K7 is 200, it is also possible to be greater than 150 integers less than 250;
Wherein, preferred K8 is 100, it is also possible to be greater than 80 integers less than 120;
Step 5.3 judges whether current tactics number is 0, and carries out corresponding operating:
If the 5.31 tactics numbers generated are 0, illustrate that chess game is over, return-INF+ (maxdepth-depth);
If the 5.32 tactics numbers generated are not 0, then continue step 5.4;
The step 5.4 tactics valuation to producing, and return best valuation or first valuation more than beta, the tool of this layer Body is:
Step 5.4.1 statement variable best, and it is initialized as-1, current preferably valuation is assigned to best;
Step 5.4.2 traversal performs step 5.1 and the 5.2 all tacticses produced and enters next layer of AlphaBeta, recurrence Until return valuation;
After step 5.4.3 obtains the valuation of step 5.4.1, if valuation is more than best, then the valuation obtained is assigned to best;
If the valuation of step 5.4.4 is more than beta, then return valuation;
After step 5.4.5 traversal terminates, if there being more preferable tactics, then record and update;
Step 5.4.6 returns best;
Step 6, call evaluation function Evaluate;
Step 6.1 is called this function of Evaluate and is calculated qstep and kstep;
Step 6.2 calculates four basic underlying variables again: t1, t2, c1, c2;These four values when calling evaluation function every time all It is initialized as 0, specifically comprises and operate as follows:
Step 6.2.1 determines the value of t1 by a and b:
A. award, non-present row are divided when certain grid both sides' qstep value gives t1x simultaneously for current play chess color Chess gives the punishment that-t1x divides, then is added on t1 by the mark of this award or punishment;
Wherein, described t1x fraction range is 0.0 to 1.0;
B., when our qstep value is less, make t1 obtain bonus point score, otherwise obtain a negative point of-score;'s Value, for can arrive the number of the chess piece of this grid with the step number representated by qstep, i.e. can arrive with minimum step number for one Grid, the quantity of chess piece that record can arrive with minimum step number;
Wherein, described score fraction range is the integer more than 1, does not the most set the upper limit;
A, b use to prevent the situation many with an enemy simultaneously;
Step 6.2.2 calculates the value of t2, particularly as follows: travel through all kstep, when our kstep value is less, and t2 adds 1, when The other side's kstep value is less, and t2 subtracts 1;
Step 6.2.3 calculates the value of c1 and c2, particularly as follows:
C1+=(pow (2.0 ,-qstep [thread] [i] [j] [0])-pow (2.0 ,-qstep [thread] [i] [j] [1]));
C2+=min (1, max (-1, (kstep [thread] [i] [j] [1] .st-kstep [thread] [i] [j] [0] .st)/6.0));
Note: thread represents current thread number, grid on i, j correspondence chessboard, and the most one-dimensional is 0 to represent us, 1 represent right Side;
Step 6.3 statement calculates variable occupy, and to compose occupy initial value be 1, when certain grid only has us can arrive then Add one by occupy, otherwise subtract 1 by occupy, i.e. occupy have recorded the space quantum count that our current situation has been captured;
Variable sumA [2] is stated and calculated to step 6.4;
Wherein, described sumA [2] represents the flexibility ratio of both sides' chess piece, and computational methods are as follows:
Step 6.4.1 calculates its flexibility ratio for each chess piece: find this most accessibility all spaces of chess piece one step Son, is designated as i for the distance of each space subrecord chess piece and space, then calculates around this space and in 8 grid be Empty grid quantity is designated as N;Calculate A=N*pow (2.0 ,-i);Can obtain for all chess piece one steps accessibility space Such a A, flexibility ratio AM of chess piece is the sum of all such A;
Step 6.4.2sumA is the sum of four chess piece each AM;Both sides are calculated to flexibility ratio, both sides can be obtained each From sumA;
So far, through step one to step 6, the Amazon chess AI algorithm of a kind of game playing by machine is completed.
Beneficial effect
The Amazon chess AI algorithm of a kind of game playing by machine of the present invention, compared with existing Amazon chess AI algorithm, has and has as follows Benefit effect:
Algorithm the most of the present invention is in multithreading strategy, and global variable AlphaB is incessantly in the top of AlphaBeta Being modified, but just can be modified when internal layer triggers certain condition, the application of this strategy considerably improves searches element speed, i.e. Improve efficiency of algorithm;
Algorithm the most of the present invention is in multithreading strategy, and statement variable i also arranges mutual exclusion lock for it, it is ensured that synchronization In only one of which thread can access this variable;I make multiple thread can be when thread runs, search one by one to n from 0 Suo Zhaofa, on the premise of having tactics sequence, this strategy can improve beta pruning efficiency;
3. the carried algorithm of the present invention, the overall operation time be within 15 minutes in the case of, can realize AlphaBeta The minimum number of plies of search is promoted to 4 layers by 3 layers, i.e. represents that this algorithm can not allow more than 15 minutes in the overall operation time In the case of, consideration one steps more than the opponent of analogous algorithms;
4. the carried algorithm of the present invention is on the basis of beneficial effect 1, and the deep thinking in later stage examines the number of plies up to 6 layers, after tested It is the most permissible that the number of plies continues intensification;
5., in the carried estimation algorithm of the present invention, the improvement of the computational methods representing value sumA of flexibility ratio makes evaluation function To capturing grid, more accurate with the judgement contained so that when the two situation occurs, the tactics be finally given more rationally has Effect.
Accompanying drawing explanation
Fig. 1 is the flow chart of the Amazon chess AI algorithm of a kind of game playing by machine of the present invention;
Fig. 2 is the Amazon chessboard used in the Amazon chess AI algorithm of a kind of game playing by machine of the present invention and embodiment.
Embodiment
For making the purpose of the embodiment of the present invention, technical scheme and advantage clearer, below in conjunction with the embodiment of the present invention In accompanying drawing, the technical scheme in the embodiment of the present invention is carried out clear, complete description, it is clear that described embodiment is A part of embodiment of the present invention rather than whole embodiment.
It should be noted that program has global variable step, the step that record both sides perform altogether to current situation from beginning Number, initial value is zero.
Embodiment 1
When step is less than 10 more than or equal to 6, arranging default search degree of depth M is 4;With the generation tactics of valuation, by valuation Sequence tactics stack, beta pruning leaves the tactics sorted at front K4;Payment multithreading runs.
Each thread calls AlphaBeta function respectively, and employing selectively produces mode and generates next layer of tactics, arranges by valuation Sequence, then beta pruning, make tactics respectively less than K6 according to degree of depth difference, and K7, K8 are individual.
The tactics that traversal generates, performs it, again calls AlphaBeta and enters lower floor.
Search depth successively decreases in a recursive process, until being 0, then calls evaluation function, and returns;Do not recall AlphaBeta.This valuation uses the parameter more sensitive to flexibility ratio.
According to Policy Updates alpha, beta, best value, revise AlphaB.Return to upper strata again after traveling through all tacticses.
Until returning to top layer, according to the Policy Updates best tactics of this thread in MultiThread function.
After all threads terminate, the comprehensive best tactics of each thread selects the overall situation preferably tactics.
Embodiment 2
As step more than or equal to 20 less than 32, use more fully tactics to generate on the basis of embodiment 3, i.e. generating Selectivity is not had during tactics.
Embodiment 3
As step more than or equal to 32 less than 48, arranging default search degree of depth M is 5;With the generation tactics of valuation, arrange by valuation Sequence tactics stack, beta pruning leaves the tactics sorted at front K5;Subsequent step is same as in Example 1.
In sum, these are only the preferred embodiments of the present invention, be not intended to limit protection scope of the present invention.All Within the spirit and principles in the present invention, any modification, equivalent substitution and improvement etc. made, should be included in the guarantor of the present invention Within the scope of protecting.

Claims (10)

1. the Amazon chess AI algorithm of a game playing by machine, it is characterised in that:
The Amazon chess AI algorithm of a kind of game playing by machine includes searching algorithm and estimation algorithm two aspect;
Wherein, searching algorithm aspect, the feasible tactics sequence that will generate, the beta pruning that can cause of maximum possible maybe can obtain preferably The tactics of effect, concrete, by for each effect assignment with judge tactics quality, come before;Searching algorithm also body Different phase uses Different Strategies now: when search does not arrives the bottom, the tactics of generation can be cropped;And when search arrives Need to launch full tactics during the bottom, tactics is not carried out cutting;
Estimation algorithm aspect, on the one hand, capture parameter occupy by adding region, make the judgement to capturing grid more accurate; On the other hand, use different valuation parameter in different phase, judge which degree is chess game proceeded to based on step number, then determine to make Use which kind of parameter, further according to situation, valuation parameter is dynamically adjusted;
Additionally, searching algorithm also uses the multithreading of optimization: on the one hand make to share resource the fewest, to prevent from waiting that resource disappears The time of consumption;On the other hand, make each cross-thread have mutually exclusive and share valuable resource, thus promote AlphaBeta algorithm Efficiency;Concrete parameters optimization mainly includes global variable AlphaB, variable i in MultiThread function, is introduced by variable best AlphaBeta function, and improve in AlphaBeta algorithm the mechanism returning and updating beta value;
It addition, the bottom at AlphaBeta uses more new sort, other layer uses valuation sequence.
The Amazon chess AI algorithm of a kind of game playing by machine the most as claimed in claim 1, is further characterized in that:
The Amazon chess AI algorithm of a kind of game playing by machine, relates generally to such as minor function:
The Amazon chess AI algorithm of a kind of game playing by machine the most as claimed in claim 1, is further characterized in that:
The Amazon chess AI algorithm of a kind of game playing by machine, specifically comprises the following steps that
Step one, statement global variable initialization step number of playing chess are 0;
Step 2, search for and select the tactics that can use;
Step 3, call createMove generate feasible tactics, the tactics meeting condition is stored in tactics stack together with valuation Return:
The described condition that meets is that produced tactics is begun a little or at the obstacle that falls, and has the other side within more at least meeting five steps Chess piece;
Step 4, call process multithreading function MultiThread, particularly as follows:
Step 4.1 states variable i, arranges mutual exclusion lock for global variable ST, in mutual exclusion lock, the value of ST is assigned to i, and adds to ST 1;Then the mutual exclusion lock of ST is discharged;
All top layer tacticses that step 4.2 traversal step three generates;
Step 4.2.1 each tactics to traversing, performs AlphaBeta search on simulation chessboard, returns estimating of this tactics Value;Cancel the execution of this tactics on simulation chessboard again;
If step 4.2.2 step 4.2.1 returns the valuation of tactics more than the best valuation of current thread, then amendment current thread is Good tactics, and record new best valuation;
Step 4.2.3 is that global variable AlphaB arranges mutual exclusion lock, if judging that in mutual exclusion lock the best valuation of current thread is big In the overall situation best valuation AlphaB, then the amendment overall situation preferably tactics and AlphaB, and update the overall situation preferably tactics BestMove, so The mutual exclusion lock of rear release AlphaB;
Step 5, call AlphaBeta function and scan for;
Step 5.1 judges search depth, carries out corresponding operating:
If 5.11 search arrive the end, the most incoming parameter depth==0, then call evaluation function Evaluate, and return is estimated Value;
5.12 otherwise, calls createMove_selecteval or createMove_eval and generates tactics, meanwhile, to each life Become tactics to call Evaluate and carry out valuation, generate after whole tactics according to valuation, i.e. tactics is carried out by Evaluate return value Sequence, particularly as follows:
5.12.1 within 20 steps, selectively generate tactics, i.e. call createMove_selecteval function and generate Tactics;
The most otherwise generate whole tactics, i.e. call createMove_eval function to generate tactics;
Step 5.2 carries out cutting according to search depth to tactics, particularly as follows:
5.2.1 the not cutting tactics when search depth depth is 1;
5.2.2 it is 2 as search depth depth and tactics number is more than K6, then retains the sequence tactics at front K6;
5.2.3 it is 3 as search depth depth and tactics number is more than K7, then retains the sequence tactics at front K7;
5.2.4 it is 4 as search depth depth and tactics number is more than K8, then retains the sequence tactics at front K8;
Wherein, preferred K6 is 300, it is also possible to be greater than 250 integers less than 350;
Wherein, preferred K7 is 200, it is also possible to be greater than 150 integers less than 250;
Wherein, preferred K8 is 100, it is also possible to be greater than 80 integers less than 120;
Step 5.3 judges whether current tactics number is 0, and carries out corresponding operating:
If the 5.31 tactics numbers generated are 0, illustrate that chess game is over, return-INF+ (maxdepth-depth);
If the 5.32 tactics numbers generated are not 0, then continue step 5.4;
The step 5.4 tactics valuation to producing, and return the best valuation of this layer or first valuation more than beta;
Step 6, call evaluation function Evaluate;
Step 6.1 is called this function of Evaluate and is calculated qstep and kstep;
Step 6.2 calculates four basic underlying variables again: t1, t2, c1, c2;These four values are the most initial when calling evaluation function every time Turn to 0, specifically comprise and operate as follows:
Step 6.2.1 determines the value of t1 by a and b:
A. award, non-present play chess is divided to give when certain grid both sides' qstep value gives t1x simultaneously for current play chess color Give the punishment that-t1x divides, then the mark of this award or punishment is added on t1;
Wherein, described t1x fraction range is 0.0 to 1.0;
B., when our qstep value is less, make t1 obtain bonus point score, otherwise obtain a negative point of-score;Value be The number of the chess piece of this grid can be arrived, i.e. for the lattice that can arrive with minimum step number with the step number representated by qstep Son, the quantity of the chess piece that record can arrive with minimum step number;
Wherein, described score fraction range is the integer more than 1, does not the most set the upper limit;
A, b use to prevent the situation many with an enemy simultaneously;
Step 6.2.2 calculates the value of t2, particularly as follows: travel through all kstep, when our kstep value is less, and t2 adds 1, works as the other side Kstep value is less, and t2 subtracts 1;
Step 6.2.3 calculates the value of c1 and c2, particularly as follows:
C1+=(pow (2.0 ,-qstep [thread] [i] [j] [0])-pow (2.0 ,-qstep [thread] [i] [j] [1]));
C2+=min (1, max (-1, (kstep [thread] [i] [j] [1] .st-kstep [thread] [i] [j] [0] .st)/ 6.0));
Note: thread represents current thread number, grid on i, j correspondence chessboard, and the most one-dimensional is 0 to represent us, and 1 represents the other side;
Step 6.3 statement calculates variable occupy, and to compose occupy initial value be 1, then will when certain grid only has us to arrive Occupy adds one, otherwise subtracts 1 by occupy, i.e. occupy have recorded the space quantum count that our current situation has been captured;
Variable sumA [2] is stated and calculated to step 6.4;
So far, through step one to step 6, the Amazon chess AI algorithm of a kind of game playing by machine is completed.
The Amazon chess AI algorithm of a kind of game playing by machine the most as claimed in claim 3, is further characterized in that:
A kind of Amazon chess AI algorithm of game playing by machine, in step one, the global variable of statement is as follows:
1.1 statement AlphaB are for recording best valuation comprehensive in multithreading;
1.2 statement maxdepth define search depth;
1.3 statement MOVEi record the numbering of the respective best tactics of each thread;
The best tactics of the 1.4 statement BestMove record overall situations;
1.5 statement qstep and kstep are for evaluation function;
1.6 statement ST;
1.7 statement totalTime record overall situations start total used time up till now;
1.8 statement movestack are used for storing tactics, and movestack is also known as tactics stack;
Wherein, the minimum step needed for a certain grid of arrival it is continuously traveling during the implication of qstep is four chess pieces along single direction Number;
The implication of kstep is the minimum step number needed for a certain grid that in four chess pieces, at random single step traveling in direction arrives;ST Implication for record top searched which tactics.
The Amazon chess AI algorithm of a kind of game playing by machine the most as claimed in claim 3, is further characterized in that:
Step 2 specifically includes again following steps:
Step 2.1 call entry function search_a_goodmove;
Step 2.2 is initialization section global variable in function search_a_goodmove: wherein said part global variable Mainly include global variable AlphaB;
Described AlphaB initial value is-INF;
Step 2.3 draws search depth value M according to step number of playing chess;
Step 2.4 is called createMove_eval and is generated tactics;
Each tactics generated is called Evaluate function by step 2.5, and all tacticses are called Evaluate function Return value is ranked up;
Step 2.6 according to step number and step 2.5 is called createMove_eval generate tactics carry out cutting;
Search depth value M when total used time totalTime was more than 14 minutes, is then set to 4 by step 2.7;
Step 2.8 is called MultiThread function and is started multithreading;
Step 2.9 waits until all thread end of runs of step 2.7, deletes multithreading and returns.
The Amazon chess AI algorithm of a kind of game playing by machine the most as claimed in claim 5, is further characterized in that:
Step 2.3 particularly as follows:
Step 2.3.1 is when step number step is less than K1, then search depth value M is 4;
Step 2.3.2 is less than K2 when step number step more than or equal to K1, then search depth value M is 5;
Step 2.3.3 is when step number step is more than or equal to K2, then search depth value M is 6;
Wherein, preferred K1 is 32, it is also possible to be greater than 20 integers less than 38;
Wherein, preferred K2 is 48, it is also possible to be greater than 30 integers less than 60.
The Amazon chess AI algorithm of a kind of game playing by machine the most as claimed in claim 3, is further characterized in that:
Concrete, the execution process of step 3 includes:
Step 3.1 to we four chess pieces in each chess piece do following 3.11 and 3.12 two operations, draw one feasible Tactics;
3.11 travel through four direction up and down from chess piece, then travel through most 10 feasible steps on each direction, find symbol Close the grid begun, then travel through all grid meeting and beginning, each grid is performed 3.12;
3.12 from each grid begun, and travels through four direction up and down, then travels through on each direction most 10 Feasible step, finds the grid that can place obstacles;
Step 3.2 does following four generic operations respectively according to the feasible tactics that step 3.1 draws:
Step 3.2.1 is called after createMove obtains feasible tactics and is directly stored in tactics stack, continues search for other tacticses;
Step 3.2.2 is called createMove_eval and is performed tactics, calls evaluation function, and obtaining the valuation after performing tactics (can Think and be the valuation of this tactics), valuation and tactics are all stored in tactics stack;
Step 3.2.3 is called createMove_select and is first checked tactics after producing tactics, if meet following bar Part:
Produced tactics is begun a little or at the obstacle that falls, and has square chess within more at least meeting five steps;
Again the tactics meeting condition is added tactics stack;
Step 3.2.4createMove_selecteval combines 3.2.2 and 3.2.3, will meet the tactics of condition together with valuation one Rise and be stored in tactics stack;
After step 3.3 traversal terminates, return.
The Amazon chess AI algorithm of a kind of game playing by machine the most as claimed in claim 3, is further characterized in that:
Step 5.4 particularly as follows:
Step 5.4.1 statement variable best, and it is initialized as-1, current preferably valuation is assigned to best;
Step 5.4.2 traversal perform step 5.1 and 5.2 produce all tacticses and enter next layer of AlphaBeta, recurrence until Return valuation;
After step 5.4.3 obtains the valuation of step 5.4.1, if valuation is more than best, then the valuation obtained is assigned to best;
If the valuation of step 5.4.4 is more than beta, then return valuation;
After step 5.4.5 traversal terminates, if there being more preferable tactics, then record and update;
Step 5.4.6 returns best.
The Amazon chess AI algorithm of a kind of game playing by machine the most as claimed in claim 5, is further characterized in that:
Step 2.6 particularly as follows:
2.6.1 it is more than K4 when step number step less than K3 and tactics number, then retains the sequence tactics at front K4;
2.6.2 it is more than K5 when step number step more than or equal to K3 and tactics number, then retains the sequence tactics at front K5;
Wherein, preferred K3 is 32, it is also possible to be greater than 6 integers less than 36;
Wherein, preferred K4 is 300, it is also possible to be greater than 200 integers less than 400;
Wherein, preferred K5 is 400, it is also possible to be greater than 300 integers less than 500.
The Amazon chess AI algorithm of a kind of game playing by machine the most as claimed in claim 3, is further characterized in that:
Variable sumA [2] is stated and calculated to step 6.4;
Wherein, described sumA [2] represents the flexibility ratio of both sides' chess piece, and computational methods are as follows:
Step 6.4.1 calculates its flexibility ratio for each chess piece: find this chess piece one step the most accessibility all spaces, right Distance in each space subrecord chess piece and space is designated as i, then calculates around this space in 8 grid as empty lattice Quantum count is designated as N;Calculate A=N*pow (2.0 ,-i);Such one can be obtained for all chess piece one steps accessibility space Individual A, flexibility ratio AM of chess piece is the sum of all such A;
Step 6.4.2sumA is the sum of four chess piece each AM;Both sides are calculated to flexibility ratio, both sides can be obtained respective sumA。
CN201610369682.2A 2016-05-30 2016-05-30 AI algorithm for game of the Amazons based on computer game playing Pending CN105999689A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610369682.2A CN105999689A (en) 2016-05-30 2016-05-30 AI algorithm for game of the Amazons based on computer game playing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610369682.2A CN105999689A (en) 2016-05-30 2016-05-30 AI algorithm for game of the Amazons based on computer game playing

Publications (1)

Publication Number Publication Date
CN105999689A true CN105999689A (en) 2016-10-12

Family

ID=57091495

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610369682.2A Pending CN105999689A (en) 2016-05-30 2016-05-30 AI algorithm for game of the Amazons based on computer game playing

Country Status (1)

Country Link
CN (1) CN105999689A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107050839A (en) * 2017-04-14 2017-08-18 安徽大学 Amazon chess game playing by machine system based on UCT algorithms
CN108647374A (en) * 2018-03-22 2018-10-12 中国科学院自动化研究所 Tank tactics Behavior modeling method and system and equipment in ground force's tactics war game game
CN110038303A (en) * 2019-03-14 2019-07-23 北京达佳互联信息技术有限公司 AI object matching method, system and electronic equipment and storage medium
CN112755538A (en) * 2021-04-07 2021-05-07 中国科学院自动化研究所 Universal multi-agent gaming algorithm

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107050839A (en) * 2017-04-14 2017-08-18 安徽大学 Amazon chess game playing by machine system based on UCT algorithms
CN108647374A (en) * 2018-03-22 2018-10-12 中国科学院自动化研究所 Tank tactics Behavior modeling method and system and equipment in ground force's tactics war game game
CN108647374B (en) * 2018-03-22 2020-11-17 中国科学院自动化研究所 Tank tactical behavior simulation method, system and equipment in army tactical chess game
CN110038303A (en) * 2019-03-14 2019-07-23 北京达佳互联信息技术有限公司 AI object matching method, system and electronic equipment and storage medium
CN112755538A (en) * 2021-04-07 2021-05-07 中国科学院自动化研究所 Universal multi-agent gaming algorithm
CN112755538B (en) * 2021-04-07 2021-08-31 中国科学院自动化研究所 Real-time strategy game match method based on multiple intelligent agents

Similar Documents

Publication Publication Date Title
CN105999689A (en) AI algorithm for game of the Amazons based on computer game playing
Saffidine et al. Solving breakthrough with race patterns and job-level proof number search
CN107622092B (en) Searching method of the Chinese chess based on Multiple Optimization, Iterative deepening beta pruning
Hyatt et al. Cray blitz
CN107661622A (en) It is a kind of to generate method of the quintet game to office data
Pawlewicz et al. Stronger virtual connections in hex
CN108871344A (en) Soccer robot GGRRT paths planning method
CN110465086A (en) A kind of game articles methods of exhibiting, device and storage medium
CN108446814A (en) With the tree searching method and device of sequential pipeline Job-Shop problem
CN106407670A (en) Game algorithm-based black and white chess game method and system
CN109343913B (en) Game behavior tree control method
CN117180750A (en) Non-user role control method, device, equipment and medium based on behavior tree
CN107894923A (en) A kind of general computer game problem decision search engine class libraries
Papadopoulos et al. Exploring optimization strategies in board game abalone for alpha-beta search
Fujiki et al. A platform for turn-based strategy games, with a comparison of Monte-Carlo algorithms
Sephton et al. Parallelization of information set monte carlo tree search
CN101890220A (en) Method for judging possibility of cards larger than cards of opponent on left by hand pattern
CN109646946B (en) Chess and card game hosting method and device
Wehr et al. Mining game logs to create a playbook for unit AIs
Zhang et al. A generic archive technique for enhancing the niching performance of evolutionary computation
Oakes Practical and theoretical issues of evolving behaviour trees for a turn-based game
Friedmann et al. Local strategy improvement for parity game solving
Nan et al. Turn-based war chess model and its search algorithm per turn
Hoffmann et al. What makes the difference between HSP and FF
CN106992962A (en) Method of the virtual machine based on multi-tenant in cloud data center security configuration

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20161012

RJ01 Rejection of invention patent application after publication