# Turn-Based War Chess Model and Its Search Algorithm per Turn

Authors: Hai Nan; Bin Fang; Guixin Wang; Weibin Yang; Emily Sarah Carruthers; Yi Liu
Journal: International Journal of Computer Games Technology
 (2016)

---

## Abstract

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.


---

## Body

## 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.Figure 1
Wargaming and SLG game.
(a)
Wargaming
(b)
SLG game “Battle Commander”Figure 2
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 (Section3.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 (Algorithm2) 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 Chess

### 2.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 (Figure3). 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.Figure 3
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 (Figure4), including the tile occupied by the unit itself. The movement range can generally be calculated by some algorithm such as breadth first search [18].Figure 4
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) TiltA 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.
(a)
(b)
(c)
(d)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 (Figure5). 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.Figure 5
Units’ attack range.
(a)
Swordsmen’s attack range
(b)
Archer’s attack rangeEach 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 graphG(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.LetOrdC 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.LetQC be a set of all sequences of the elements in set C such that QC=OrdC. Thus, QC=Pnn.Without loss of generality, letOrdA be an action sequence of units inAlex’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 (Figure6), 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].Figure 6
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.


## 2.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 (Figure3). 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.Figure 3
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 (Figure4), including the tile occupied by the unit itself. The movement range can generally be calculated by some algorithm such as breadth first search [18].Figure 4
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) TiltA 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.
(a)
(b)
(c)
(d)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 (Figure5). 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.Figure 5
Units’ attack range.
(a)
Swordsmen’s attack range
(b)
Archer’s attack rangeEach 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 graphG(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.LetOrdC 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.LetQC be a set of all sequences of the elements in set C such that QC=OrdC. Thus, QC=Pnn.Without loss of generality, letOrdA be an action sequence of units inAlex’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 (Figure6), 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].Figure 6
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 Analysis

### 3.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 (Figure7). 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 ofAlex’s turn).Figure 7
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 isPnAnA=nA!.Step 2.
Calculate the number of all plans of action in a specified action sequence.LetRi 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 ofAlex’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 ofAlex’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 Step1, 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 thatR1=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 byS, is(4)Sbest<S≤Sworst.In the following examples, we calculate the actual values of the total plansS. 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.Figure 8
The growth trend of statesS following nA under different movement points. (a) Movement point: 2, movement cost: 1; (b) movement point: 5, movement cost: 1.
(a)
(b)


### 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. Table1 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.Table 1
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 (Figure9). 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.Figure 9
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.


## 3.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 (Figure7). 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 ofAlex’s turn).Figure 7
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 isPnAnA=nA!.Step 2.
Calculate the number of all plans of action in a specified action sequence.LetRi 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 ofAlex’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 ofAlex’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 Step1, 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 thatR1=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 byS, is(4)Sbest<S≤Sworst.In the following examples, we calculate the actual values of the total plansS. 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.Figure 8
The growth trend of statesS following nA under different movement points. (a) Movement point: 2, movement cost: 1; (b) movement point: 5, movement cost: 1.
(a)
(b)


## 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. Table1 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.Table 1
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 (Figure9). 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.Figure 9
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.


## 4. Single-Round Search Algorithms

### 4.1. Algorithm2: Dictionary Sequence Enumeration Algorithm

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 Section3.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 ofnA 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, callednext_permutation, which generates the next sequence from an original one, is illustrated as in Algorithm 1.Algorithm 1:
next_permutation(Ord).
Input: the original permutation sequence
Ord=Ord1Ord2⋯Ordj-1OrdjOrdj+1⋯Ordk-1OrdkOrdk+1⋯Ordn
(1) findj=max⁡i∣Ordi<Ordi+1
(2)if  j doesn’t exist then
(3)exit, and next permutation sequence doesn’t exist.
(4)else
(5) findk=max⁡i∣Ordi>Ordj
(6)swap(Ordj, Ordk)
(7) reverse the sub-sequenceOrdj+1⋯Ordk-1OrdjOrdk+1⋯Ordn
(8)Output: Ord′=Ord1Ord2⋯Ordj-1OrdkOrdn⋯Ordk+1OrdjOrdk-1⋯Ordj+1 is the
next permutation sequence.
(9)end ifAlgorithm 2:Dictionary sequence enumeration algorithm.
(1) initialize a sequenceOrd which is the first sequence in dictionary sequences
(2)while  Ord exists do
(3) callSearch(1)
(4)Ord←next_permutationOrd
(5)end whileFor example, 754938621 is a sequence of numbers 1–9. The next sequence obtained by this algorithm is 754961238.


