Mini Social

Project Description

In this project we implement an agent based simulation to a variation of the deduction board-game Code-777. The aim of the project is to apply epistemic logic to model the knowledge of the agents involved in game playing and experiment different agent behaviors (strategies) as employed throughout the game.



Code 777

Code 777 is a deduction board game by Robert Abbott. There are 28 cards each of which is attributed by a single colored digit. There are four players: North, South, East and West. In front of each player is a rack containing three cards. The remaining 16 cards are not used and kept invisible. Each player could see the cards on the other racks, but not the cards on his own rack. To win, a player must determine the cards on his own rack.

Knowing the cards on his opponents’ racks, a player starts with 19 C 3 = 969 possibilities for his own cards. Throughout the game, each player - in his turn - randomly pick up a question card, from a set of question cards, and asks the question written on it to an opponent of his choice. The selected opponent has to answer truthfully and from his answer, all other players could benefit and reduce their possibilities.

The game proceeds by players picking up question cards in turn until a player identifies his own cards (reduces all his possible card combinations to 1). The player announces his cards and the game finishes.

Reduced Code 777

For the purpose of the project, we considered a reduced version of the game. We reduced the number of cards from 28 to 12 and the number of players from 4 to 3 and accordingly considered a subset of the question base. The game workflow and rules are kept as they are, however, we considered the following modifications to compensate the mentioned reduction. (1) The rack in front of each player contains 2 cards instead of 3. This leaves the deck with 6 unrevealed cards. Since each player could see cards on other players’ racks but not his own rack, this leaves each player with (8c2=28) different cards possibility at the beginning of the game.

Considered Questions & Cards
• On how many racks is the sum of 6 or more
• On how many racks it the sum of 7 or less
• On how many racks there are 2 different colors
• On how many racks are all the cards even
• On how many racks are all the cards odd
• On how many racks exists identical cards
• Is there a rack with 2 consecutive numbers
• On how many racks can you see this number?
• On how many racks can you see this color?

Common Knowledge

Common knowledge increases every turn throughout the game. Starting with NO “relevant” common knowledge between all participating agents, each turn a question is asked, answered and accordingly the answer becomes a common knowledge to all participating agents.

Agents Behaviour

In our implementation, we programed different types of agents – Random, Annoying, Smart1 and Smart2 – With the first 2 considering the current situation, and the last 2 looking ahead one step forward. Given the only agent choice is the opponent they should ask a selected question, these agents’ acts as following.

Random: Follows a random selection process
Annoying: Considers opponents and their possibilities. Asks the opponent that he thinks has the least number of possibilities remaining, since by asking him it is guaranteed that this opponent will not have any of his remaining possibilities reduced.
Smart1: Given that an agent knows the question he should in advance, the agent first checks who is the most opponent that will benefit from that question and ask him, so that he does not benefit at all.
Smart2: Similar to the annoying agent, but checks the opponents remaining possibilities after asking the question i.e. Given the current agent a1, and his opponents op1 and op2. a1 assumes he asked op2 the question and calculates the remaining possibilities of op1 (since op2 remaining possibilities will not change), then he assumes he asked op1 the question and calculates the remaining possibilities of op2. Knowing the remaining possibilities of op1 and op2, the agent asks the opponent with the lowest remaining possibilities.

Application Description

Reduced Code-777 is implemented in Java and simulates the game playing. As mentioned 4 different types of agents are programmed, each has different behavior that affects his choices. From the settings tab, the user selects the types of agents, the application delay in milliseconds (the simulation speed, in case he wants to take his time thinking and reasoning about the agents choices) and the number of simulations he would like to run (for a normal game simulation or a test he could choose just 1 simulation, however, running the game multiple times (500 for example) would give an intuition about different strategies, in terms of wins). The user could then start the game. During the game play / simulation the user could pause the game or reset his simulations.

Interface

Through the user interface, the user is presented by the actual game play (1), the possibilities each player thinks for himself (2), and possibilities each player considers for his opponents (3). Throughout the game, questions being asked and their responses (which also correspond to the common knowledge) are also presented (4). Through this information a user could reason the agent’s behaviors while the game is being played.

Source Code

Application source code can be downloaded from here