This document provides a basic overview of the starter agent code, along with suggestions for making improvements.
Message storage classes:
These classes store messages to or from the game server. You will probably not need to make any changes to these classes. There are methods for writing to and
reading from XML files that may be of interest, but these are no longer needed since the same information can now be read from the game logs using the log file
parser.
Bookkeeping classes:
These classes store information about the state of the agent, and are used for basic bookkeeping purposes.
You may want to make some modifications to allow additional information to be stored. The ComponentInfo
and ComputerInfo classes are the most important, as these store all information about components and computers.
The information in these classes will automatically be updated based on the incoming and outgoing messages each day,
so there is no need to directly modify the information stored during the course of the day.
Prediction classes:
There is currently only one prediction class. You may want to add more.
SupplierModel
This class is both a prediction class and a bookkeeping class. One instance is used for each supplier and product to store orders and offers. This class
also tracks reputation and makes predictions about future prices and deliveries, although these predictions are currently very simple.
Methods of interest:
calculatePrice
Predicts the price the supplier will offer for a given request, based on past offers from the supplier.
getExpectedDeliveries
Predicts the deliveries from this supplier on each future day.
getSpareOffers
Returns the maximum number of components that could be requested but not ordered before the agent's reputation drops below perfect.
Manager classes:
These are the classes that implement the agent strategy. Currently, all agent tasks are divided between a supply manager and a demand manager. If you want to change
this division of tasks, you will need to modify the manager interfaces. The manager classes are currently very simple and will need significant improvement to make
the agent effective.
SimpleSupplyManager
Interacts with the suppliers and is responsible for buying components.
SimpleDemandManager
Interacts with the customers and is responsible for producing, delivering, and selling computers. Makes use of a greedy algorithm for production and
delivery that looks ahead several days.
Methods of interest:
calculateCosts
Determines the cost of producing each type of computer, based on the costs of each component. Prediction of component costs could easily be improved, or
shifted to the supply manager.
produceExistingOrders
Greedily schedules the production of existing orders, as well as deliveries.
handleRFQs
Sets the offer price on each RFQ (currently a price low enough so that acceptance is always assumed), and also schedules the production that will be needed as
a result of expected orders.
tryToProduce
Determines whether it is possible to produce a given number of a certain computer by a given date. The computers will be scheduled for production
using cycles and components from the latest possible days. If not all computers can be produced, the remainder will be taken from the inventory of
already completed computers, if possible. This method will be called by the greedy production scheduler for each order that is considered.
sendProductionSchedule
Determines what production schedule should be sent to the factory for the next day based on the multi-day schedule generated by the greedy scheduler.
projectFutureComponentUse
Makes a projection of what components will be used in the future based on the scheduled production.
Agent classes:
These are the classes that run the agent. You will probably not need to modify these much, if at all.
TACAgent
The main agent class. This processes messages from the server, calls the managers to perform daily tasks, and sends messages to the server.
You may want to modify this class if you want to change the order in which the agent performs its tasks or how these tasks are divided between manager classes.
TACAgentParser
When reloading the agent state from a log file, this parses the file and then starts the agent. If you want to write your own log analysis tools, this class
can serve as a template.
TACAgentParserHandler, TACAgentParserMain
Needed to run the parser.
Notes:
In many places in the code, components or computers are referred to by index instead of product ID to allow the use of arrays. Indices begin at 0 and are in the same
order as the product IDs (for components, ID 100 has index 0, ID 101 has index 1, etc.). The index for a particular computer or component can be obtained with the
getIndex methods of the ComputerInfo and ComponentInfo objects.
When a delivery schedule is sent on day d, the deliveries take place on day d+1. If the due date is on or after day d+1, the delivery will
be
considered on-time.
When a production schedule is sent on day d, the actual production will take place on day d+1, and the computers produced will be shown in inventory
on day d+2. It is possible to send a delivery schedule on day d+1 that makes use of these computers, however. The computers used will not appear in
inventory on day d+2. The total number of computers currently available for delivery, including those in inventory and those currently being produced, can be
obtained using the getTomorrowsInventoryCopy method of the ComputerInfo object.
When a component delivery is received on day d, the components are not shown in inventory or available for use until day d+1. The component inventory
reported by the server does not include the components being used for the current day's production. The total number of components available for use on the following
day (the day for which a production schedule is sent) is the number in reported inventory plus any deliveries. This number can be obtained using the
getTomorrowsInventoryCopy method of the ComponentInfo object.