Advanced Topics in Artificial Intelligence - 2000

Project Definition

(* Design now FINAL *)


Description of the domain

This semester's project is a variant of the game of HUNT. The game consists of a maze (constructed from square blocks), with a number of players, each trying to shoot down the other players. Motion is in either the vertical or horizontal directions. We will add a few enhancements to make intelligent planning in the game a bit more challenging, adding features from the DOOM family of games.

The game is a discrete-time game, each move is by exactly one unit, and the action of shooting is instantaneous. In addition, a player has an INVENTORY and may select and use an item from the inventory (items are automatically picked up when a player moves into a square where they are located).

Each player has a HEALTH attribute and an ARMOR attribute, both initially 100. A player hit by a shot is injured by deducting some HEALTH points, depending on ARMOR and on attributes of the weapon used. Probability of a shot hitting depends inversely on distance, and on possible player enhancements. Players operate in an initially unknown environment, and start at a random location in the maze.

A list of items found at some locations in the maze are:

  • First aid
  • Armor repair
  • Ammunition
  • (Temporary) acuity-improvement pill (improves aim)
  • Map
  • Enemy detector "radar"
  • Teleportation traps (cause teleportation to random location)
  • Confusion traps (cause a player to be confused - i.e. action taken sometimes results in another action).

    Game rules - designed in class

    (* Design now final - no changes permitted (modulo serious bugs) *)

    Agent state (maintained by server)

  • Agent health (integer, initially 100) (optionally, read from file))
  • Agent armor (integer, initially 100) (optionally, read from file))
  • Agent location (integer x, y, initially random (optionally, read from file))
  • Agent heading, initially random
  • Agent inventory

    Note that these state elements can also be maintained by the agent, but some are initially UNKNOWN to the agent. Health and armor state are sent from server to agent every turn.

    State of the environment (maintained by simulator)

    Map is a 2-D maze maintained by server, initially unknown to agents. The global state consists of the contents of the (including items and activated traps), and all agent states.

    Before each move, the server notifies all agents of part of the agent state, as well as part of the state of the environment, as follows:

  • Agent health and armor values
  • Results of previous action (move or shoot faliure, success of failure of activating an inventory item).
  • Killing another agent or getting killed.
  • An item added to the inventory (picked up).
  • What the agent perceives in the environment, as follows:

    A note on designing your agent: although state information is maintained by the simulator, much of that is NOT transmitted to the agent, which should attempt to keep track of them by counting, learning, etc.

    Permissible player moves

    By committee decision, ANY of these actions make up a move (e.g. cannot turn and shoot at same time).
  • Turn left 90 degrees
  • Turn right 90 degrees
  • Move forward 1 position
  • Move left 1 position while facing forward
  • Move right 1 position while facing forward
  • Shoot (forward)
  • Use an inventory item
  • Do nothing

    Simulator resolution of multiple agent moves

    The server waits until the current turn message is received from all agents. The actions are then performed "in parallel". All shoot actions occur before all object activation actions, which occur before all move actions. Trap activation actions occur last (when an agent steps onto a trap).

    Conflicting actions are still possible - two agents attempt to move into the same locations. In this case BOTH motions fail, and the agents are notified. Other items agreed by committee:

  • A trap laid by an agent is visible to that agent.
  • Only one item or trap in each location.
  • Simulator notifies agents at start of game how many points for a kill, and how many (negative) points for getting killed.

    Various simulation parameters

    The simulation functions and parameters have been finalized as:

  • Probaility of hit (as a function of distance) is min(1, k/(d^2)) where d is the distance in unit squares. For all agents, k=20, except for agents under the influence of vision improvement, where k = 60.
  • Injury caused by a shot is (100-a)/b where a is the value of the target's armor, and b is a parameter that defaults to b=2.5.
  • Damage to armor caused by hit is 20.
  • Durations of activation of items maps, confusion traps, acuity, and radar are parameters, with a default value of 50 simulation time units.
  • All agent start with s units of ammunition. By default, s=10.
  • A confused agent performing a motion action will successfully exexute the action with probability p, and some other motion action with probability (1-p) uniformly distributed over all other motion actions. The simulator decides which action is actually performed, according to the above rule. The parameter p is a configuration parameter, defaulting to p=0.8.

    Project tasks

    The project is partitioned into two parts, each to be implemented by a team of programmers, as follows:
  • Environment simulator and server
  • Player agent

    Each part will be a complete program that communicates with the others via an agreed-upon interface, in order to create a complete running system. Tasks to be implemented by each part are as follows.

    Environment simulator and server

    Responsible for coordinating all game actions, simulating the game environment, keeping score, and graphical display of the environment. The server, after reading a configuration file, loads a maze file (specified by the configuration), and waits for contact by all agent programs. The server sends all clients an initialization message, including an agent ID (see below), and then repeatedly waits for actions from all agents, updates the environment and scores, displays changes, and sends updates to all agents. A dead agent is revived at a random location in the map.

    Client and player agent

    Generates a player agent behaviour. Begins by connecting to the server (port number listed in the configuration file). It the repeatedly receives a game state from the server, and then computes a player action and sends it to the server/simulator. A dead player does not mean that the client program is dead. The agent gets reincarnated by the server, and the new incarnation keeps running under the same client. Computation of an action is the main issue here. It tries to achieve player agent goals, such as survival, collecting enhancements gaining bonus points, etc. using AI techniques. One or more of the following should be employed:
  • Planning/search
  • Learning
  • Decision making under uncertainty
  • Flexible computation (anytime algorithms)

    Interface details

    In order to achieve a clean interface, communication protocols and data formats appear below.

    Client-Server Communications

    We will be using reliable socket-streams. Server will wait for a number of clients specified by a command-line parameter. Once the requisite number of clients have connected, the simulator in the server is started and the game begins. A game turn consists of (sepatrate) messages originated by the simulator and sent by the server to all clients. The agent in each client recieves these messages, processes the information and sends back a turn command. After the server collects a message from each client, the simulator processes the messages and a new turn begins. For example code containing basic ASCII client-server communication, see ~shimony/public/client_server_example.

    Connection protocol - client-server level

    The server is started up first, and creates a PF_INET, SOCK_STREAM type socket. After binding the socket name, it "listen"s for client connects, and accepts as many clients as specified in a command-line parameter. Note that a DUPLICATE socket is created on accept, and the duplicate is used henceforth to communicate with the client (one duplicate created for each client).

    Client creats a socket and connects to server socket, and henceforth uses the socket for bidirectional communication.

    Agent-simulator communications

    All communications are in printable ASCII messages. Every information item is on a null-terminated string, with the last line (string) of the message consisting of the 2-character string "#E" (also terminated by null). Internal fields in messages terminated by space, where necessary, or non-terminated if length of field is pre-determined. To be on the safe side, we adopt the following two conventions:

  • Extra spaces and tabs are ignored by the recepient of the message
  • Extra fields, if any, that the recepient does not expect are ignored, up to the null. (This allows for later expansions, preserving backward compatibility.)

    Initialization

    Simulator sends an initial message, including the agent ID in addition to the usual message item. This ID is an integer, sent as an extra line in the standard message (see below), with the format:
    #I agent-id
    

    Subsequent communication - agent to simulator

    Agent sends a single item of information - its turn, in the format:

    #T turn-specifier optional-item-specifier
    

    The turn specifier is a single character, one of the following:

  • l - turn left
  • r - turn right
  • L - move left
  • R - move right
  • S - shoot
  • F - move forward
  • N - do nothing
  • U - use item

    The optional-item-specifier is a specifier used for the U action, a single character denoting the item to be used.

    Subsequent communication - simulator to agent

    The simulator must provide an agent with results of actions, what the agent senses, information on its state, and state of the game. The following sequence of message lines will be used. Semicolon always starts a COMMENT field to be ignored by the recepient.

    ; Start with a line signifying perception - starting with forward direction
    #F     1   x      ; Enemy number 1 in front, then space, then wall (x)
    #L                ; Single character specifying environment one space to left
    #Rx               ; What's on the agent's right (a wall - x)
    #l                ; What's on the agent forward left (dx = 1, dy =  1)
    #r                ; What's on the agent forward right (dx = 1, dy = -1)
    #H integer        ; Health of agent (an actual number instead of "integer"
    #A integer        ; Armor of agent
    #f x              ; Action x failed 
    #T x              ; Agent just stepped on trap of type x (one of C T)
    #C                ; Agent is confused
    #K x y            ; Agent x killed agent y
    #P x              ; Picked up item x
    #U x              ; Just used item x
    #e n h a dir      ; Status of enemy in front, if any. n is enemy id, h=health,
                      ; a=armor, dir=which way the enemy faces: T=towards agent
                      ; L=facing left (from agent's perspective), R=right, A=away.
    #o dx dy n        ; Radar on - list element - enemy n at rel. location dx dy
    #o dx dy n        ; Additional enemies, if any 
    #M x y            ; Optional - when map on, x y are dimensions of map
    #a x y            ; In map - location of agent
    #m     xxx   xxx  ; actual lines of map, as many as necessary
    #m     x x a   x  ; actual lines of map, as many as necessary
    #E                ; Last line of message
    

    Note change: radar info now begins with o instead of r due to conflict wirh r used as forward-right information about environment.

    In the message, visible, gathered, or used items are reported according to the following format:

  • First aid - H
  • Armor repair - A
  • Ammunition - a
  • (Temporary) acuity-improvement pill (improves aim) - V
  • Map - M
  • Enemy detector "radar" - R
  • Teleportation traps - T
  • Confusion traps - C
  • Acive teleportation traps (visible only to activating agent) - t
  • Active confusion traps (visible only to activating agent) - c
  • Wall - x
  • No object - space
  • Enemy - integer-agent-ID
    Back to BGU CS HomePage