You are not logged on | Login | Register  
TCL procedures for robots

This section has been divided into two sections: a section with the special Dominate that are available to robot developers, and a section with the procedures that robot developers should develop.

Section one: available Tcl procedures
On top of the normal Tcl procedures, a number of special procedures are available for robot developers. With the following procedures, you have access to all necessary information. More additional procedures will become available upon request.

cards contain ?card? ...
This procedure accepts any number of arguments. The possible values for the supplied arguments are "cavalry", "infantry", "artillery" and "wildcard". This procedure returns 1 when the robot owns the supplied card-combination, and 0 when it does not.

cards list
This procedure returns the list of cards that the robot has in hands. Possible values for cards are: "cavalry", "infantry", "artillery" and "wildcard".

cards size ?card?
This procedure returns the total number of cards that the robot owns. If the parameter ?card? is specified, only the number of cards of the specified type are returned. Possible values for card are "cavalry", "infantry", "artillery" and "wildcard".

continent bonus [continent-handle]
This procedure returns the bonus value of a continent. When a player owns all countries in a continent, he receives this bonus as number of armies at the start of his turn.

continent countries [continent-handle]
This procedure returns a list of all the country-handles inside this continent. A country-handle is a numeric identifier that represents a country.

continent name [continent-handle]
This procedure returns the name of a continent. The supplied continent-handle is a numeric identifier for a continent.

country armies [country-handle]
This procedure returns the number of armies that can be found on a country. When the number of armies is smaller than 0, the robot is in a blind map game, and does not know the number of armies on this country.

country continent [country-handle]
This procedure returns the continent-handle of the continent that the supplied country belongs to. Every country belongs to one continent.

country name [country-handle]
This procedure returns the name of the country that is represented by the numeric identifier stored in the country-handle.

country neighbours [country-handle]
This procedure returns a list of country-handles that are adjacent to the supplied country. A country-handle is a numeric identifier for a country.

country owner [country-handle]
This procedure returns the player-handle of the player who owns the supplied country. If the returned player-handle is smaller than 0, the robot is in a blind-map game and does not know who owns the country.

map continents
This procedure returns a list of all the continent-handles that can be found on the map. A continent-handle is a numeric identifier for a continent.

map countries
This procedure returns a list of all the country-handles that can be found on the map. A country-handle is a numeric identifier for a country.

map name
This procedure returns the name of the map on which the game is being played.

map user
This procedure returns the name of the user who created the map on which the game is being played.

option list
This procedure lists all options that are recognized by the server. When an option is in the list, it does not mean that the option is set for the game. This option only lists which options are recognized.

option ?option?
This procedure returns the value of an option. When an option is set, it returns "1" and when an option is not set it returns "0". When the parameter is "seconds", it returns the timeout period in seconds.

player cards [player-handle]
This procedure returns the number of cards that are owned by the supplied player. When the game has the hidecards option, the value 0 is always returned.

player list
This procedure returns a list of the player-handles that are inside the current game. A player-handle is a numeric identifier for a player.

player me
This procedure returns the player-handle of the robot. The robot itself is also one of the players with a unique player-handle. This procedure returns that handle.

player name [player-handle]
This procedure returns the name of a player. The supplied parameter is a numeric identifier for the player.

player robot [player-handle]
This procedure returns 1 when the supplied player-handle is a handle of a robot player, and 0 when it is a human player. Do not use this procedure to find out the handle of the current robot, as there can be more robots inside a game.

Section two: Tcl procedures you need to write
When a robot should take some action, the server calls one of the procedures inside your script. You need to implement those procedures. This section describes the procedures you should write.

robot_start_turn
This procedure is called before the turn of the robot starts. Use this procedure for initializationcode. No return value is required. This procedure is optional, you do not have to implement it.

robot_attack
This procedure is called by the server when the robot has to perform an attack. The procedure should return a list with three elements: the handle of the source-country, the handle of the destination-country and the number of dice to use.

robot_attack_or_end
This procedure is called by the server when the robot has performed one or more attacks. When the robot wants to continue it's attack, it should return the string "attack". When the robots wants to end it's turn, it should return the string "end".

robot_place_or_attack
This procedure is called by the server when the robot needs to choose between placing or attacking. When the robot wants to skip its turn and place additional armies instead, it should return the string "place". Otherwise it should return the string "attack".

robot_exchange_cards
This procedure is called when the robot could exchange cards. When the robot does not want to exchange cards, nothing should be returned, otherwise a list with the three cards to exchange should be returned. When the robot has 5 or more cards, he MUST exchange cards.

robot_initial_placement armies
This procedure is called by the server when the robot should place it's initial armies. After the game starts, each player should place the initial armies. You can place at most four armies on a country. This procedure returns one country-handle. This procedure is called repeatedly until all initial armies have been placed. The parameter specifies the total number of armies the robot should have on the map.

robot_movement
This procedure is called by the server at the end of a turn. This procedure should return nothing (an emty string or list) when no movement is required, or a list with three elements when the robots wants to move armies. The list should contain three elements: the handle of the source-country, the handle of the destination-country and the number of armies to move. At most seven armies can be moved.

robot_pick_capital
This procedure is called by the server when the robots has to pick it's capital. This procedure should return a country-handle.

robot_placement armies
This procedure is called by the server when the robot has to place armies. The procedure should return one country-handle on which the next army should be placed. This procedure is called repeatedly until all armies have been placed. The parameter specifies the total number of armies the robot should have on the map.

robot_take_country source-handle destination-handle minimal
This procedure is called when the robot has captured a country. Now the robot should decide the number of armies to place on the new country. Three parameters are supplied to this procedure: a country-handle of the country where the attack came from, the country-handle of the captured country and the minimal number of armies to place on the new country. This procedure should return the number of armies on place.

robot_end_turn
This procedure is called at the end of the turn of the robot. Use this procedure for clean up. No return value is required. This procedure is optional, you do not have to implement it.




Copernica is a software for e-mail marketing, profile enrichment, websites and short text messages campaigns.