COMP1501A (Winter 2019) “Introduction to Computer Game Design” Specification for Assignment 3 of 4
Your submission for the first milestone of this assignment with be a Python 3 source code file that defines and implements a finite state machine-based, artificially intelligent agent for the glad_AI_tors program, with the filename ‘comp1501_w19_#########_a3_milestone1.py’ (where the number signs have been replaced by your nine-digit student number). This file must contain, as its first line, a comment of the form “# -> $$$$$$$$$$$$” (where the dollar signs have been replaced by the name for your agent, which must not exceed 12 characters in length).
The due date for Milestone #1 is Saturday, March 9, 2019, by 11:00pm.
On the weekend of the due date for Milestone #1, a roster of opponents will be released to cuLearn. Your final grade for this assignment will be largely determined by the performance of your artificial intelligence against the members of this roster of opponents, so the second milestone is your opportunity to refine your design and improve your agent’s performance. Your submission for the second milestone of this assignment must have the filename ‘comp1501_w19_#########_a3_milestone2.py’ (where the number signs have again been replaced by your nine-digit student number)
The due date for Milestone #2 is Saturday, March 16, 2019, by 11:00pm. Late assignments will not be accepted and will receive a mark of 0.
For this assignment, you will practice designing and implementing artificial intelligences by creating a module of functions that will govern the behaviour of a combatant in a simulated top-down shooter known as “glad_AI_tors”. To clarify, you have been provided with a program that will handle the updating and rendering of a small arena, designed such that separate source files provide the “inputs” that would control each player. This makes it possible for you to load two finite state machines (each represented as a Python module of functions) and observe the battle that ensues!
COMP1501A (Winter 2019) “Introduction to Computer Game Design” Specification for Assignment 3 of 4
The largest component of the grade you will receive for this submission will be determined by the performance of your artificial intelligence against each member of a set of artificial intelligences that will be provided for you after the first milestone. This entails that, if you allow yourself enough time to adequately test your submission, you will be able to estimate (with a high degree of accuracy) the grade you will receive for your final submission.
Please also note that this assignment will be followed by a tournament where the best artificial intelligences will compete against each another. As a further incentive, the students that submit the agents with the best performance in the tournament will be given the opportunity (and priority) to choose from the possible topics for the final assignment.
Remember that this program (along with any other program submitted in this class) must be a completely original work, designed and authored by you and you alone, prepared for this offering (i.e., Winter 2019) of COMP1501. Do not discuss this assignment with anyone except the instructor or the teaching assistants, and do not copy anything (source code, algorithm designs, rough work, etc.) from the internet or any other source.
You should approach the tasks required for this assignment in the following order:
1. Familiarize yourself with the program by downloading and extracting the contents of the archive on cuLearn. In order to run this program, the “glad_AI_tors_v1.0.py” program must occupy the same folder as the “Assets” and “Players” folders (which contain the sprites/fonts for the program and the player source files, respectively). This version of glad_AI_tors was designed for use with Windows, and it is within this environment that your programs will be evaluated. Start the program from the command line and provide the filenames of the two desired players as command line arguments to initiate a match, or simply run the program from the command line with no arguments to see more detailed usage information.
2. Observe some matches between the player files provided. Note specifically that the two players are placed at random locations (facing away from each other), and there are multiple game objects in play that obscure line-of-sight and have various effects. Above each player sprite are the player names (as read from the source file provided) and a horizontal bar for indicating the status (i.e., health) of that player.
3. After your have observed the behaviours of the source files provided, design a finite state machine for an artificial intelligence that you believe will fare well. Please note that this is not an optional design stage – you will be asked to present your finite state machine diagram before receiving any programming assistance from the teaching assistants or the instructor. See the following page for more details on the capabilities of your agent.
COMP1501A (Winter 2019) “Introduction to Computer Game Design” Specification for Assignment 3 of 4
Once you have created the initial (and high-level) design for a player, you will implement it as a collection of functions in Python 3. The functions you use to represent the different states of your finite state machine must always have no arguments and must always have two return values – a string, indicating the state to which you would like your finite state machine to transition on the next frame, and a dictionary telling your player what it should be “doing”. If, for example, you would like the finite state machine to enter the state labeled “wander_around”, while accelerating horizontally to the right as quickly as possible, then the return value should be:
return “wander_around”, {‘ACLT_X’: 1}
Your player can move in any direction, has no turning radius, and can adjust the angle at which it “throws” the weapons independently. If any “weapons” collides with either player then that player may receive damage proportional to the velocity of the weapon relative to the velocity of the player. Collisions with the stationary “columns” can also inflict damage upon a player, and a collision with one of the stationary “hazards” (which appear as “holes” in the arena grid) will result in an immediate loss for that player.
As previously discussed in class, finite state machines are, by nature, memoryless structure. Since you cannot pass any “arguments” while transitioning between states, your player has also been granted the use of eight “register” variables, each of which can be used to store exactly two characters of data.
To summarize the actions available to your tank during transitions, consult the table below.
If you would like your player to…
…then add this to the dictionary.
…accelerate horizontally… …accelerate vertically…
…rotate the weapon clockwise… …rotate the weapon counter-clockwise… …pick up a (slow-moving) weapon… …throw a held weapon…
…save a two-character string to register A… …draw a debug line from (10, 20) to (30, 40)… …draw a debug circle of radius 10 at (20, 30)…
‘ACLT_X’: float in (-1, +1)
‘ACLT_Y’: float in (-1, +1)
‘ROT_CW’: float in (+0, +1)
‘ROT_CC’: float in (+0, +1)
‘WEAPON’: True
‘WEAPON’: False
‘SAVE_A’: string of len 2
‘DEBUGS’: [(10, 20, 30, 40)]
‘DEBUGS’: [(20, 30, 10)]
1. Any number of debugging elements can be sent by including them all as the list placed in the ‘DEBUGS’ key.
2. The eight register variables available are ‘SAVE_A’, ‘SAVE_B’, ‘SAVE_C’, ‘SAVE_D’, ‘SAVE_E’, ‘SAVE_F’, ‘SAVE_X’, and ‘SAVE_Y’.
COMP1501A (Winter 2019) “Introduction to Computer Game Design” Specification for Assignment 3 of 4
The previous page described “what” your player can do, and since (by this stage) you should already have created a preliminary high-level design, it remains to decide “how” you will implement each behaviour, by providing a function for each state of your finite state machine. The return value for each of these functions (as previously noted) is a tuple of the next state and the current actions, but no arguments can be passed to these functions.
For your tank to “sense” the environment, in order to decide how to transition between states, you will need to call some of the following functions. An example of how these functions could be used is detailed on the next page.
get_position_tuple()
returns the current position (x, y) of this player
get_velocity_tuple()
returns the current velocity (x, y) of this player
get_current_status()
returns the current “health” of this player as a value between 0 and 100
get_if_have_weapon()
returns a Boolean value to indicate if this player is holding a weapon or not
get_my_stored_data()
returns the 16 characters stored in the register memory
get_throwing_angle()
returns the current angle (at which the player would throw a weapon, for instance) (n.b., collisions at 0 and 180 relative to this angle are on the longitudinal axis of the player and will be less damaging than collisions at 90 and 270 relative to this angle)
get_match_duration()
returns the number of frames that have elapsed since the match began
get_radar_data(radar_angle)
returns a 3-tuple of the type (i.e., one of “player”, “weapon”, “column”, or “hazard”), distance, and additional information (if any is available) about the first game object that would collide with a “ray” cast from the player’s current position in the direction of radar_angle. If the type of object that collides with the “line-of-sight” at this angle is a “player”, the additional information will include that player’s health, whether or not that player is currently holding a weapon, and the throwing angle at which that player is oriented. On the other hand, if the type of object is a “weapon”, the additional information is only whether or not that “weapon” is moving fast enough to inflict damage were it to collide with a player.
The preceding functions represent the only legitimate way for your agent to “access” information about the game environment. Any attempt to access any other protected data used by the glad_AI_tors program (e.g., by searching memory directly) will be considered academic misconduct and will result in an automatic zero for your assignment submission.