War chess gaming has so far received insufficient attention but is a significant component of turn-based strategy games (TBS) and is studied in this paper. First, a common game model is proposed through various existing war chess types. Based on the model, we propose a theory frame involving combinational optimization on the one hand and game tree search on the other hand. We also discuss a key problem, namely, that the number of the branching factors of each turn in the game tree is huge. Then, we propose two algorithms for searching in one turn to solve the problem: (1) enumeration by order; (2) enumeration by recursion. The main difference between these two is the permutation method used: the former uses the dictionary sequence method, while the latter uses the recursive permutation method. Finally, we prove that both of these algorithms are optimal, and we analyze the difference between their efficiencies. An important factor is the total time taken for the unit to expand until it achieves its reachable position. The factor, which is the total number of expansions that each unit makes in its reachable position, is set. The conclusion proposed is in terms of this factor: Enumeration by recursion is better than enumeration by order in all situations.
1. Introduction
Artificial intelligence (AI) is one of the most important research fields in computer science, and its related algorithms, technologies, and research results are being widely used in various industries, such as military, psychological, intelligent machines and business intelligence. Computer games, known as “artificial intelligence’s drosophila,” are an important part of artificial intelligence research. With the increasing development of computer hardware and research methods, artificial intelligence research in traditional board games has seen some preliminary results. Alus et al. [1] have proven that Go-Moku’s AI, provided it moves first, is bound to win against any (optimal) opponent by the use of threat-space search and proof-number search. The Monte Carlo Tree Search (MCTS) method, based on UCT (UCB for tree search), has improved the strength of 9 × 9 Go, close to the level of a professional Kudan [2].
Computer game based on artificial intelligence is a sort of deterministic turn-based zero-sum game, containing certain information. Man-machine games can be classified into two categories: two-player game and multiplayer game, according to the number of game players. Most traditional chesses, such as the game of Go and Chess, belong to the two-player game category, to which α-β search based on min-max search and its enhancement algorithms such as Fail-Soft α-β [3], Aspiration Search [4], Null Move Pruning [4], Principal Variation Search [5], and MTD(f) [5] are usually applied. On the contrary, Multiplayer Checkers, Hearts, Sergeant Major, and so forth belong to the multiplayer game category [6] which runs according to a fixed order of actions, with participants fighting each other and competing to be the sole winner of the game. Its search algorithm involves Maxn search [7], Paranoid [6], and so forth. The α-β search previously mentioned based on min-max search is a special case based on the Maxn search and shadow pruning algorithms [7]. Man-machine games can also be classified into two categories: classic board games and new board games, according to the game content. Classic board games involve Go, chess, backgammon, checkers, and so forth, which are widespread and have a long history. While other board games such as Hex [8], Lines of Action [9], and Scotland Yard [10] are ancient games, with the rapid development of modern board games and mobile client applications they have been accepted by more and more players until their prevalence is comparable to that of the classic board game. The machine game algorithms of the board games listed above are all based on α-β search and their enhancement algorithms. The MCTS algorithm has developed rapidly in recent years, being used increasingly in these board games and getting increasingly satisfactory results [8–10].
However, not all board games can be solved with the existing algorithms. Turn-based strategy games (TBS), as well as turn-based battle simulation games (SLG) (hereinafter collectively referred to as turn-based strategy games), originated from the wargames [11] that swept the world in the mid-19th century (Figure 1(a) shows an example of a wargame). With the introduction of computer technology, this new type of game, turn-based strategy game, has flourished (Figure 1(b) shows a famous TBS game called “Battle Commander,” and Figure 2 shows the popular SLG game “Heroes of Might & Magic”). Now, TBS games have become the second most famous type of game after RPGs (role-playing games). With the blossoming of mobile games, TBS games will have greater potential for development in the areas of touch-screen operation, lightweight, fragmented time, and so on. The content of a TBS game generally comprises two levels: strategic coordination and tactical battle control. The latter level, whose rules are similar to those of board games, for example, moving pieces on the board, beating a specified enemy target for victory, and turn-based orders, is called the turn-based war chess game (TBW). The artificial intelligence in TBW is an important component of TBS games. The AI of modern TBS games is generally not so intelligent, of which the fundamental reason is that the AI in its local battle (TBW) is not so intelligent. How to improve the TBW’s artificial intelligence, thus improving the vitality of the entire TBS game industry, is an urgent problem that until now has been overlooked.
Wargaming and SLG game.
Wargaming
SLG game “Battle Commander”
SLG game “Heroes of Might & Magic.”
Currently, the study of artificial intelligence in turn-based strategy games is mainly aimed at its macro aspect, and the research object is primarily the overall macro logistics, such as the overall planning of resources, construction, production, and other policy elements. The main research contents involve planning, uncertainty decisions, spatial reasoning, resource management, cooperation, and self-adaptation. However, studies on artificial intelligence for a specific type of combat in TBS are scarce, and the attention paid to researching the TBW units’ moves, attacks, and presentation of the game round transformation, whose AI is precisely the worst of all parts of the AI in a large number of TBS games, is not enough. At present, the research related to TBW’s behavior involves spatial reasoning techniques. Bergsma and Spronck [12] divided the AI of TBS (NINTENDO’s Advanced Wars) into tactical and strategic modules. The tactical module essentially has to decide where to move units and what to attack. It accomplishes this by computing influence maps, assigning a value to each map tile to indicate the desirability for a unit to move towards the tile. This value is computed by an artificial neural network. However, they unfortunately do not provide any detail on how such a mechanism would work. Paskaradevan and Denzinger [13] presented a shout-ahead architecture based on two rule sets, one making decisions without communicated intentions and one with these intentions. Reinforcement learning is used to learn rule weights (that influence decision making), while evolutionary learning is used to evolve good rule sets. Meanwhile, based on the architecture, Wiens et al. [14] presented improvements that add knowledge about terrain to the learning and that also evaluate unit behaviors on several scenario maps to learn more general rules. However, both approaches are essentially based on rules for the artificial intelligence, resulting in a lack of flexibility of intelligent behaviors, a lack of generality as they depend on a game’s custom settings, and, moreover, a lack of reasoning for more than one future turn, similar to common chess games.
At present, research on TBW’s AI from the perspective of the multiround chess game method is scarce because a TBW’s player needs to operate all his pieces during each round, which is an essential difference with other ordinary chess games. Thus, the number of situations generated by permutation grows explosively such that, from this perspective, the TBW’s AI can hardly be solved during regular playtime by the game approach described previously.
This paper attempts to study TBW’s AI from the perspective of the chess game method. This is because the TBW’s rules have many similarities with other chess games, and the decision made every turn in a TBW can be made wisely as in other chess games. In this paper, we propose two enumeration methods in a single round: dictionary sequence enumeration and recursive enumeration, which is the fundamental problem in our new framework. The improvement in TBW’s AI can not only bring more challenges to game players but also bear a new series of game elements, such as smart AI teammates, which will provide players with a new gaming experience.
A TBW game is essentially the compound of combinational optimization laterally and game tree search vertically (Section 3.2), which can be regarded as a programming problem of multiagent collaboration in stages and can be seen as a tree search problem with huge branching factor. Thus, the expansion and development of the traditional systems hidden behind TBW games will make the research more meaningful than the game itself.
This paper first summarizes the general game model for TBW and illustrates its key feature, that is, that the branching factor is huge in comparison with traditional chess games. Then, it puts forward two types of search algorithms for a single round from different research angles: the dictionary sequence enumeration method (Algorithm 2) and the recursive enumeration method (Algorithm 5). Ensuring invariability of the number of branches, Algorithm 5 has less extension operation of pieces than Algorithm 2 under a variety of conditions. The experiments also confirmed this conclusion.
2. Game Module of Turn-Based War Chess2.1. Rules
TBW is played on a square, hexagonal, or octagonal tile-based map. Each tile is a composite that can consist of terrain types such as rivers, forests, and mountains or built up areas such as bridges, castles, and villages (Figure 3). Each tile imposes a movement cost on the units that enter them. This movement cost is based on both the type of terrain and the type of unit. Each tile is occupied by only one unit at the same time.
An example of TBW: Here are four red units and four blue units belonging to two players, respectively, on a square board. The units are divided into sword men and archers. The number written in the bottom right of each unit is the unit index. White tilts mean their terrain can be entered. However, ochre ones marked by “A” illustrate hilly areas no unit can enter. The dark green tilts marked by letter “B” illustrate lakes or rivers, which also cannot be entered, but archers can remotely attack the other side of the tilts.
Each player in a TWB game controls an army consisting of many units. All units can either move or attack an enemy unit. Each unit has an allotted number of movement points that it uses to move across the tiles. Because different tiles have different movement costs, the distance that a unit can travel often varies. All of the tiles the unit can travel to compose a union of them called movement range (Figure 4), including the tile occupied by the unit itself. The movement range can generally be calculated by some algorithm such as breadth first search [18].
Green tilts illustrate the movement range of a swordsman, whose movement point is 2. The movement cost of each tilt is 1. (a) No obstacle. (b) Tilt A is an obstacle and thus tilt B is out of the movement range. (c) The swordsman cannot pass the enemy to reach tilt B. (d) The swordsman can pass units of the same side to reach tilt B.
In addition to the movement point, each unit has its own health point (Hp) and attack power (ATK), which are numerical values and are various among the different units. Like movement range, a unit’s attack range is another union of tiles to which the unit can attack from its current tile (Figure 5). Commonly, a unit’s attack range is determined by its attack technique. Melee units, such as swordsmen, generally only attack adjacent units, and thus their attack range looks like that shown in Figure 5(a). Ranged attacking units, such as archers, can attack enemies as far as two or more tiles away (Figure 5(b)). Special units’ attack range is also a special one. If a unit attacks another unit, it forfeits all of its movement points and cannot take any further actions that turn; therefore, if a unit needs to be moved to a different tile, it must perform the move action prior to performing an attack action. A unit also has the option not to take any attack action after its movement or even not to take any action and stay on its current tile.
Units’ attack range.
Swordsmen’s attack range
Archer’s attack range
Each unit attacked by its enemy must deduct its Hp by the attacking unit’s ATK, which indicates the damage. When a unit’s Hp is deducted to or below 0, this indicates that it is dead and must be removed from the board immediately. The tilt it occupied becomes empty and can be reached by other following units.
A game of TBW consists of a sequence of turns. On each turn, every player gets their own turn to perform all of the actions for each of their side’s units. This is unlike ordinary board games, such as chess, where turns are only for selecting a pawn to move. The opposing side does not get to perform its actions until the current side has finished. A player wins the game if all of the units or the leader units of the other player have died.
2.2. Setup and Notation
TBW is composed of the board and pieces (units). The board is considered as an undirected graph G(V,E), where V is the set of vertices (tilts) and E is the set of edges that connect the neighboring tilts. Units are divided into two parties A (Alex’s) and B (Billie’s) according to which player they belong to. The sizes of the two parties are denoted as nA and nB, respectively, and the indexes of the units in the two parties are 1,2,…,nA and 1,2,…,nB, respectively. Let n=nA+nB be the total number of units. An assignment M:[1,n]→V places the units in unique tilts: ∀i,j∈[1,n], j≠i:M(i)∈V, M(j)∈V, M(i)≠M(j). For each unit, there is a movement range R⊆V, where r=R, and an attack range Ratk, where ratk=Ratk.
Let OrdC be a sequence of elements in set C such that OrdiC is the ith element of this sequence. We denote n=C, and thus OrdiC∈C and ∀i,j∈[1,n], j≠i:OrdiC≠OrdjC.
Let QC be a set of all sequences of the elements in set C such that QC=OrdC. Thus, QC=Pnn.
Without loss of generality, let OrdA be an action sequence of units in Alex’s turn such that OrdiA expresses the index of the unit doing the ith action, where i∈1,nA.
2.3. Game Tree Search
We try to use game tree search theory to research the AI of TBW. Game tree search is the most popular model for researching common chess games. In the game tree (Figure 6), nodes express states of the game board. Branches derived from nodes express selections of the move method. The root node is the current state, and the leaf nodes are end states whose depths are specifically expanded from the root. Both sides take turns. Even layer nodes belong to the current player (squares), while odd layer nodes belong to the other side (circles). If the leaf node is not able to give a win-lose-draw final state, an evaluation on a leaf node is needed to select the expected better method from the current state; this is the function of game tree search. Game tree search is based on min-max search, which is used to find the best outcome for the player and the best path leading to this outcome (Principal Variation) and, eventually, to find the corresponding move method in the root state (Root Move), that is, the best move for the player’s turn [19].
Game tree expanding to ply 4.
It is not difficult to see that the evaluation and search algorithm are the most important parts of the game tree. For TBW, the evaluation factor of the state generally involves powers, positions, spaces, and motilities of units. The most common algorithms of game tree search are Alpha-Beta search [20] and Monte Carlo Tree Search [21], which can also be, although not directly, applied to TBW’s search. This is because the branching factor of the search tree for TBW is huge and the common algorithms applied to TBW’s search cause a timeout.
3. Features and Complexity Analysis3.1. Complexity Analysis
A game of TBW consists of a sequence of turns. During each turn, every player gets their own turn to perform all of the actions for each of their side’s units, which is the most important feature of TBW. The sequence of actions is vital. This is because the units cannot be overlapped; moreover, a different sequence of actions will also have a different state when a unit of another side is eliminated (Figure 7). Thus, during each side’s turn, all of the plans of actions for its units are calculated by a permutation method. The amount of plans is estimated from both the worst and best situations (e.g., in the case of Alex’s turn).
Effect of actions sequence. (a) The initial state of red side’s turn. (b–d) Red swordsman number 1 acts and eliminates blue swordsman number 1, followed by red swordsman number 2. (e–g) Red swordsman number 2 acts and eliminates blue swordsman number 1, followed by red swordsman number 1.
Step 1.
Determine the sequence of actions: the total number is PnAnA=nA!.
Step 2.
Calculate the number of all plans of action in a specified action sequence.
Let Ri be the movement range of unit number i such that ri=Ri. For simplicity, we assume that r1=r2=⋯=rnA=r. In the worst case, the movement ranges of all of Alex’s units are independent without overlapping each other; that is, ∀i,j∈1,nA, j≠i:Ri∩Rj=⌀. Moreover, in the attack phase, the amount of enemies that fall into each of Alex’s units reaches maximum. For example, on a four-connected board, a melee unit has at most four adjacent tilts around it, which are full of enemies. Then, the number of attack plans is at most five (including a plan not to attack any enemy), that is, ratk+1. According to the multiplication principle, the number of states expanding under a specified actions sequence is(1)rratk+1nA.
According to Step 1, the number of actions sequences is PnAnA=nA! and thus, in the worst situation, the number of plans is(2)Sworst=rratk+1nA×nA!.
In the best situation, the movement ranges of all units overlap completely such that R1=R2=⋯=RnA=R. Moreover, there are no enemies in the attack range of every unit. Thus, the amount of states can be calculated by the arrangement number PrnA such that we can select nA from r positions to make all of the arrangements of the units. Therefore, the number of plans in the best situation is(3)Sbest=r!r-nA!.
Above all, the total number of plans under all action sequences, denoted by S, is(4)Sbest<S≤Sworst.
In the following examples, we calculate the actual values of the total plans S. For “Fire Emblem,” a typical ordinary TBW game, both sides have five units, and in the open battlefield, the movement range of each unit can reach at most 61 tilts (in that map, each tilt is adjacent to four other tilts, the movement point is 5, the movement cost of each tilt is 1, and there is no obstacle). Thus, Sbest≈710 million and Sworst≈317 trillion. Assuming that the average computing time for searching a plan is 200 nanoseconds, searching all plans for one side’s turn will then take from 2.4 minutes to approximately two years. Note that in the formula nA is a key factor such that as it increases, the number of plans will dramatically expand (Figure 8). For a large-scale TBW, such as “Battle Commander,” whose units may amount to no less than a dozen or dozens, the search will be more difficult.
The growth trend of states S following nA under different movement points. (a) Movement point: 2, movement cost: 1; (b) movement point: 5, movement cost: 1.
3.2. Features and Comparison
Compared with TBW games, other board games (such as chess, checkers, etc.) only require selecting a unit to perform an action in a single round, which not only results in fewer single-round action plans but also makes the number of plans linear with increasing numbers of units (for the chess type played by adding pieces, such as Go and Go-Moku, the number of plans is linear with increasing amounts of empty grids on the board). The number of single-round action plans corresponds to the size of the game tree branching factor. Table 1 shows a comparison between TBW games and some other ordinary board games that have more branching factors. A large branching factor and a rapidly expanding number of units are the key features by which the TWB games are distinguished from other board games.
Branching factors comparison between TBW game and other board games.
Branching factor
Comment
Chess [15]
≈30
Maximum branching factor is 40.
Go [16]
≈100
Amazons [17]
≈1500
There are 2176 branches in the first turn.
TBW
710 million~317 trillion
Suppose that the movement point is 5, the movement cost is 1, and the amount of units is 5 for each side.
A TBW game is essentially the compound of combinational optimization laterally and game tree search vertically (Figure 9). Vertically, it can be seen as a tree search problem with a huge branching factor. Laterally, the relationship between layers is a series of phased combination optimizations, which is like a programming problem of multiagent collaboration. Therefore, the new game model generated by the expansion of the explosive branches needs to be researched by new algorithms.
Search tree of TBW game: (a) red side’s turn; (b) blue side’s turn.
Because the large number of states in a single round is the key problem by which the TBW games are distinguished from other board games, the optimization search and pruning of a single round have become the most important issues and processes for solving TBW games. That the search of a single round can be efficiently completed guarantees that the entire game tree can be extended. In the following, we propose two single-round search algorithms and compare them.
Each side of a TBW game (hereafter, unless otherwise stated, referring specifically to Alex’s side) wants to achieve a single turn search. Based on Section 3.1, we need to first determine the sequence of actions of nA units and then enumerate all of the action plans of the units in each sequence.
4.1.1. Action Sequence of Units Algorithm
Determining an action sequence of nA units requires a permutation algorithm. There are some famous permutation algorithms, such as the recursive method based on exchange, the orthoposition trade method, the descending carry method, and the dictionary sequence method [22–25]. Their execution strategies are different, their time and space complexities vary, and they have been used in different problems. We first apply the dictionary sequence method, whose time complexity is lower. The idea of all permutation generation from n elements (e.g., {1,2,…,n}) is that with the beginning of the first sequence (123⋯n) a series of subsequent larger sequences are generated lexicographically until reaching the reverse order (n⋯321). The algorithm, called next_permutation, which generates the next sequence from an original one, is illustrated as in Algorithm 1.
Enumerate all of the plans of units’ actions in a particular order. Because the search depth is limited (equal to the number of units), depth-first search is an effective method. Because the depth is not great, realizing the depth-first search by the use of recursion requires smaller space overhead, which leads to the sequential enumeration algorithm with permutation and recursion, as in Algorithm 2.
Here Search(i) is the algorithm for enumerating all of the action plans of the ith unit (see Algorithm 3).
Algorithm 2 comes from a simple idea that always starts enumeration from the first unit in every search for the next sequence. However, compared with the previous sequence, the front parts of units whose orders are not changed are not required to be enumerated again, which creates redundant computing and reduces efficiency. For example, when the search of sequence Ord1,Ord2,…,Ordi,…,Ordj,…,Ordn is finished, if the next sequential order is adjusted only from the ith to the jth unit, then in the recursive enumeration phases the units from the first one to the i-1th can directly inherit the enumeration results of the previous sequence and we only need to enumerate the units from the ith to the last one recursively. On the basis of this feature, we switch to the recursive permutation algorithm to achieve the arrangement so that the recursive algorithm combines with the recursive depth-first search algorithm for the purpose of removing the redundant computation, which is the improved algorithm called the recursive enumeration algorithm illustrated as in Algorithm 4.
<bold>Algorithm 4: </bold>
<italic>recursive_permutation</italic>(<italic>i</italic>) (enumerate sequences from <inline-formula><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" id="M105"><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:math></inline-formula>th to the last element).
(1) ifi≥nthen
(2) output the generated sequence Ord1,Ord2,…,Ordn
(3) return
(4) else
(5) j←i
(6) whilej≤ndo
(7) swap(Ordi, Ordj)
(8) callrecursive_permutation(i+1)
(9) swap(Ordi, Ordj)
(10) j←j+1
(11) end while
(12) end if
<bold>Algorithm 5: </bold>Recursive enumeration algorithm: <inline-formula><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" id="M116"><mml:mi>P</mml:mi><mml:mi>l</mml:mi><mml:mi>a</mml:mi><mml:mi>n</mml:mi><mml:mi>s</mml:mi><mml:mo>_</mml:mo><mml:mi>S</mml:mi><mml:mi>e</mml:mi><mml:mi>a</mml:mi><mml:mi>r</mml:mi><mml:mi>c</mml:mi><mml:mi>h</mml:mi><mml:mo stretchy="false">(</mml:mo><mml:mi>i</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:math></inline-formula> (search action plans from <inline-formula><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" id="M117"><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:math></inline-formula>th to the last unit).
(1) ifi>nthen
(2) return
(3) else
(4) j←i
(5) whilej≤ndo
(6) swap(Ordi, Ordj)
(7) for each action plan of the ith unit
(8) execute the current plan
(9) callPlans_Search(i+1)
(10) cancel this plan and rollback to the previous state
(11) end for
(12) swap(Ordi, Ordj)
(13) j←j+1
(14) end while
(15) end if
In Algorithm 4, n is the size of our sequence (lines (1), (6)). With respect to the predefined procedure, we generate the permutations from the ith to the last unit in the sequence by calling the function recursive_permutation(i). The latter is realized using the subpermutations from the i+1th to the last unit in the sequence, which are generated by calling the function recursive_permutation(i+1) recursively (lines (5)–(11)). The index j points to the unit swapped with the ith unit (line (7)) in every recursive call, after which the two units must resume their orders (line (9)), for the next step.
By initializing the sequence Ord and running the function recursive_permutation(1), we can obtain a full permutation of all the elements.
Based on the above, the improved single-round search algorithm, called the recursive enumeration algorithm, is described as in Algorithm 5.
The framework of this new algorithm is similar to that of the recursive_permutation algorithm, where n is the number of units. In the new algorithm, all the action plans of the ith unit, which involve selecting targets for attack, are enumerated and executed separately (lines (7)-(8)) after the required swap process. Then, after solving the subproblem using the recursive call Plans_Search(i+1), a rollback of the current plan is necessary and the state needs to be resumed (line (10)).
To enumerate the actions plans of all the units, the sequence Ord is initialized, and then the function Plans_Search(1) runs.
From step (3) of Algorithm 5, before enumerating the action plans of the unit, we do not need to generate all of the sequences; that is, for each unit, determination of its order and enumeration of its actions are carried out simultaneously.
4.3. Comparison
First, we compare the time complexities of the two algorithms.
The time consumption of the recursive enumeration algorithm lies in an n times loop and an n-1 times recursion, such that the time complexity is Onn-1n-2⋯1=On! [23]. It is the same as the time complexity of the dictionary sequence enumeration algorithm [23]. Moreover, the states searched by the two algorithms are also the same.
Theorem 1.
The states searched by Algorithms 2 and 5 are the same.
Proof.
Suppose SOrd is the set of the states in the sequence Ord, and Prea are the sequences beginning with a in QA. According to Algorithm 2, it first determines the order of a sequence Ord and then enumerates all of the states S1 under this sequence:(5)S1=⋃OrdA∈QASOrdA.
According to the outermost layer of the recursion in Algorithm 5, we can obtain all of the states S2:(6)S2=⋃a∈ASPrea.
Because ∪a∈APrea=QA and ∪OrdA∈QAS(OrdA)=S(QA), therefore, S1=S2.
The difference between Algorithms 2 and 5 reflects the efficiency of their enumerations. In the searching process, an important atomic operation (ops1) expands each unit’s action plan on each position it moves to. This is because (1) the states taken by search are mainly composed of every unit moving to every position and (2) every unit arriving at every position and then attacking or choosing other options for action is a time-consuming operation in the searching process. Suppose the number of ops1 in Algorithms 2 and 5 is H1 and H2, respectively. For simplicity, we make the following assumptions.
Assumption 2.
Assume that every unit’s movement range does not overlap another’s, the sizes of which are all equal; that is, R1=R2=⋯=Rn=r, and R1∩R2∩⋯∩Rn=⌀. Moreover, every unit cannot attack after moving (i.e., none of the enemies are inside the attack range).
In the following, we calculate H1 and H2, respectively.
In Algorithm 2, in each identified sequence, ops1 corresponds to the nodes of the search tree formed by enumerating states (except the root node, which represents no action). The depth of the tree is n, and each of the branching factors is r; then, the number of nodes is rn+rn-1+⋯+r. Moreover, the number of all sequences is Pnn=n! and therefore(7)H1=n!rn+rn-1+⋯+r.
In Algorithm 5, suppose that the number of ops1 of n units is hn. The first unit performing an action according to the order of the current sequence is a. According to Algorithm 5, every time a moves to a tilt, it will make a new state combining the following n-1 units, such that the number of the ops1 is 1+hn-1. Because the number of tilts a can move to is r and the recursion operates n times, we can deduce that hn=nr(1+hn-1), where h1=r; thus,(8)H2=hn=n!∑i=0n-1rn-ii!.Accordingly,(9)H1-H2=n!∑i=2n-1i!-1i!rn-i.It is easy to see that the number of ops1 of Algorithm 5 is smaller than that of Algorithm 2. Table 2 lists the experimental results, showing H1 under Assumption 2, H2 under a general condition, and their differences.
(a) For three units, the comparison of ops1 under different movement points and different dispersions. (b) For four units, the comparison of ops1 under different movement points and different dispersions.
Movement point 2
Movement point 3
Movement point 4
Dispersed
Compact
Dispersed
Compact
Dispersed
Compact
Algorithm 2
14274
9804
97650
79260
423858
371652
Algorithm 5
14235
9771
97575
79191
423735
371535
Dops1∗
0.27%
0.34%
0.077%
0.087%
0.029%
0.031%
D^ops1∗∗
0.30%
0.080%
0.030%
Movement point 2
Movement point 3
Movement point 4
Dispersed
Compact
Dispersed
Compact
Dispersed
Compact
Algorithm 2
742560
345264
9765600
6394800
69513696
53301744
Algorithm 5
740272
343804
9757600
6388468
69492704
53283548
Dops1∗
0.31%
0.42%
0.082%
0.099%
0.030%
0.034%
D^ops1∗∗
0.30%
0.080%
0.030%
∗Dops1 shows the reduced percentage of using ops1 in Algorithm 5 instead of in Algorithm 2.
∗∗D^ops1 shows the estimated value of Dops1 under Assumption 2.
Conclusion. On the premise that the search states are exactly the same, Algorithm 5 is better than Algorithm 2 regarding the consumption of ops1 and actual running time.
5. Experimental Evaluation
In this section, we present our experimental evaluation of the performance of Algorithms 2 and 5 under all types of conditions and their comparison. Because they are both single-round search algorithms, we set only one side’s units on the board, ignoring the other side’s, whose interference is equivalent to narrowing the range of units’ movement. Experiments are grouped based on the following conditions: the number of units, the unit’s movement point, and the dispersion of units. The number of units is set to 3 and 4 (setting to 2 is too simple with a lack of universality, while setting to 5 leads to timeout). The movement point is set to 2, 3, and 4, and the movement cost of each tilt is set to 1. The dispersion is set to the most dispersive ones and the most centralized ones. The most dispersive cases mean that the movement ranges of all of the units are independent without overlapping each other, corresponding to the worst case in Section 3.1. The most centralized cases mean that all of the units are put together (Figure 10), which maximizes the overlap degree and corresponds to the best case in Section 3.1. The experimental groups set above cover all of the actual situations. The board used in the experiments is completely open without any boundary and barrier. The case of a board with boundaries and barriers can be classified into cases where a smaller movement point of units is set. The experimental tool is a PC with Intel Core i7-2600@2.40 GHz CPU and 4.00 GB memory, and the program was written with Visual C++ 2005 with optimized running time.
(a) Compact placement of three units. (b) Compact placement of four units.
From Table 2, we can see that in all cases the number of ops1 of Algorithm 5 is less than that of Algorithm 2 for different levels. Assuming that the number of units is invariable, the optimization level of Algorithm 5 will become low by increasing the movement point, which can be deduced from (8) and (9): under Assumption 2, D^ops1 which shows the reduced percentage of using ops1 in Algorithm 5 instead of in Algorithm 2 is (10)D^ops1=H1-H2H1=∑i=2n-1i!-1/i!rn-i∑i=0n-1rn-i.
In (10), the numerator is the infinitesimal of higher order of the denominator; that is,(11)D^ops1≈12r-2.
Table 2 lists the values of D^ops1 when the movement point is 2, 3, and 4, which are consistent with the experimental results.
Under the same conditions of the movement point and the number of units, the value of Dops1 with compact units is more than that with dispersed units. This is because the more the units are compact, the stronger the interference the units will cause to each other, which is equivalent to a narrow movement range of r. According to (11), therefore, Dops1 will increase correspondingly. Moreover, under the same conditions of the movement point and the degree of units’ dispersion, Dops1 will also increase with the increase of the number of units. In summary, the experiments show that, regardless of whether Assumption 2 is satisfied, Algorithm 5 always performs better than Algorithm 2 on the number of ops1, which coincides with D^ops1 from (11). Because the degree of optimization is not very prominent, the running times of these two algorithms are almost the same.
6. Conclusions
Based on a modest study of turn-based war chess games (TBW), a common gaming model and its formal description are first proposed. By comparison with other chess type models, the most important feature of TBW has been discussed: the player needs to complete actions for all of his units in a turn, which leads to a huge branching factor. Then, a game tree theory framework to solve this model is proposed. Finally, two algorithms for single-round search from the most complex part of the framework are proposed: Algorithm 2 is the dictionary sequence enumeration algorithm and Algorithm 5 is the recursive enumeration algorithm. Finally, based on theoretical derivations and experimental results, respectively, the completeness of these algorithms is proven. Also, the performance comparison shows that under all conditions the number of ops1 of Algorithm 5 decreases to a certain extent compared to that of Algorithm 2.
Although these two algorithms are designed from classical algorithms, they can be used to solve the single-round search problem completely and effectively. Moreover, the research angles of the two algorithms are completely different, which provide two specific frameworks for a further study on TBW.
The dictionary sequence enumeration algorithm is implemented in two steps. The first step consists of the generation of sequences; and the second step consists of the enumeration of action plans under these sequences. Therefore, this algorithm is based on sequences. Different permutation algorithms can be used to generate different orders of sequences, which may be more suitable for new demands. For instance, the orthoposition trade method [23] can minimize the difference of each pair of adjacent sequences. Thus, more action plans from the former sequence can be reused for the next, which can improve the efficiency.
The recursive enumeration algorithm is also implemented in two steps. The first step consists of the enumeration of action plans of the current unit; and the second step consists of the generation of the sequences of the next units. Therefore, this algorithm is based on action plans. Pruning bad action plans in the depth-first search process can easily cut off all the following action sequences and action plans of later units, which will lead to a significant improvement of efficiency.
In the current era of digital entertainment, TBW games have broad application prospects. They also have a profound theoretical research value. However, in this study, TBW theory has been discussed partially. The game model framework we proposed is composed of the combinatorial optimization problem on one hand, and the game tree search problem on the other hand. Thus, our future research will mainly start with the following two points:
Introduce the multiagent collaborative planning approach to efficiently prune the huge branches of the game tree. Moreover, by introducing the independent detection approach [26], we can separate the independent units that have no effect on each other into different groups with the purpose of decreasing the number of units in each group.
Introduce the Monte Carlo Tree Search method to simulate the deep nodes. The single-round search algorithms proposed in this paper are complete algorithms and can be used to verify the performance of the new algorithm.
Conflict of Interests
The authors declare that there is no conflict of interests regarding the publication of this paper.
Acknowledgments
This work is supported by the National Key Basic Research Program of China (973 Program 2013CB329103 of 2013CB329100), the National Natural Science Foundations of China (NSFC-61173129, 61472053, and 91420102), the Fundamental Research Funds for the Central University (CDJXS11182240 and CDJXS11180004), and the Innovation Team Construction Project of Chongqing Institute of Engineering (2014xcxtd05).
AlusL. V.van den HerikH. J.HuntjensM. P. H.Go-Moku solved by new search techniquesDengC.NetoH. C.JuliaR. M. S.CaexetaG. S.BarcelosA. R. A.LS-VisionDraughts: improving the performance of an agent for checkers by integrating computational intelligence, reinforcement learning and a powerful search methodLiuY. J.JokićJ.SturtevantN. R.KorfR. E.On pruning techniques for multi-player games49Proceedings of the 17th National Conference on Artificial Intelligence and 12th Conference on Innovative Applications of Artificial Intelligence (AAAI-IAAI '00)July-August 2000Austin, Tex, USA201207LuckhartC.Irani BK.An algorithmic solution of N-person games1Proceedings of the 5th National Conference on Artificial Intelligence (AAAI '86)August 1986Philadelphia, Pa, USA158162BrowneC.A problem case for UCTWinandsM. H. M.BjörnssonY.SaitoJ.-T.Monte Carlo tree search in lines of actionNijssenP.WinandsM. H. M.Monte carlo tree search for the hide-and-seek game Scotland YardWangG.LiuH.ZhuN.A survey of war games technologyBergsmaM. H.SpronckP.Adaptive spatial reasoning for turn-based strategy gamesProceedings of the 4th Artificial Intelligence and Interactive Digital Entertainment Conference (AIIDE '08)October 2008Palo Alto, Calif, USA161166PaskaradevanS.DenzingerJ.A hybrid cooperative behavior learning method for a rule-based shout-ahead architecture2Proceedings of the IEEE/WIC/ACM International Conferences on Web Intelligence and Intelligent Agent Technology (WI-IAT '12)December 2012IEEE Computer Society266273WiensS.DenzingerJ.PaskaradevanS.Creating large numbers of game AIs by learning behavior for cooperating unitsProceedings of the IEEE Conference on Computational Intelligence in Games (CIG '13)August 2013Ontario, CanadaIEEE1810.1109/cig.2013.66336082-s2.0-84892395775BadhrinathanG.AgarwalA.Anand KumarR.Implementation of distributed chess engine using PaaSProceedings of the International Conference on Cloud Computing Technologies, Applications and Management (ICCCTAM '12)December 2012Dubai, United Arab EmiratesIEEE384210.1109/iccctam.2012.64880682-s2.0-84876003347XuX.XuC.Summarization of fundamental and methodology of computer gamesSongJ.MullerM.An enhanced solver for the game of AmazonsGesangD.WangY.GuoX.AI arithmetic design and practical path of a war-chess gameXuX.WangJ.Key technologies analysis of Chinese chess computer gameBošanskýB.LisýV.ČermákJ.VítekR.PěchoučekM.Using double-oracle method and serialized alpha-beta search for pruning in simultaneous move gamesProceedings of the 23rd International Joint Conference on Artificial IntelligenceAugust 2013Beijing, ChinaAAAI Press4854GuezA.SilverD.DayanP.Scalable and efficient Bayes-adaptive reinforcement learning based on Monte-Carlo tree searchSedgewickR.Permutation generation methodsKnuthD. E.HeapB. R.Permutations by interchangesIvesF. M.Permutation enumeration: four new permutation algorithmsSharonG.SternR.GoldenbergM.FelnerA.The increasing cost tree search for optimal multi-agent pathfinding