Distributed
Simulation Game: Annihilation
Due Date: Midnight, Tuesday October 22, 2002
Game Description:
You are to implement a distributed
simulation game using the FDK (Federated Simulations Development Kit) software
package.
There are two players in the game, the red team and the blue team that
share a playing area that is organized as a grid, as illustrated in Figure 1.
Each team consists of 16 mobile units (MUs).
At each time step of the game, each MU randomly moves in one direction (N/NE/E/SE/S/SW/W/NW) to an adjacent grid cell, or remains in the same cell. An MU cannot move beyond the edge of the playing area. For example, a MU in the northernmost row cannot move north. Each MU is equally likely to choose among its options for moving or remaining in the same cell. FDK includes a random number generator that you can use to implement this function. Multiple MUs can reside in the same grid cell at the same time.
The red team¡¯s base
is at the grid cell with coordinates (0,0), and blue team¡¯s base is located at (7,7). At the start of the game, all
MUs should start from their team¡¯s home
base.
When red and blue MUs meet in the same grid
cell, each red MU annihilates exactly one blue MU. For example, if three Red MUs and one Blue MU meet in the
same cell, one Red and one Blue MU are destroyed and removed from the game,
leaving two Red MUs in the cell.
The remaining MUs then advance to the next time step, and resume their
movement operations. The game ends
when the simulation executes 40 time steps.
|
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
||
|
0 |
Red base |
|
|
|
|
|
|
|
||
|
1 |
|
|
RR |
|
|
B |
|
|
||
|
|
|
R |
|
B |
|
|
B |
|
||
|
|
|
|
RB |
B |
|
B |
|
|
||
|
|
RB |
|
|
|
|
|
|
|
||
|
|
|
|
|
|
B |
|
|
|
||
|
|
|
R |
|
|
|
|
|
|
||
|
|
|
|
|
B |
|
|
|
Blue base |
||
|
Figure 1: 8X8 play area. |
|
|
||||||||
You should implement a distributed simulation containing two federates, one to simulate the red team, and one to simulate the blue team. Each time step the red (blue) federate should (1) compute the new position of each red (blue) MU, (2) send messages indicating the new position of the red (blue) MUs, (3) receive messages indicating the position of the blue (red) MUs, (4) print out the position of all MUs (after they move, but before annihilation takes place) (5) annihilate MUs that are in the same grid cell, and (6) print a list of MUs that are annihilated.
Use the object management services (e.g., Update/Reflect Attribute Values) and the time management services (Time Advance Request and Time Advance Grant) of the FDK to generate updated MU positions and to advance the simulation time, respectively. It is recommended you use BRTI for this assignment since it is simpler to use than DRTI, and program each federate in C.
You should define two object classes to exchange position information: RedMU is an object class that includes attributes indicating the position of a single Red MU. Similarly, BlueMU is an object class with attributes indicating the position of a single Blue MU. The red (blue) federate should create an instance of a RedMU (BlueMU) object for each MU it owns, and update the position of RedMU (BlueMU) object instances each time step. The red (blue) federate subscribes to the blue (red) object class in order to receive position updates for Blue (Red) MUs.
You should start by installing the FDK software, and getting the sample programs to run. Modify the sample program that is provided to build your distributed simulation.
You must submit both source
code and an executable for the program. Use the tar command to make an archive of your
files. You should also include a README file describing how to compile and run your program. Please name the tar file ¡°hw2_lastname.tar,¡± for
example, hw2_yang.tar and send it as an attachment to the TA (jeonghwa@cc.gatech.edu)
Below, ¡®%¡¯ denotes the Unix prompt (i.e., type the
command following the ¡®%¡¯. All
work should be done on nighthawk.cc.gatech.edu (an SGI Origin multiprocessor
machine)
Download the FDK (from the class web site) to your
working directory.
Decompress the file:
%gunzip fdk3-04oct02.tar.gz
%tar xvf fdk3-04oct02.tar
Type
%cd FDK3_04OCT02/FEDSIM
To compile FDK3.0 type
%make
Now, compilation has been done. You are ready to run the
sample program.
Add ¡°nighthawk.cc.gatech.edu¡± to your ~/.rhosts file. If the file doesn¡¯t already exist, create a
file of this name containing ¡°nighthawk.cc.gatech.edu
your_login¡± where your_login is
the login name on your account.
Go to the sample program directory:
%cd ./RTIS/BRTI/APP/PING
Edit the script in the file called runon. Make sure the script contains the following two lines to set the ARCH and FMTYPE environment variables:
setenv ARCH SGIMP
setenv FMTYPE MIX
Note, to run on the EDHPC cluster, you would need to set the ARCH environment variable to say ¡°LINUX¡± instead of ¡°SGIMP.¡±
You can now run the tm_ping application program by typing:
%./runon nighthawk nighthawk
This will create two tm_ping processes that run on two
of nighthawk¡¯s processors. Output
is sent to stdout. Also, the
output produced by each federate is dumped to a file created on /tmp (the file name includes your login
name).
To get you started, we have created a variation on tm_ping that sets up publications and subscriptions,
invokes the time management services for a time stepped execution, and sends
and receives update messages. This
program is in example.c
and uses a modified fedfile
which you need to place in the same directory. You will need to modify the makefile.aimk
and runon files in the PING directory
to replace tm_ping with example to compile and run this
program. After making these
modifications, just type %make in the
same directory to compile, and the same runon
command as before to execute the distributed simulation.
The example program is commented to describe what the
program is doing, and how it interfaces to FDK. See the FDK User¡¯s Manual located in the DOC directory of the installation for more
detailed information concerning FDK and the calls and declarations made in the
example program.
If you have
any question doing your homework, ask by email (jeonghwa@cc.gatech.edu) or use the TA
office hour (Tu/Th