# Legal Moves

This section introduces the concept of a **legal move**. Legal moves should be distinguished from legal tactics: a "move" is a change in an agent's tactics, whereas a tactic vector is legal if it meets certain conventions.

## The Concept of Legality

When a power structure has symmetric, ternary tactics and one player makes a move, they also alter an opposing player's relationship to them, due to Heuristic 1. The problem is that if the focal agent is allowed to make whatever move she wants, she could force the other player into a situation that is against their interests. For example, in the following sequence, the focal agent initiates cooperation with a larger competitor whose PrinceRank drops as a result.

To avoid this sort of situation, we introduce the concept of a legal move. A move is only considered legal if, *where an agent's desired tactic requires increased positivity, it also increases the PrinceRank of the other agent*. In other words, if cooperation increases, it has to be in the other player's interest. On the other hand, a player can start a conflict unilaterally. This rule enforces consistency with Heuristic 1.

The need for move legality is due to the use of symmetric tactics, which are used due to the challenge of modeling reciprocity in a game (see Axelrod 2006). This challenge arises in the context of game tree search because of the backward induction problem: players have an incentive to defect in the last round, making it difficult for cooperation to be sustained. It would be interesting to explore how reciprocity might emerge in a quantitative realist model, perhaps using machine learning, instead of assuming it.

## Generating Legal Moves

Given a power structure, we want to be able to find nearby legal moves. Below are two ways to generate them.

### Systematic Search

One way to implement legality checking is with the following function, which takes two power structures and an agent index as input, and returns a Boolean indicating whether the proposed move from `ps1`

to `ps2`

is legal.

```
LegalMoveQ[ps1_, ps2_, i_] := Block[{j},
For[j = 1, j <= Length[ps1["s"]], j++,
If[i != j && T2[[i, j]] > T1[[i, j]] && pr2[[i]] <= PrinceRank[ps1][[i]],
Return[False]]
];
Return[True];
]
```

With this function, one can then look at all nearby tactics and test to see which are legal. Unlike the method below, here only a single agent moves and the agent can unilaterally increase the positivity of a relationship.

### Random Alteration then Symmetrization

A second way to generate legal moves is to randomly alter a ternary tactic matrix and then symmetrize it. This method is intended for a simultaneous move situation and it complies with the definition of legality above because it simply prohibits increased positivity from occurring unless both parties want it. It is much faster than systematic search, but it tends to produce tactic matrices that skew negative, since `SymmetrizeT`

effectively "rounds down" each pairwise interaction. This tendency can be mitigated by choosing fewer -1's and 0's when randomly altering the matrix.