Program Algorithm Design – Expressed in Pseudo-Code
Program Algorithm Design – Expressed in Pseudo-CodeThe pseudo-code was first done individually by each member for their assigned programming tasks. Then we compiled all the pseudo-code to produce a program algorithm design. This task was done before coding the ‘Virtual Robot Obstacle Course’ in Python because it gives us an outline of how we would layout the code in Python, and it also provides us with the opportunity to see how the code would run.Load Modules, Objects and Constant VariablesImport ModulesGET Tkinter moduleGET ttk moduleSet CanvasINITILISE windowCREATE canvas with resolution 854x480 and white backgroundDISPLAY "Sloths Virtual Robot" as window nameCREATE window with resolution 874x568SET window as not resizableVelocity and Robot MovementSET x velocity 5.0SET y velocity to 10.0SET move right to x1 + x velocity and x2 + x velocitySET move left to robot’s left side – x velocity and robot’s right side – x velocitySET move up to robot’s top side – y velocity and robot’s bottom side – y velocitySET move down to robot’s top side + y velocity and robot’s bottom side + y velocityEstablish Screen BoundariesSET minimum x axis to 0.0SET minimum y axis to 0.0SET maximum x axis to 400.0SET maximum y axis to 300.0Create RobotCREATE rectangle with (name, left side’s coordinates, top side’s coordinates, right side’s coordinates, bottom side coordinates)SET variables for sides of the robot (x1, y1, x2, y2)GENERATE random number for x co-ordinate (From 0 TO 854)GENERATE random number for y co-ordinate (From 0 TO 480)PLACE robot at random chosen co-ordinatesCreate CountdownCREATE countdown label displaying "00:00:00"PLACE countdownCREATE combo box for map selection displaying 6 maps to choosePLACE combo box PAD canvasIf Dropdown Box pressedIF Dropdown box pressed SHOW selections of map, map 1, map 2 etc… SELECT map LOAD ObjectsEND IF Create and Place ButtonsCREATE Start buttonCREATE Stop buttonCREATE Reset buttonPLACE Start button in correct placePLACE Stop button in correct placePLACE Reset button in correct place While LoopCountdown: RED BLOCK COLOURINGIF Start button is pressed REPEAT change random block colour to red every “00:00:05” UNTIL countdown is “00:00:00”ELSE IF Stop button is pressed STOP change random block colour to redELSE IF Reset button is pressed STOP change random block colour to redEND IF Robot has reached the boundaries (reverse direction)If x1 is less than or equal to minimum x axis + 10.0SET x velocity to + 10.0END IFIF y1 is less than or equal to minimum y axis + 10.0SET y velocity by + 5.0END IFIF x2 is greater than or equal to maximum x axis – 10.0SET x velocity to - 10.0END IFIF y2 is greater than or equal to maximum y axis – 10.0SET y velocity to - 5.0END IFRobot has detected and responded to an objectDETECT LEFT SIDE OF THE OBJECTIF x2 > (obx1 – 10) and x2 < (obx1 + 10) and y1 < oby1 and y1 > oby2SET x velocity = -10.0END IFDETECT RIGHT SIDE OF THE OBJECTIF x1 < (obx2 + 10) and x1 > (obx2 – 10) and y1 < oby1 and y1 > oby2SET x velocity = 10.0END IFDETECT TOP SIDE OF THE OBJECTIF y2 < (oby1 – 10) and y2 > (oby1 + 10) and x1 < obx1 and x1 > obx2 SET y velocity = -10.0END IFDETECT BOTTOM OF THE OBJECTIf y1 > (oby2 – 10) and y1 < (oby2 + 10) and x1 < obx1 and x1 > obx2SET velocity = 10.0END IFCheck for change selectionIF map selected BREAK out of countdown loop on startEND IFWhen changed reload polygonsIF Reload polygonSEND the robot to the next polygonEND IFCountdown: Map ChangeIF map is changed BREAK out of countdown loop on startEND IFPROMPT “Map has been changed. Press Start to start again.”Countdown: Start Button IF Start button is pressed SET countdown to “00:01:00”REPEAT countdown – 1 and PRINT countdown – 1UNTIL countdown is “00:00:00”PRINT “00:00:00”PROMPT “Press Start to Start Again”END IFCountdown: Stop ButtonIF Stop button is pressedBREAK out of countdown loop on startEND IFCountdown: Reset ButtonIF Reset button is pressedSET countdown to “00:01:00”END IFStop RobotIf Stop button pressedBREAK Movement loopBREAK Countdown LoopEXIT Countdown LoopPROMPT user program has stopped and choose start againENDIFHandling Screen UpdatesSET the time skip to 0.1 and delete the previous imageUPDATE the canvasIf stop button pressed break movement loopIF Stop button pressedBREAK Movement loopPAUSE screenEND IFDespawn robotThe robot will disappear and go to the next mapReset Timer IF Reset timer is activatedSTOP countdown to “00:01:00”RESET countdownEND IFThe highlighted pseudo-code (grey) is the pseudo-code that I did for the countdown. When I individually wrote the pseudo-code for the countdown, I broke the countdown into segments so it would be clearer to understand by another person. This proved to be beneficial when the project group compiled all the pseudo-code together because the headings showed what the pseudo-code corresponded to. However adjusts will be made as we code the project in Python because some sections may require more operations than we first predicted. ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- lighting design jobs in texas
- code to pseudo code converter
- pseudo code to python
- pseudo code to python converter
- python to pseudo code converter
- best design schools in us
- best design schools in america
- design methodologies in software engineering
- top interior design schools in america
- program to design room
- free program to design room
- pseudo code for fibonacci sequence