#### 4.1.2. Algorithm2: Dictionary Sequence Enumeration Algorithm

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 Algorithm2.HereSearch(i) is the algorithm for enumerating all of the action plans of the ith unit (see Algorithm 3).Algorithm 3:
Search(i).
(1)if  i>n  then
(2)return
(3)else
(4)for each action plan of the ith unit
(5)  execute the current plan
(6)call  Search(i+1)
(7)  cancel this plan and rollback to the previous state
(8)end for
(9)end if


### 4.2. Algorithm5: Recursive Enumeration Algorithm

Algorithm2 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 therecursive enumeration algorithm illustrated as in Algorithm 4.Algorithm 4:
recursive_permutation(i) (enumerate sequences from  ith to the last element).
(1)if  i≥n  then
(2) output the generated sequenceOrd1,Ord2,…,Ordn
(3)return
(4)else
(5)j←i
(6)while  j≤n  do
(7)swap(Ordi, Ordj)
(8)call  recursive_permutation(i+1)
(9)swap(Ordi, Ordj)
(10)j←j+1
(11)end while
(12)end ifAlgorithm 5:Recursive enumeration algorithm: Plans_Search(i) (search action plans from  ith to the last unit).
(1)if  i>n  then
(2)return
(3)else
(4)j←i
(5)while  j≤n  do
(6)swap(Ordi, Ordj)
(7)for each action plan of the ith unit
(8)   execute the current plan
(9)call  Plans_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 ifIn Algorithm4, 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 functionrecursive_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 functionrecursive_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 sequenceOrd and running the functionrecursive_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 Algorithm5.The framework of this new algorithm is similar to that of therecursive_permutationalgorithm, 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 callPlans_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 sequenceOrd is initialized, and then the functionPlans_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 ann 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 Algorithms2 and 5 are the same.Proof.
SupposeSOrd 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 Algorithm5, 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 Algorithms2 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 calculateH1 and H2, respectively.In Algorithm2, 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 Algorithm5, 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.Table 2
(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.
(a)
Movement point 2
Movement point 3
Movement point 4
Dispersed
Compact
Dispersed
Compact
Dispersed
Compact
Algorithm2
14274
9804
97650
79260
423858
371652
Algorithm5
14235
9771
97575
79191
423735
371535
D
ops1
∗
0.27%
0.34%
0.077%
0.087%
0.029%
0.031%
⁢D^ops1∗∗
0.30%
0.080%
0.030%
(b)
Movement point 2
Movement point 3
Movement point 4
Dispersed
Compact
Dispersed
Compact
Dispersed
Compact
Algorithm2
742560
345264
9765600
6394800
69513696
53301744
Algorithm5
740272
343804
9757600
6388468
69492704
53283548
D
ops1
∗
0.31%
0.42%
0.082%
0.099%
0.030%
0.034%
D
^
o
p
s
1

∗
∗
0.30%
0.080%
0.030%
∗
D
o
p
s
1 shows the reduced percentage of using ops1 in Algorithm 5 instead of in Algorithm 2.
∗
∗
D
^
o
p
s
1 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.


## 4.1. Algorithm2: Dictionary Sequence Enumeration Algorithm

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 Section3.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 ofnA 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, callednext_permutation, which generates the next sequence from an original one, is illustrated as in Algorithm 1.Algorithm 1:
next_permutation(Ord).
Input: the original permutation sequence
Ord=Ord1Ord2⋯Ordj-1OrdjOrdj+1⋯Ordk-1OrdkOrdk+1⋯Ordn
(1) findj=max⁡i∣Ordi<Ordi+1
(2)if  j doesn’t exist then
(3)exit, and next permutation sequence doesn’t exist.
(4)else
(5) findk=max⁡i∣Ordi>Ordj
(6)swap(Ordj, Ordk)
(7) reverse the sub-sequenceOrdj+1⋯Ordk-1OrdjOrdk+1⋯Ordn
(8)Output: Ord′=Ord1Ord2⋯Ordj-1OrdkOrdn⋯Ordk+1OrdjOrdk-1⋯Ordj+1 is the
next permutation sequence.
(9)end ifAlgorithm 2:Dictionary sequence enumeration algorithm.
(1) initialize a sequenceOrd which is the first sequence in dictionary sequences
(2)while  Ord exists do
(3) callSearch(1)
(4)Ord←next_permutationOrd
(5)end whileFor example, 754938621 is a sequence of numbers 1–9. The next sequence obtained by this algorithm is 754961238.


### 4.1.2. Algorithm2: Dictionary Sequence Enumeration Algorithm

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 Algorithm2.HereSearch(i) is the algorithm for enumerating all of the action plans of the ith unit (see Algorithm 3).Algorithm 3:
Search(i).
(1)if  i>n  then
(2)return
(3)else
(4)for each action plan of the ith unit
(5)  execute the current plan
(6)call  Search(i+1)
(7)  cancel this plan and rollback to the previous state
(8)end for
(9)end if


## 4.1.1. Action Sequence of Units Algorithm

Determining an action sequence ofnA 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, callednext_permutation, which generates the next sequence from an original one, is illustrated as in Algorithm 1.Algorithm 1:
next_permutation(Ord).
Input: the original permutation sequence
Ord=Ord1Ord2⋯Ordj-1OrdjOrdj+1⋯Ordk-1OrdkOrdk+1⋯Ordn
(1) findj=max⁡i∣Ordi<Ordi+1
(2)if  j doesn’t exist then
(3)exit, and next permutation sequence doesn’t exist.
(4)else
(5) findk=max⁡i∣Ordi>Ordj
(6)swap(Ordj, Ordk)
(7) reverse the sub-sequenceOrdj+1⋯Ordk-1OrdjOrdk+1⋯Ordn
(8)Output: Ord′=Ord1Ord2⋯Ordj-1OrdkOrdn⋯Ordk+1OrdjOrdk-1⋯Ordj+1 is the
next permutation sequence.
(9)end ifAlgorithm 2:Dictionary sequence enumeration algorithm.
(1) initialize a sequenceOrd which is the first sequence in dictionary sequences
(2)while  Ord exists do
(3) callSearch(1)
(4)Ord←next_permutationOrd
(5)end whileFor example, 754938621 is a sequence of numbers 1–9. The next sequence obtained by this algorithm is 754961238.


## 4.1.2. Algorithm2: Dictionary Sequence Enumeration Algorithm

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 Algorithm2.HereSearch(i) is the algorithm for enumerating all of the action plans of the ith unit (see Algorithm 3).Algorithm 3:
Search(i).
(1)if  i>n  then
(2)return
(3)else
(4)for each action plan of the ith unit
(5)  execute the current plan
(6)call  Search(i+1)
(7)  cancel this plan and rollback to the previous state
(8)end for
(9)end if


## 4.2. Algorithm5: Recursive Enumeration Algorithm

Algorithm2 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 therecursive enumeration algorithm illustrated as in Algorithm 4.Algorithm 4:
recursive_permutation(i) (enumerate sequences from  ith to the last element).
(1)if  i≥n  then
(2) output the generated sequenceOrd1,Ord2,…,Ordn
(3)return
(4)else
(5)j←i
(6)while  j≤n  do
(7)swap(Ordi, Ordj)
(8)call  recursive_permutation(i+1)
(9)swap(Ordi, Ordj)
(10)j←j+1
(11)end while
(12)end ifAlgorithm 5:Recursive enumeration algorithm: Plans_Search(i) (search action plans from  ith to the last unit).
(1)if  i>n  then
(2)return
(3)else
(4)j←i
(5)while  j≤n  do
(6)swap(Ordi, Ordj)
(7)for each action plan of the ith unit
(8)   execute the current plan
(9)call  Plans_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 ifIn Algorithm4, 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 functionrecursive_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 functionrecursive_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 sequenceOrd and running the functionrecursive_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 Algorithm5.The framework of this new algorithm is similar to that of therecursive_permutationalgorithm, 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 callPlans_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 sequenceOrd is initialized, and then the functionPlans_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 ann 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 Algorithms2 and 5 are the same.Proof.
SupposeSOrd 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 Algorithm5, 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 Algorithms2 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 calculateH1 and H2, respectively.In Algorithm2, 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 Algorithm5, 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.Table 2
(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.
(a)
Movement point 2
Movement point 3
Movement point 4
Dispersed
Compact
Dispersed
Compact
Dispersed
Compact
Algorithm2
14274
9804
97650
79260
423858
371652
Algorithm5
14235
9771
97575
79191
423735
371535
D
ops1
∗
0.27%
0.34%
0.077%
0.087%
0.029%
0.031%
⁢D^ops1∗∗
0.30%
0.080%
0.030%
(b)
Movement point 2
Movement point 3
Movement point 4
Dispersed
Compact
Dispersed
Compact
Dispersed
Compact
Algorithm2
742560
345264
9765600
6394800
69513696
53301744
Algorithm5
740272
343804
9757600
6388468
69492704
53283548
D
ops1
∗
0.31%
0.42%
0.082%
0.099%
0.030%
0.034%
D
^
o
p
s
1

∗
∗
0.30%
0.080%
0.030%
∗
D
o
p
s
1 shows the reduced percentage of using ops1 in Algorithm 5 instead of in Algorithm 2.
∗
∗
D
^
o
p
s
1 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 Algorithms2 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.Figure 10
(a) Compact placement of three units. (b) Compact placement of four units.
(a)
(b)From Table2, 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.Table2 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 ofDops1 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: Algorithm2 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.(1)
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.(2)
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:(1)
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.(2)
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.



---

*Source: 5216861-2016-03-03.xml*