logging in or signing up class1 AscotEdu Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINTLite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 168 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: January 03, 2008 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Software ProjectRobots Battle: Software Project Robots Battle Angela Enosh angela@tau.ac.il Office: Schriber -18, 640-6114 Web: http://www.cs.tau.ac.il/~angela/RobotsBattleSrc/ ProjectSummer2005.htm Course outline: Course outline Two classes at the beginning of the semester Work in groups of TWO. Address questions to me in person, by email or in the forum. Handout next week: Initial design Sample UNIX program Outline cont.: Outline cont. The project definition is in the web-page Get updated at the web page Every Week Programming language: C or C++ Operating system: linux in classroom 04 11-September-2005, the final project. Project overview: Project overview Two robots are fighting each other on a battle field. Each robot tries to gain a victory by hitting the enemy with a laser beam. Robots are controlled by a strategy program It can Move, turns and fire. The robot programming language is an event driven language.Project Overview: Project Overview Your program is composed of two major parts : Understanding (parsing) the robot programs and executes them Simulating the flow of the game (collisions, motion animation). The programming language: The programming language Robot commands, such as “Turn” Event driven program Built-in variables User-defined variables User defined routines Simple arithmeticSample program : NWCH { # NorthWallCollisionHandler # The robot is too close # to the north wall, # turn back turn(180) } SWCH { # SouthWallCollisionHandler # The robot is too close # to the south wall, # turn back turn(-135) } Sample program Sample.str #User defined routine TurnAndFire { Turn(-25) #Built-in routine Fire() #Built-in routine } MyIdleStrategy { while($CurrentLifePoints > 2) $distance = random(0,359) Move($distance) #Built In RandomTurn() #User Defined Fire() #Built-In routine endwhile while($true) TurnAndFire() #User Defined Endwhile } Sample Program (Cont’): Sample Program (Cont’) # Initialization code # This is where the program # starts like “main” in “C” main { #Register Events RegisterOnNorthWallCollisionAlert(NWCH, 1) RegisterOnSouthWallCollisionAlert(SWCH, 1) #Main Strategy – its priority is the smallest by default RegisterOnIdle(MyIdleStrategy) } Built-in Commands: Built-in Commands Robot Commands Move(distance) Turn(angle) Fire() Debug Commands Print("String") Print(variable) Exit()Event Built-in Commands: Event Built-in Commands Wall Collision Event Registration RegisterOnNorthWallCollistionAlert(function, priority) RegisterOnEastWallCollistionAlert(function,priority) RegisterOnWestWallCollistionAlert(function,priority) RegisterOnSouthWallCollistionAlert(function,priority)Event Built-in Commands: Event Built-in Commands RegisterOnEnemyCollisionAlert(function,priority) RegisterOnLaserHit(function,priority) RegisterOnLaserAlert(function,priority) RegisterOnIdle(function)Robot Built-in Commands: Robot Built-in Commands Turn(angle) Rotate the robot by the angle [0-360) around its center. The angle is in degrees. This is a relative angle with respect to the current direction of the robot. Positive angle - turn right , Negative angle - turn left. Built-in Commands (Cont’): Built-in Commands (Cont’) Move(distance) Move in the current direction of the robot by the specified distance and stop. distance may be an integer or a variable of type int It is a continues command Built-in Commands (Cont’): Built-in Commands (Cont’) Fire() Fire laser beam from the center of the robot's position. The laser beam will move ahead in current robots direction. It is a continues commandEvents: Events Types OnXWallCollisionAlert X = North, East, West, South OnEnemyCollisionAlert OnLaserAlert OnLaserHit OnIdle Events have priority Only one event may be active at a time for each robotEvents Registration: Events Registration Event-handling-routines are registered Connect an event to a routine. Assign priority to event. It is possible to re-register an event. WCH { #Wall Collision Handler #Turn back to avoid wall collision Turn(180) Move(100) } Main # Initialization code { # Set up event handlers RegisterOnNorthWallCollisionAlert(WCH, 1) RegisterOnEastWallCollisionAlert(WCH, 1) RegisterOnWestWallCollisionAlert(WCH, 1) RegisterOnSouthWallCollisionAlert(WCH, 1) }Events Priority Policy: Events Priority Policy If a high priority event occurs while a lower priority event is running, the lower priority event-handling-routine is terminated and the high priority event is executed. When the high priority event finishes, the program turns to idle If the same event occurs - it is ignored If a low or equal priority event occurs while a high priority event is running – it is discarded. OnIdle Event: OnIdle Event MyIdleStrategy { #Cause this event to run forever ... while ($true) Turn(45) Fire() endwhile } Main { RegisterOnIdle(MyIdleStrategy) } Idle has priority that is smaller than any other event. If registered it is called when no other event is running Variables and Expressions: Variables and Expressions Constant built-in Variables - sensors Built In Variables User Defined Variables Expressions Constant Variables - sensors: Their values are defined in the source code (web) $EnemyCollisionDistanceAlert ENEMY_DISTANCE_ALERT $WallDistanceAlert WALL_DISTANCE_ALERT $LaserDistanceAlert LASER_DISTANCE_ALERT Constant Variables - sensorsBuilt-in Variables: Built-in Variables There are several built-in variables ($Direction, $CurrentLifePoints etc). Built-in variables are read-only They cannot be changed by the robot program. Built-in Variables: Built-in Variables $Direction $CurrentPositionX $CurrentPositionY $NorthWallDistance $EastWallDistance $WestWallDistance $SouthWallDistanceBuilt-in Variables: Built-in Variables $CurrentEnemyPositionX $CurrentEnemyPositionY $CurrentEnemyDirection $CurrentLifePoints $CurrentLaserBeamPositionX $CurrentLaserBeamPositionY $CurrentLaserBeamDirection $IsEnemyLaserDataValid $true $falseUser Defined Variables: User Defined Variables $[A--Z]([A--Z]|[0--9])* Strategy programmers can define variables. A variable holds real values (i.e. int float or double). Variables are always global. A variable is initialized when it is first used and cannot be deleted Expressions: Expressions Expressions are of the form: <Value> ($name | number) <Value> <op> <Value> (BinOp) <function > (<value>) (e.g., cos, sin…) <function > ( < Value > , < Value > ) (e.g., random(low,high)) $x = 5 $y = 17 $x2 = $x * $x $y2 = $y * $y $len2 = $x2 + $y2 $len = sqrt($len2) $a = Sqrt(-3) # this will return 0. Op = +, -, *, /, <, >, <=, >=, ==, != Flow Control - if: Flow Control - if if ( < value | BinOp > ) else endif Controls the flow of a program. < value > is a constant or a value of a variable or BinOp. A 0 value means false, any other values are true. The else is optional. Flow Control - while: Flow Control - while while ( < value | BinOp > ) endwhile Continue to execute the statements between the while and endwhile as long as value != 0. = Assignment <variable>=<exp> Assign a value to a variable. (e.g., $x=$y+5)Routines: Routines [A--Z]([A--Z]|[0--9])* Routines receive zero parameters and do not return any value. One routine can call another routine using the following syntax: ``FunctionName()'' Routine Example: Routine Example # Compute the square of the variables $dx and $dy # and store the results in $dx2 and $dy2 respectively # SQR2 { $dx2 = $dx * $dx $dy2 = $dy * $dy } ComputeDistance { $dx = $CurrentPositionX - $CurrentEnemyPositionX $dy = $CurrentPositionY - $CurrentEnemyPositionY SQR2() $d2 = $dx2 + $dy2 $distance = sqrt($d2) }LaserBeam: LaserBeam Laser beam represented as a line segment with distance of LASER_BEAM_LENGTH struct LaserBeam{ double x, y; //current position double direction;//(0-360]degree bool isVisible;//set true when the laser need //to be drawn };Robot: Robot Robot is represented as a triangle. Each robot can Turn, Fire and Move. struct Robot{ double x,y;//current position double direction; int hitPoints; Status status;//move | stopped char* name; LaserBeam laserBeam; } Canonical Robot: Canonical Robot P1(-w/2, -h/3) P2(w/2, -h/3) P3 (0, h*2/3) (Cx,Cy)SimpleTest: SimpleTest int main (int argc, char* argv[]){ //Read Input //Parse //Create Internal Representation of the //strategies files. rs.robots[0].setName("Megatron"); //renderState rs.robots[1].setName("Optimus"); robotsBattleGrInit(animate); return 0; }SimpleTest (Cont’): SimpleTest (Cont’) #include "RobotsBattleGr.h" RenderSceneState rs; static void animate(){ /* Main Loop which update the current state of the scene each clock tick */ /*Update Scene Status*/ rs.robots[0].Turn(2); rs.robots[1].Turn(-7); rs.laserBeam(0).direction = 45; rs.laserBeam(0).x++ rs.laserBeam(0).y++; Render(rs); }Simulation: Simulation The simulation is performed on a two dimensional RING_WIDTH×RING_HEIGHT field. the bottom-left corner of the ring is coordinate (0,0). Angles are clockwise, (Turn(90) turn right). 0,0RobotsBattleGr : RobotsBattleGr RobotsBattleGr handles the scene drawing of the robots and laser beams. Your task is to Update the robots and the laser beam positions/directions in world coordinate. Simulate motion for the robot and the laser beam Calculate collisions in the scene. Use SimpleTest as a starting point for your project.Simulation (Cont’): Simulation (Cont’) Input two robots programs (strategy files) The two robots programs run in parallel Work in time-steps (clock ticks) For every robot Execute a single instruction - Move robot if needed - Move laser beam if needed Simulation Command Line: Simulation Command Line The command line is: startbattle [-c <cycles>] [-s] [-n <number of battles>] <robot's name > <its strategy file name > <robot's name > <its strategy file name> -c Set the maximal number of clock ticks for one battle (default 2000). -s (optional) run the simulation in a single step mode. -n <number of battles> (optional) (default is 10). For example: “startbattle Megatron Megatrone.str BumbaleBee BumbaleBee.str '' Simulation Output: Simulation Output The output of the simulation is as follows: In case of an error (usually during parsing) output the following line and exit the program: printf("Error Robot File Name:%s line:%d, Description:%s\n", robot_file_name, line_number, reason); Simulation Output: Simulation Output Each simulation output should be appended to BattleScore.res -------------------------------------------------------------------- Battle Duration: <time duration of battle in clock ticks> Battle Winner: <Robot Name> Battle Score: <Robot A Life points> <Robot B Life points > Battle Strategy: <Robot A Strategy File Name> <Robot B Strategy File Name> Battle Remark: <cause of winning [Enemy Destruction | Out of Ring | Time out]> -------------------------------------------------------------------- In case of a tie, the two robots' names will appear in the "Battle Winner" line. At the end of the file state the final winner (after #n battles) Requirements: Requirements A working project Documentation A non-trivial robot programDeveloping software: Developing software Specifications Final product Executable Documentation Examples [+User Manual] Design Implement Test Documentation User ManualDesign - Modules: Design - Modules A set of related functions Manage a single entity Modules interact through an interface Modules: Modules You know your set of modules is OK if: You can name your modules You can define the interaction between modules You can specify what services modules require from one another (interface)The initial design: The initial design Read the project definition carefully Include a diagram A short description of the modules List data structures that you will need Next week: Next week More about the project Software engineering QuestionsMakefile: Makefile Dependency tree DAG actually myprogram : f1.o f2.o f3.o f1.o: f1.c myslist.h f2.o: f2.c graphics.h globals.h f3.o: f3.c globals.h myprogram f1.c mylist.h f2.c f3.c globals.h graphics.hMakefile: Makefile Dependency tree Commands myprogram : f1.o f2.o f3.o <TAB> gcc –o myprogram f1.o f2.o f3.o f1.o: f1.c myslist.h <TAB> gcc –c –Wall f1.c f2.o: f2.c graphics.h globals.h <TAB> gcc –c –Wall f2.c f3.o: f3.c globals.h <TAB> gcc –c –Wall f3.cMakefile: Makefile Dependency tree Commands Automatic variables myprogram : f1.o f2.o f3.o <TAB> gcc –o $@ $^ f1.o: f1.c myslist.h <TAB> gcc –c –Wall $< f2.o: f2.c graphics.h globals.h <TAB> gcc –c –Wall $< f3.o: f3.c globals.h <TAB> gcc –c –Wall $<Makefile: Makefile Dependency tree Commands Automatic variables Variables CFLAGS = -c -g –Wall LIBS = -lm myprogram : f1.o f2.o f3.o <TAB> gcc –o $@ $^ $(LIBS) f1.o: f1.c myslist.h <TAB> gcc –c $(CFLAGS) $< f2.o: f2.c graphics.h globals.h <TAB> gcc –c $(CFLAGS) $< f3.o: f3.c globals.h <TAB> gcc –c $(CFLAGS) $<Makefile: Makefile Dependency tree Commands Automatic variables Variables Implicit rules Multiple targets Default: make all “make clean” More information NOVA: “tkinfo make” CFLAGS = -g –Wall LIBS = -lm .c.o: <TAB> $(CC) –c $(CFLAGS) $< all: myprogram myprogram : f1.o f2.o f3.o <TAB> gcc –o $@ $^ $(LIBS) f1.o: f1.c myslist.h f2.o: f2.c graphics.h globals.h f3.o: f3.c globals.h clean: <TAB> rm –f *.o *~Debugging in Unix (gdb): Debugging in Unix (gdb) Compile using “gcc -g” gdb myprogram l main - list the function main, l misc.c:foo - list foo() in misc.c b 52 - set a break point at line 52 help where prints the stack up,down move in the stack, to inspect variables of calling routines. run the program n,s step over and step into Resources Online help while using GDB. Quick reference card, download from the web-page > “info GDB” command on the unix You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
class1 AscotEdu Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINTLite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 168 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: January 03, 2008 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Software ProjectRobots Battle: Software Project Robots Battle Angela Enosh angela@tau.ac.il Office: Schriber -18, 640-6114 Web: http://www.cs.tau.ac.il/~angela/RobotsBattleSrc/ ProjectSummer2005.htm Course outline: Course outline Two classes at the beginning of the semester Work in groups of TWO. Address questions to me in person, by email or in the forum. Handout next week: Initial design Sample UNIX program Outline cont.: Outline cont. The project definition is in the web-page Get updated at the web page Every Week Programming language: C or C++ Operating system: linux in classroom 04 11-September-2005, the final project. Project overview: Project overview Two robots are fighting each other on a battle field. Each robot tries to gain a victory by hitting the enemy with a laser beam. Robots are controlled by a strategy program It can Move, turns and fire. The robot programming language is an event driven language.Project Overview: Project Overview Your program is composed of two major parts : Understanding (parsing) the robot programs and executes them Simulating the flow of the game (collisions, motion animation). The programming language: The programming language Robot commands, such as “Turn” Event driven program Built-in variables User-defined variables User defined routines Simple arithmeticSample program : NWCH { # NorthWallCollisionHandler # The robot is too close # to the north wall, # turn back turn(180) } SWCH { # SouthWallCollisionHandler # The robot is too close # to the south wall, # turn back turn(-135) } Sample program Sample.str #User defined routine TurnAndFire { Turn(-25) #Built-in routine Fire() #Built-in routine } MyIdleStrategy { while($CurrentLifePoints > 2) $distance = random(0,359) Move($distance) #Built In RandomTurn() #User Defined Fire() #Built-In routine endwhile while($true) TurnAndFire() #User Defined Endwhile } Sample Program (Cont’): Sample Program (Cont’) # Initialization code # This is where the program # starts like “main” in “C” main { #Register Events RegisterOnNorthWallCollisionAlert(NWCH, 1) RegisterOnSouthWallCollisionAlert(SWCH, 1) #Main Strategy – its priority is the smallest by default RegisterOnIdle(MyIdleStrategy) } Built-in Commands: Built-in Commands Robot Commands Move(distance) Turn(angle) Fire() Debug Commands Print("String") Print(variable) Exit()Event Built-in Commands: Event Built-in Commands Wall Collision Event Registration RegisterOnNorthWallCollistionAlert(function, priority) RegisterOnEastWallCollistionAlert(function,priority) RegisterOnWestWallCollistionAlert(function,priority) RegisterOnSouthWallCollistionAlert(function,priority)Event Built-in Commands: Event Built-in Commands RegisterOnEnemyCollisionAlert(function,priority) RegisterOnLaserHit(function,priority) RegisterOnLaserAlert(function,priority) RegisterOnIdle(function)Robot Built-in Commands: Robot Built-in Commands Turn(angle) Rotate the robot by the angle [0-360) around its center. The angle is in degrees. This is a relative angle with respect to the current direction of the robot. Positive angle - turn right , Negative angle - turn left. Built-in Commands (Cont’): Built-in Commands (Cont’) Move(distance) Move in the current direction of the robot by the specified distance and stop. distance may be an integer or a variable of type int It is a continues command Built-in Commands (Cont’): Built-in Commands (Cont’) Fire() Fire laser beam from the center of the robot's position. The laser beam will move ahead in current robots direction. It is a continues commandEvents: Events Types OnXWallCollisionAlert X = North, East, West, South OnEnemyCollisionAlert OnLaserAlert OnLaserHit OnIdle Events have priority Only one event may be active at a time for each robotEvents Registration: Events Registration Event-handling-routines are registered Connect an event to a routine. Assign priority to event. It is possible to re-register an event. WCH { #Wall Collision Handler #Turn back to avoid wall collision Turn(180) Move(100) } Main # Initialization code { # Set up event handlers RegisterOnNorthWallCollisionAlert(WCH, 1) RegisterOnEastWallCollisionAlert(WCH, 1) RegisterOnWestWallCollisionAlert(WCH, 1) RegisterOnSouthWallCollisionAlert(WCH, 1) }Events Priority Policy: Events Priority Policy If a high priority event occurs while a lower priority event is running, the lower priority event-handling-routine is terminated and the high priority event is executed. When the high priority event finishes, the program turns to idle If the same event occurs - it is ignored If a low or equal priority event occurs while a high priority event is running – it is discarded. OnIdle Event: OnIdle Event MyIdleStrategy { #Cause this event to run forever ... while ($true) Turn(45) Fire() endwhile } Main { RegisterOnIdle(MyIdleStrategy) } Idle has priority that is smaller than any other event. If registered it is called when no other event is running Variables and Expressions: Variables and Expressions Constant built-in Variables - sensors Built In Variables User Defined Variables Expressions Constant Variables - sensors: Their values are defined in the source code (web) $EnemyCollisionDistanceAlert ENEMY_DISTANCE_ALERT $WallDistanceAlert WALL_DISTANCE_ALERT $LaserDistanceAlert LASER_DISTANCE_ALERT Constant Variables - sensorsBuilt-in Variables: Built-in Variables There are several built-in variables ($Direction, $CurrentLifePoints etc). Built-in variables are read-only They cannot be changed by the robot program. Built-in Variables: Built-in Variables $Direction $CurrentPositionX $CurrentPositionY $NorthWallDistance $EastWallDistance $WestWallDistance $SouthWallDistanceBuilt-in Variables: Built-in Variables $CurrentEnemyPositionX $CurrentEnemyPositionY $CurrentEnemyDirection $CurrentLifePoints $CurrentLaserBeamPositionX $CurrentLaserBeamPositionY $CurrentLaserBeamDirection $IsEnemyLaserDataValid $true $falseUser Defined Variables: User Defined Variables $[A--Z]([A--Z]|[0--9])* Strategy programmers can define variables. A variable holds real values (i.e. int float or double). Variables are always global. A variable is initialized when it is first used and cannot be deleted Expressions: Expressions Expressions are of the form: <Value> ($name | number) <Value> <op> <Value> (BinOp) <function > (<value>) (e.g., cos, sin…) <function > ( < Value > , < Value > ) (e.g., random(low,high)) $x = 5 $y = 17 $x2 = $x * $x $y2 = $y * $y $len2 = $x2 + $y2 $len = sqrt($len2) $a = Sqrt(-3) # this will return 0. Op = +, -, *, /, <, >, <=, >=, ==, != Flow Control - if: Flow Control - if if ( < value | BinOp > ) else endif Controls the flow of a program. < value > is a constant or a value of a variable or BinOp. A 0 value means false, any other values are true. The else is optional. Flow Control - while: Flow Control - while while ( < value | BinOp > ) endwhile Continue to execute the statements between the while and endwhile as long as value != 0. = Assignment <variable>=<exp> Assign a value to a variable. (e.g., $x=$y+5)Routines: Routines [A--Z]([A--Z]|[0--9])* Routines receive zero parameters and do not return any value. One routine can call another routine using the following syntax: ``FunctionName()'' Routine Example: Routine Example # Compute the square of the variables $dx and $dy # and store the results in $dx2 and $dy2 respectively # SQR2 { $dx2 = $dx * $dx $dy2 = $dy * $dy } ComputeDistance { $dx = $CurrentPositionX - $CurrentEnemyPositionX $dy = $CurrentPositionY - $CurrentEnemyPositionY SQR2() $d2 = $dx2 + $dy2 $distance = sqrt($d2) }LaserBeam: LaserBeam Laser beam represented as a line segment with distance of LASER_BEAM_LENGTH struct LaserBeam{ double x, y; //current position double direction;//(0-360]degree bool isVisible;//set true when the laser need //to be drawn };Robot: Robot Robot is represented as a triangle. Each robot can Turn, Fire and Move. struct Robot{ double x,y;//current position double direction; int hitPoints; Status status;//move | stopped char* name; LaserBeam laserBeam; } Canonical Robot: Canonical Robot P1(-w/2, -h/3) P2(w/2, -h/3) P3 (0, h*2/3) (Cx,Cy)SimpleTest: SimpleTest int main (int argc, char* argv[]){ //Read Input //Parse //Create Internal Representation of the //strategies files. rs.robots[0].setName("Megatron"); //renderState rs.robots[1].setName("Optimus"); robotsBattleGrInit(animate); return 0; }SimpleTest (Cont’): SimpleTest (Cont’) #include "RobotsBattleGr.h" RenderSceneState rs; static void animate(){ /* Main Loop which update the current state of the scene each clock tick */ /*Update Scene Status*/ rs.robots[0].Turn(2); rs.robots[1].Turn(-7); rs.laserBeam(0).direction = 45; rs.laserBeam(0).x++ rs.laserBeam(0).y++; Render(rs); }Simulation: Simulation The simulation is performed on a two dimensional RING_WIDTH×RING_HEIGHT field. the bottom-left corner of the ring is coordinate (0,0). Angles are clockwise, (Turn(90) turn right). 0,0RobotsBattleGr : RobotsBattleGr RobotsBattleGr handles the scene drawing of the robots and laser beams. Your task is to Update the robots and the laser beam positions/directions in world coordinate. Simulate motion for the robot and the laser beam Calculate collisions in the scene. Use SimpleTest as a starting point for your project.Simulation (Cont’): Simulation (Cont’) Input two robots programs (strategy files) The two robots programs run in parallel Work in time-steps (clock ticks) For every robot Execute a single instruction - Move robot if needed - Move laser beam if needed Simulation Command Line: Simulation Command Line The command line is: startbattle [-c <cycles>] [-s] [-n <number of battles>] <robot's name > <its strategy file name > <robot's name > <its strategy file name> -c Set the maximal number of clock ticks for one battle (default 2000). -s (optional) run the simulation in a single step mode. -n <number of battles> (optional) (default is 10). For example: “startbattle Megatron Megatrone.str BumbaleBee BumbaleBee.str '' Simulation Output: Simulation Output The output of the simulation is as follows: In case of an error (usually during parsing) output the following line and exit the program: printf("Error Robot File Name:%s line:%d, Description:%s\n", robot_file_name, line_number, reason); Simulation Output: Simulation Output Each simulation output should be appended to BattleScore.res -------------------------------------------------------------------- Battle Duration: <time duration of battle in clock ticks> Battle Winner: <Robot Name> Battle Score: <Robot A Life points> <Robot B Life points > Battle Strategy: <Robot A Strategy File Name> <Robot B Strategy File Name> Battle Remark: <cause of winning [Enemy Destruction | Out of Ring | Time out]> -------------------------------------------------------------------- In case of a tie, the two robots' names will appear in the "Battle Winner" line. At the end of the file state the final winner (after #n battles) Requirements: Requirements A working project Documentation A non-trivial robot programDeveloping software: Developing software Specifications Final product Executable Documentation Examples [+User Manual] Design Implement Test Documentation User ManualDesign - Modules: Design - Modules A set of related functions Manage a single entity Modules interact through an interface Modules: Modules You know your set of modules is OK if: You can name your modules You can define the interaction between modules You can specify what services modules require from one another (interface)The initial design: The initial design Read the project definition carefully Include a diagram A short description of the modules List data structures that you will need Next week: Next week More about the project Software engineering QuestionsMakefile: Makefile Dependency tree DAG actually myprogram : f1.o f2.o f3.o f1.o: f1.c myslist.h f2.o: f2.c graphics.h globals.h f3.o: f3.c globals.h myprogram f1.c mylist.h f2.c f3.c globals.h graphics.hMakefile: Makefile Dependency tree Commands myprogram : f1.o f2.o f3.o <TAB> gcc –o myprogram f1.o f2.o f3.o f1.o: f1.c myslist.h <TAB> gcc –c –Wall f1.c f2.o: f2.c graphics.h globals.h <TAB> gcc –c –Wall f2.c f3.o: f3.c globals.h <TAB> gcc –c –Wall f3.cMakefile: Makefile Dependency tree Commands Automatic variables myprogram : f1.o f2.o f3.o <TAB> gcc –o $@ $^ f1.o: f1.c myslist.h <TAB> gcc –c –Wall $< f2.o: f2.c graphics.h globals.h <TAB> gcc –c –Wall $< f3.o: f3.c globals.h <TAB> gcc –c –Wall $<Makefile: Makefile Dependency tree Commands Automatic variables Variables CFLAGS = -c -g –Wall LIBS = -lm myprogram : f1.o f2.o f3.o <TAB> gcc –o $@ $^ $(LIBS) f1.o: f1.c myslist.h <TAB> gcc –c $(CFLAGS) $< f2.o: f2.c graphics.h globals.h <TAB> gcc –c $(CFLAGS) $< f3.o: f3.c globals.h <TAB> gcc –c $(CFLAGS) $<Makefile: Makefile Dependency tree Commands Automatic variables Variables Implicit rules Multiple targets Default: make all “make clean” More information NOVA: “tkinfo make” CFLAGS = -g –Wall LIBS = -lm .c.o: <TAB> $(CC) –c $(CFLAGS) $< all: myprogram myprogram : f1.o f2.o f3.o <TAB> gcc –o $@ $^ $(LIBS) f1.o: f1.c myslist.h f2.o: f2.c graphics.h globals.h f3.o: f3.c globals.h clean: <TAB> rm –f *.o *~Debugging in Unix (gdb): Debugging in Unix (gdb) Compile using “gcc -g” gdb myprogram l main - list the function main, l misc.c:foo - list foo() in misc.c b 52 - set a break point at line 52 help where prints the stack up,down move in the stack, to inspect variables of calling routines. run the program n,s step over and step into Resources Online help while using GDB. Quick reference card, download from the web-page > “info GDB” command on the unix