Predicting An Opponent's Moves Would Enable Deeper Search

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

User avatar
towforce
Posts: 12659
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK
Full name: Graham Laight

Predicting An Opponent's Moves Would Enable Deeper Search

Post by towforce »

A deeper search would obviously lead to better play, and we could get a deeper search if we could predict the opponent's moves.

This thought came to me because I was thinking about conditional universal consistency: many years ago, I wrote some algorithms to play the game of Matching Pennies (you guess which hand I'm hiding the penny in) based on the opponent's pattern of play. I still have the web page I wrote that uses JavaScript to make the guesses (I wasn't able to get friends to play it very much: I required the player to make 50 guesses, which I considered the minimum number to get the benefit of spotting patterns in their play, and they found it too boring: also, it didn't take long to find ways to beat my algorithm). I compared multiple algorithms, and what I found was that conditional universal consistency wasn't just the best algorithm I looked at - it absolutely thrashed all the other algorithms!

To be able to use this algorithm to guess an opponent's move, we need to find a way to classify their moves - so that's what this is really about: how would we go about classifying an opponent's moves in chess? Would it even be possible to do this without building a sophisticated model of their move selection process - which might not be possible because our sample size of their games would be too small (mathematically: number of variables too large for the sample data size)?

To be honest, I'm really thinking about non-chess projects for this - but in theory it absolutely could be applied to chess (though re-reading what I've written here, I think I might just have answered my own question!).

In case anyone is not familiar with conditional universal consistency, I've asked Gemini to describe it for you (I searched for explanations online, but IMO Gemini's is better. Unfortunately, Gemini's beautiful layout of this answer is lost here - but you've got the text):

Gemini wrote:In essence, CUC is a desirable property of learning algorithms (or strategies) used in repeated decision-making scenarios. Imagine a player who repeatedly faces an opponent (or a complex environment) whose behavior is unknown and potentially changing over time. A learning algorithm with CUC has the remarkable ability to:

Adapt and Learn: Figure out the patterns and regularities in the opponent's behavior.

Perform Optimally (Conditionally): Achieve a payoff that is almost as good as if the player knew the true probabilities of the opponent's actions given specific "conditions" or categories of past observations.


How Does It Work?

Categorization: The CUC algorithm divides the history of observed actions and outcomes into different categories or "bins." These categories might be based on patterns, recent history, or other relevant features.

Fictitious Play within Categories: Within each category, the algorithm essentially simulates a game of "fictitious play." This means it tries to predict the opponent's next move based on the frequency of their past actions within that category.

Randomization and Adaptation: To avoid being predictable and exploitable, the CUC algorithm introduces some randomness into its own choices. It also adapts its strategy over time based on new observations and the success or failure of its past decisions.


Why CUC Matters

Robustness: CUC algorithms are robust to changes in the opponent's behavior. They can quickly adapt to new patterns and maintain good performance even in uncertain and dynamic environments.

Theoretical Guarantee: CUC provides a strong theoretical guarantee. It assures that, in the long run, the player's average payoff will be close to optimal, conditional on the information captured by the categorization scheme.

Wide Applicability: The CUC concept is applicable to a variety of settings, including game theory, online learning, and decision-making under uncertainty.


Key Points to Note

Categorization is Key: The effectiveness of a CUC algorithm depends heavily on how well it categorizes the observed history. A good categorization scheme captures the relevant regularities in the opponent's behavior.

Not Always Perfect: While CUC guarantees good performance in the long run, it doesn't mean the algorithm will always make the best decision in every single round. There might be some initial learning and adjustment periods.
Human chess is partly about tactics and strategy, but mostly about memory
User avatar
towforce
Posts: 12659
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK
Full name: Graham Laight

Re: Predicting An Opponent's Moves Would Enable Deeper Search

Post by towforce »

towforce wrote: Sat Jun 29, 2024 11:43 amTo be able to use this algorithm to guess an opponent's move, we need to find a way to classify their moves - so that's what this is really about: how would we go about classifying an opponent's moves in chess? Would it even be possible to do this without building a sophisticated model of their move selection process - which might not be possible because our sample size of their games would be too small (mathematically: number of variables too large for the sample data size)?

When I wrote that, I was thinking of human players - but, of course, with computer opponents one can generate many millions of sample games.

This might turn out to be an interesting idea that doesn't work in practice - but just suppose one came up a classifier which was able to predict most of Stockfish's moves without generating a game tree beyond ply 1?

From the prediction algorithm, a new eval function could be created for Stockfish, and the process repeated until no further gains could be made.

If this is possible (and doable), then it would be a backdoor method of uncovering the deep secrets of chess: a path to a God algorithm.
Human chess is partly about tactics and strategy, but mostly about memory
shawn
Posts: 97
Joined: Fri Jun 28, 2024 9:24 am
Full name: Wallace Shawn

Re: Predicting An Opponent's Moves Would Enable Deeper Search

Post by shawn »

Sounds a lot like policy. MCTS engines such as lc0 uses policy to determine the best moves in a position, and uses that information to guide the search.