Final Year Project Interim Project Report Multi-Agents Chess By Madhuri Kottamraju 200001049, B.Tech IV Year International Institute of Information Technology Gachibowli, Hyderabad – 500019, Andhra Pradesh, India Project Advisor Dr. Kamal Karlapalem Centre for Data Engineering IIIT Hyderabad September 2003 Organization of the report 1 Introduction 1.1 Agents 1.1.1 What is an Agent? 1.1.2 What is an Intelligent agent? 1.1.3 Characteristics of an Agent 1.1.4 Desired Characteristics of an Agent 1.1.5 What is a Multi Agent System? 1.2 Chess and AI 1.3 Chess and Multi Agents 2 Description of the system 2.1 Aim 2.2 Related Work 3 Description of the Database 3.1 Notation 3.2 Relations 4 Evaluating a move 5 Communication 6 Analysis of a Game 7 Implementation Details 8 Challenges and Future Research 9 References 2 1. Introduction 1.1 Agents 1.1.1 What is an agent? An agent is a computer system capable of autonomous action in some environment. 1.1.2 What is an Intelligent agent? An intelligent agent is a computer system capable of flexible autonomous action in some environment. 1.1.3 Characteristics of an Agent 1. 2. 3. 4. 5. Autonomous - capable of acting independently and exhibiting control over their internal state. Reactive - A reactive system is one that maintains an ongoing interaction with its environment, and responds to changes that occur in it (in time for the response to be useful). Pro-active - implies displaying goal directed behavior. Recognizing opportunities, generating and attempting to achieve goals; not driven solely by events but also taking the initiative. Social Ability - Social ability in agents is the ability to interact with other agents (and possibly humans) via some kind of agent communication language, and perhaps cooperate with others. Learning/Adaptation agents improve performance over time. 1.1.4 Desired Characteristics of an Agent 1. 2. 3. Intelligence - the third trend is more intelligent systems. Complexity of tasks that we are able to automate and delegate to computers has increased and will continue to increase. Delegation - means giving control to computer systems. Communication - While the earliest computer systems were isolated entities, communicating only with their human operators, computer systems today are usually interconnected. They are networked into large distributed systems. Thus, the need for communication among agents. 1.1.5 What is a Multi Agent System? A multi-agent system is a loosely coupled network of problem-solver entities that work together to find answers to problems that are beyond the individual capabilities or knowledge of each entity. More recently, the term multi-agent system has been given a more general meaning, and it is now used for all types of systems composed of multiple autonomous components showing the following characteristics • each agent has incomplete capabilities to solve a problem • there is no global system control • data is decentralized • computation is asynchronous 1.2 Chess and AI The game of chess has sometimes been referred to as the Drosophila of artificial intelligence and cognitive science research -- a standard task that serves as a test bed for ideas about the nature of intelligence and computational schemes for intelligent systems. Both machine intelligence -how to program a computer to play good chess (artificial intelligence) -- and human intelligence -how to understand the processes that human masters use to play good chess (cognitive science) -- are important to be understood properly. The idea of programming computers to play chess appeared almost simultaneously with the birth of the modern computer. There was a close family resemblance among most of the early programs. The task was viewed in a game-theoretic frame work. Chess has usually been implemented using search trees like MinMax tree, Alpha-Beta trees, etc. Some of the popular Chess games like DEEP BLUE and GNU CHESS also use search trees. But this does not involve any kind of learning. 1.3 Chess and Multi Agents Chess is a game of strategies. Building a strategy usually means making a plan of coordinated actions for reaching a particular goal. There are two ways to implement Chess using Multi agents. One is with a master agent and the other is without a master agent. For the first case, usually when we have a goal to achieve with multiple agents, there is a global agent or system i.e. “Master Agent” which takes the final decision of what step to take. All the individual agents inform their current position and the best step they can take to the master agent, who then decides what would be best by analyzing all the agents scenario. In the 3 second case, i.e. when there is no master agent, after each piece agent has evaluated its current situation and determined the best move to make on an individual basis by interacting with other agents of the same type and with the opponent type, it broadcasts the same to all other agents. Now these agents, by negotiating with each other, should come to an agreement as to which piece agent should make a move. This decision could be based on some priority or point system. 2 Description of the system Chess is a board game played on a 8x8 board of 64 squares. It is a two-player, zero sum game ( i.e. 3 outcomes are possible – win, loss, draw). It is a complete information game that is all the agents know the state of the board at any given time. It is an accessible environment as the agent can obtain complete, accurate, up-to-date information about the environment’s state. It is a non-deterministic environment as any action does not have a single guaranteed effect — there is uncertainty about the state that will result from performing an action. It is a static environment as it remains unchanged except by the performance of actions by the agent. It is a discrete environment as there are a fixed, finite number of actions and percepts in it. Our system plays as one of the players either as white or black. Each side begins with 16 pieces for each side – 8 pawns, a king, a queen, 2 rooks, 2 knights and 2 bishops, i.e. 32 agents in total. We will model our system to consist of 6 kinds of agents i.e. pawn, king, queen, rook, knight and bishop. Each agent will be an autonomous entity capable of evaluating its position in the board and be able to decide the best move that it can make. It makes this move based on several parameters including a database of previous games. Based on the moves it made in the previous games it learns as it progresses. After every agent evaluates its position, the decision of the final move is made by the agents communicating with one another and negotiating as to which move is the best. 2. 1 Aim The aim of our project is to show that in a multi agent scenario, the agents can learn from each other. In the game of chess we can also explore how one agent can learn from the strategies of the other agent. For this purpose we use the second scenario where there is no master agent. For example if each piece is considered as an agent, then these pieces communicate before making each move and learn from the moves that the other agents make in a situation. Playing more and more games will increase their experience and hence they can make more intelligent decision next time, showing that they have the ability to learn. 2.2 Related Work Until now Chess had been implemented using AI i.e. using search trees. Little work has been done in Chess using agents. One of the systems developed is MARCH (Multi Agent Reactive Chess). It uses a distributed approach to implement a chess program. They have modeled the system as being purely reactive i.e. the agents base their moves entirely upon the current action. To tap the true potential of multi agents we should not only explore the reactive aspect but also exploit the learning aspect. This is what we are striving to do. 3 Description of the Database 3.1 Notation The board is marked as follows: Each square on the chess board can be uniquely identified. The notation is as shown in the figure above. The columns are numbered ‘a’ to ‘h’ while the rows are numbered from ‘1’ to ‘8’. The numbering always starts from the left, bottom of the board on the white side which could be seen as a kind of an origin for the board with reference to which all the numbering is done. Thus, the pawns of the white side are placed in the row marked 2 while those of the black are placed in the row marked 7. The rest of the white pieces stand in the row marked 1 and those of black on the row marked 8. Each square is identified by mentioning both the row and column number in which it falls. First, the alphabet denoting the column and then the number denoting the row is written. For example, at 4 the beginning of the game the square on which the King stands is ‘e1’ as it stands on the square which lies in the 5th column, i.e. ‘e’, and the 1st row, i.e. ‘1’. A notation also exists to identify the pieces on the board though it does not uniquely identify each piece. This is because a letter is assigned to each kind of a piece i.e. P for Pawn, K for King, Q for Queen, R for Rook, N for Knight and B for Bishop. To identify whether the piece belongs to white or black we add ‘w’ or ‘b’, respectively. So, the black King would be identified as Kb. The symbol ‘x’ denotes a capture taken place in that move while ‘+’ denotes a check. 3.2 Relations All the information about the previous games has to be stored in a way that it can be easily retrieved. So we store the games in the database in such a way that we can mine the information easily. There are three relations in the database. The first relation is as follows: Game Number Colour Move Number Board Status This relation contains the full board position of every move in all the games. ‘Game Number’ stores the number of the game played. ‘Colour’ mentions whether the agents represented the white side or the black side. White is denoted by ‘w’ and black by ‘b’. ‘Move Number’ stores no. of the move which leads the board to be in the present state. One Move is considered to have been played when either white or black have finished playing. ‘Board Status’ stores the status of the board at that moment i.e. the location of each piece on the board. We store the status as a continuous string of ordered pairs or triplets consisting of the piece and the square it is on. So, if only a white Pawn, the white King, a black Pawn and the black King were still standing in the squares e4, d5, f1 and f5 respectively, then the board status would look like this – “(Pw, e4), (Kw, d5), (Pb, f1), (Kb, f5)”. If in moving to e4 the Pawn captures a piece then we put ‘x’ in another field and the board status now becomes - – “(Pw, e4, x), (Kw, d5), (Pb, f1), (Kb, f5)”. If it also causes a check then we append a ‘+’ to the 3rd field and the board status looks like this - “(Pw, e4, x+), (Kw, d5), (Pb, f1), (Kb, f5)”. The second relation is Game Number Result The second relation has the information whether this game was won or lost. The third relation is Piece Game Move Type Number Number This relation stores what all moves were made by a particular piece in various games. Every time a new game is played the database is updated. All the moves are stored and are used for further games. 4 Evaluating a Move While deciding on what move to play next, we have to look for the advantages and disadvantages of all the moves possible at that time. To account for these we have come up with an evaluation scheme. A part of this scheme involves calculating the benefit of the squares an agent can move to, along with king’s safety and sacrifice criteria. Apart from this we also use the information previously stored games from the database as a part of the evaluation. For example, after mining the database we might find out that one particular move has been advantageous in most of the games played, so this can also be used for evaluating a particular move. After all these factors are considered, this agent informs the other agents that it wants to make this move. Then the other agents analyze their situation if this move is made and report it back to the first agent. For example if the queen sees that it is being threatened by the opponent’s rook if this move is made, it informs the same to the piece which wants to make this move, otherwise it informs that it is “OK” with the move. An appropriate weight will be associated with the information provided by the other agents and added to the final value. This is done for each move that the active agents (i.e. a piece that can make a move) can make, and then the one with the highest evaluated value is selected. The benefit for each square it can move to is calculated by adding the values of all the pieces it protects, minus the values of all the pieces that are now threatened by the opponent, plus the value of the pieces of the opponent that it threatens. Also, if at that square there is an opponent piece multiply its value by an appropriate factor, depending on which piece it is killing, and add it to the benefit. The second thing is the King’s Safety. For any move we make we have to take care about the safety of the king. If making a move by a certain piece, directly endangers the king then we should immediately reject that move. If a move made by a piece keeps itself in direct threatening position, then we should evaluate whether sacrificing that piece is an advantage or not. For this we can get information from the previous games that whether sacrificing this piece in a similar scenario was beneficial or not. The agents should communicate if they are endangered by the sacrifice 5 of that piece and hence conflict resolution should be figured out amongst the pieces. Moreover when a piece has to move, knowledge about its previous moves is mined from the database and based on that information, some weight is given to the particular move. For example if we are considering the Knight’s move, then similar board status is first mined from the Knight’s Moves Database and the moves that the Knight made in that situation are analyzed and if its advantageous then a positive weight is allotted, otherwise a negative weight is allotted. After analyzing all these points a particular move can be rejected or stored as a possible move. Once this is done for all the moves of all the active pieces, the move with the highest value is made. If there is more than one move with the same maximum value, one of them is randomly picked and the corresponding piece is asked to move on the related place. 5 Communication The decision as to which piece should make a move after each agent has evaluated its position and the possible moves it can make is not possible unless each one knows what are the possible moves that others can make and whether its own move is better than those of others. This can be achieved by facilitating communication between the pieces. There are 3 kinds of information that an agent might want to communicate to the other agents, namely – 1. Benefit – which conveys to the other agent the absolute value of the move it is about to make. 2. Sacrifice – if it will be taken if it makes the move 3. Danger – whether it places the other piece in danger or faces danger due to the move suggested by the other piece. We plan to use a form of communication in which the agents have a predefined code of communication. They communicate through an interface. To inform the other agent an agent would use TELL(Agent, Infotype, Info) and to ask for information it would use ASK(Agent, Infotype) where – • Agent is the identification id of the other agent • Infotype could constitute one of the 3 types stated above, namely Benefit, Sacrifice, Danger, etc. • Info is the actual message about the Infotype that the agent wants to convey. After an agent receives information regarding the other agent, which piece makes the move is determined by a comparison of both the values. 7 Implementation Details We have made the basic classes for the various agents. The classes made are King, Queen, Rook, Bishop, Knight and Pawn. Each class has a class variable called color, which will tell whether these agents are black or white. This is necessary because based on this we will have to mine the database. The second class variable is the structure Position. This structure stores the column and the row that the particular agent is in. The next class variable is a structure PossibleMove which stores the moves returned by the function getNextPosition. The various functions in the class are : • • getNextPosition(char *move): This function gets all the possible legal positions that the agent can move to at that time. removeNotPossible(): This function removes all the moves stored which are not possible. Like for example a Knight can make a move to a particular square , but it actually cant move right now as a piece of its own color is already in that square. This function is called in getNextPosition function. Apart from this, for opening moves, we select a random move from a set of good opening moves separately for white and black. Also we have populated the database with some games. 8 Challenges and Future Research To develop better algorithms for negotiation between agents has been a research interest in the past and will continue to do so for some time to come. For an agent to complete the desired task the foremost necessity is to state our preferences to it correctly. This a not a very easy task and research work is going on for the same. Continuing research in multi-agent systems will govern how effectively deployed agents can work together. However, integrating humans into such systems poses additional challenges evidenced by research in areas such as human-agent teamwork, human supervision of agent tasking and coordination, adjustable autonomy, interface or proxy agents, human-agent interaction, personalized agents, and human-robot interaction. In the future, humans should be able to interact effectively and simultaneously with diverse software and robotic agents having various goals, 6 interfaces, and degrees of initiative and autonomy. In addition, future organizations will need to manage the coordination of multiple humans and multiple agents for job-related tasks. 9 References 1. Alexis Drogoul, When Ants Play Chess (Or Can Strategies Emerge From Tactical Behaviors?) 2. Herbert A Simon CMU, Jonathan Schaffer, The Game of Chess , University of Alberta 3. An Introduction to Multi Agent Systems, By Micheal Wooldridge 4. http://www.mines.edu/~rtankele/cs404/ Chapter%202.htm 5. http://kuba.korea.ac.kr/~ixix/Article/ag ent/00Articlelist.htm 6. http://ai-depot.com/Logic/109.html 7. http://www.research.ibm.com/deepblue /home/html/b.html 8. http://www.rci.rutgers.edu/~cfs/472_ht ml/Intro/ChessContents.html 9. http://www.sciencenews.org/sn_arc97/ 8_2_97/bob1.htm 10. http://www.aihorizon.com/essays/chess ai/ 11. http://www.ri.cmu.edu/people/sycara_k atia.html 12. http://www.media.mit.edu/research/ind ex.html 13. http://www.aaai.org/AITopics/html/che ss.html#pages 14. http://www.cs.nott.ac.uk/~gxw/chesshi s.html 15. http://www.isi.edu/teamcore/tambe/age nt.html 16. http://www-2.cs.cmu.edu/~softagents/ 17. http://www2.cs.cmu.edu/~softagents/afc.html 18. www.multiagents.com 19. http://www.research.ibm.com/deepblue /meet/html/d.3.html 7
© Copyright 2026 Paperzz