In preparation for the lab, you will design your own bug species for the BugsWorld contest that will take place during the lab. This document gives you a brief introduction to the applications involved and how to set up and run a simulation. Before the lab you will need to familiarize yourself with all the tools and, most important, write your own BL program to create the invincible bug. A compiler is provided so that you can fix any syntax errors in your BL program before the lab. You will also be able to run simulations to test the behavior and strength of your bugs. Note that all the programs needed can currently be executed only on the coelinux platform. For this lab you will have to use your coelinux account.
For your homework, turn in a printed copy of the BL program for your bugs and make sure it compiles successfully.
As we discussed in class, there are four applications that you need to be familiar with: the BL compiler (bw-compiler), the server application (bw-server), the client application (bw-client), and the display application (bw-display).
Compiling Your BL Program(s) and Running the Applications on coelinux from Your Own Computer
To compile your bug program(s) you will need to upload them to your coelinux account and to run the server, client, and display applications you will need an ssh connection to coelinux.
You can either create the source files on your own computer and upload them to coelinux or you can create and edit them directly on coelinux. Some instructions on how to approach these tasks are available here.
The BL Compiler
The compiler translates a BL program into a compiled form that the client application can interpret. It is invoked with the command (in an coelinux terminal window):
/share/CSE/class/software/bin/bw-compiler < input.bl > output.bo
where input.bl is the text file containing the BL source program, and output.bo is the text file containing the string of integers representing the corresponding object code. Although you can name these files whatever you like, you may want to follow the convention that all BL source files terminate with ".bl" and all compiled BL files terminate with ".bo".
At this time, the compiler provided does not print extremely useful error messages. It simply aborts execution as soon as it finds a syntax error, and prints a message stating what it expected instead. Although more helpful messages would certainly be convenient, the syntax of BL is simple enough that you should not have real problems fixing any syntax errors. You may want to start with a small program, and keep adding to it while periodically using the compiler to check that the syntax is correct.
The Server
To run a simulation, the first thing you want to do is start up the server application. This is done by simply invoking the command:
/share/CSE/class/software/bin/bw-server
In response to that, the server replies with a message stating on what machine it is running and the port number clients can use to connect to it. You may want to write those down on a piece of paper since you will need them to start all client and display applications, and other output from the server may make machine name and port number scroll out of view.
The server has several command line options that can be used to modify its default behavior. Type
/share/CSE/class/software/bin/bw-server -h
to see a list of the options currently supported. For the time being, the defaults should be enough for your testing purposes.
Note that the server will not stop running until you kill it. Please do not run it in the background and leave it running after you are done with it. Always make sure all the servers you started are killed before you log out (use control-c in the terminal window where you started the server to kill it).
The Client
Once the server is up and running, and you know the machine name and the port number, you can start the clients. To start a client, type in a separate terminal window the command:
/share/CSE/class/software/bin/bw-client
In response to that the client application will ask you for three pieces of information: (1) the name of the file with the object code for the species of bugs that the client will handle; (2) the name of the machine on which the server is running; (3) the server port number. Answer each prompt with the appropriate information and the client will connect to the server and start interpreting the bugs program. (Note that although the server will give you the complete name of the machine it is running on, e.g., alpha.cse.ohio-state.edu, you only need to give the simple name to the client, e.g., alpha.)
The client will print messages informing you of when a bug of your species has been born and when it dies. It will complete execution only when all bugs of your species are extinct or when the server terminates.
The Display
After the server is started and either before or after any client is started, you can run a display applications. To start a display, type in a separate terminal window the command:
/share/CSE/class/software/bin/bw-display
The display application will ask you for the name of the machine running the server and for the server port number. Type the appropriate information and the display window will appear showing what's going on in the simulation. The display process will also keep executing until the server is killed.
Running the display application from a terminal requires an X11 server to be running on your machine. FastX provides such an option. However, note that running the display application is not required to run a simulation: all that is needed are the server and client applications.
One final note: We tried to keep this document as short as possible while still giving enough information to get you started with the compiler and the simulation environment. If you need any further information, please make sure to ask.