# Programmatic method to determine if a move is passive or aggressive

I'm currently trying to determine if a player on average plays more aggressive or defensive games. To do this I wanted to look at a game from that player, then average the amount of aggressive moves vs defensive moves. But the real issue is identifying if a move is aggressive or defensive.

I am looking for a method to determine if it's aggressive or defensive using a Machine learning/AI type algorithm, rather then having a bunch of if-else statements. I've seen this other question regarding this topic. In an answer to that question, user @HelloWorld recommended to use something called the "Monte-carlo tree search". I've done some basic research of the search, and I don't understand what they mean by "margin error". Can someone explain what that means and how it ties to this topic?

Also if you have any other algorithms to determine if a move is passive or aggressive, I'd love to hear it.

• some moves are both. and what the move is depends on the position and what the other player is doing. i doubt the information you ask about will have any practical use. – edwina oliver Feb 21 '20 at 13:58
• What kind of machine learning algorithm are you thinking of? Supervised or Unsupervised? – Michael West Feb 21 '20 at 14:45
• @MichaelWest I'm more familiar with supervised algorithms, but I am also open to unsupervised. I just want the algorithm to be any type of ML. – Tarun R Feb 21 '20 at 16:12
• please define what you mean by passive aggressive moves – edwina oliver Feb 21 '20 at 19:33

As described here the min-max algorithm is used in order to get the best strategy from any position in games, and therefore in chess. It uses tree ordering of the moves and each layer in the tree describes another player's move. The leaves at the bottom of the tree are the "values" gained from reaching this position with the sequence of moves from going down the tree. The algorithm assumes that the other player is playing his best possible moves also. This algorithm was used for example in Deep Blue, but the problems were that the branching factor of each node in the tree gets huge after couple of moves. So this is very hard to calculate.

In the matter of your question, I don't think you could gain any knowledge about passive/agressive moves from min-max algorithm, as it only tells you the best moves (not knowing if it was passive or agressive). I think a better approach to determine wether a move is agressive or passive will be tagging a large amount of moves in different positions in the game (with tags being 'passive'/'agressive') and training a Neural Network to determine if a new move that it never saw is passive or agressive.

• Thanks for the answer, I think the idea of just tagging a large amount of moves then running a neural network would work - however it would take a long time to do so. I looked online and haven't been able to find any data sets with already tagged data. Is there anydata sets you/others know of which has it? – Tarun R Feb 22 '20 at 3:46
• I don't know if there are any databases available for this goal, but when searching for one you might consider the scope of the question - wether you want a passive/agressive binary tags or a value, say between 0 and 1, indicating how passive or aggressive is that move (0 being the most passive in that case). Since Neural Networks could deal with both cases i'd say the second one will be more informative for your cause but more difficult to be tagged. – Roy Levy Feb 22 '20 at 9:32

Other algorithms for solving chess problems are min-max algorithm. What it does it tries to maximize your position and to minimize opponent's moves.

• Thanks for the answer, can you please elaborate on what you mean by maximizing your position and minimizing opponents move, and how will I go calculate that. – Tarun R Feb 21 '20 at 14:18
• what does that have to do with passive vs aggressive? – edwina oliver Feb 21 '20 at 16:41
• @TarunR basically you need to convert chess position to a number that quantifies how good is your position. One simple implementation would be to count figures. Other more serious implementation would be to count active pieces in addition and to involve not only this position but to go in depth and analyze up to 10 moves ahead and incorporate all that chess position number to the first position number to signify good prospects of the position. – blackuprise Feb 27 '20 at 16:46

Rather than using the engine evaluation, I suggest you to review how the engine evaluate threats and how you could capture such data.

For instance, a possible activity or aggresive order from more to less could be: A mate threat > loss of material > loss of space > overloading a piece > weakening the King's castle > pawns doubled > mobility reduced > piece with reduced mobility > piece distance to own king, etc.

An aditional element is how an engine determines which pieces or squares are insuficiently defended or attacked and how this was changed with the previous move. In a elementary book I read moves were classified as attacking moves, defending moves or developing moves. Later I learned that we must consider also in-between moves in dinamic positions.

The idea of an aggressive move and passive move is quite intuitive to my knowledge, but here is the general outline for whether a move is aggressive or not(These are very general and in some cases don't work):

Aggressive: 2 square pawn move, pawn move which threatens a piece, moves which threaten common tactics(pin, fork, skewer, etc...), checkmate threats, aim to open up position, avoiding queen trade, and more..., flank pawn moves, sacrifices, and etc...

Passive: 1 square pawn moves, Retreating moves, aim to close position, aiming at queen trades, and etc...

Assign a value to each of these categories positive being aggressive and negative being passive.

Example: A knight retreats and attacks the opponent's queen. A retreating move could be -10 and attacking the queen could be +15. This would give that move a value of +5. The rest is just as you said averaging for the entire game.

By "margin error", i.e. "margin of error", HelloWorld probably means the standard deviation of the distribution of results, possibly implying that an aggressive move will converge on a result faster than a passive move. One way to classify using that idea would be to calculate the length of a game following each candidate move, sort in ascending order, and label the ones in the top half "aggressive" and the rest "passive". This way you can label all moves in a given game and decide whether a player is passive or aggro.