BugsWorld Project
-
Upload
arthur-espinoza -
Category
Documents
-
view
47 -
download
0
description
Transcript of BugsWorld Project
![Page 1: BugsWorld Project](https://reader036.fdocuments.in/reader036/viewer/2022082505/56812b26550346895d8f2c69/html5/thumbnails/1.jpg)
BugsWorld Project
The Game The Simulator The Language The Translator
![Page 2: BugsWorld Project](https://reader036.fdocuments.in/reader036/viewer/2022082505/56812b26550346895d8f2c69/html5/thumbnails/2.jpg)
The Game: It’s a BugsWorld!
![Page 3: BugsWorld Project](https://reader036.fdocuments.in/reader036/viewer/2022082505/56812b26550346895d8f2c69/html5/thumbnails/3.jpg)
The Simulator
Client
Server
Client
Client
Display
Display
![Page 4: BugsWorld Project](https://reader036.fdocuments.in/reader036/viewer/2022082505/56812b26550346895d8f2c69/html5/thumbnails/4.jpg)
Simulator Continued… One server, multiple clients and displays Server keeps track of world, processes
client requests, resolves conflicts Client simulates creature behavior for
all creatures of one species Display shows current state of world
plus some statistics about the simulation
Each process can run on a different computer (distributed simulation)
![Page 5: BugsWorld Project](https://reader036.fdocuments.in/reader036/viewer/2022082505/56812b26550346895d8f2c69/html5/thumbnails/5.jpg)
The Language: BL The behavior of each species is determined by
a program in BL Primitive instructions: move, turnleft, turnright,
infect, skip Control structures: IF-THEN, IF-THEN-ELSE,
WHILE-DO Defining new instructions: INSTRUCTION-IS Conditions: test whether next cell is empty,
friend, enemy, or wall (plus true and random)
![Page 6: BugsWorld Project](https://reader036.fdocuments.in/reader036/viewer/2022082505/56812b26550346895d8f2c69/html5/thumbnails/6.jpg)
An Example
PROGRAM TryToGuess IS
INSTRUCTION FindObstacle IS WHILE next-is-empty DO move END WHILE END FindObstacle
BEGIN # TryToGuess WHILE true DO FindObstacle IF next-is-enemy THEN infect ELSE IF next-is-wall THEN turnleft ELSE # next-is-friend skip END IF END IF END WHILEEND TryToGuess
![Page 7: BugsWorld Project](https://reader036.fdocuments.in/reader036/viewer/2022082505/56812b26550346895d8f2c69/html5/thumbnails/7.jpg)
Language Continued…
Precise syntax Case sensitive Matching ENDs Comments Identifiers
start with ‘a’..’z’,’A’..’Z’ followed by any of
‘a’..’z’,’A’..’Z’,’0’..’9’,’-’
![Page 8: BugsWorld Project](https://reader036.fdocuments.in/reader036/viewer/2022082505/56812b26550346895d8f2c69/html5/thumbnails/8.jpg)
The TranslatorPROGRAM TryToGuess IS INSTRUCTION FindObstacle IS WHILE next-is-empty DO move END WHILE END FindObstacleBEGIN # TryToGuess WHILE true DO FindObstacle IF next-is-enemy THEN infect ELSE IF next-is-wall THEN turnleft ELSE # next-is-friend skip END IF END IF END WHILEEND TryToGuess
<20, 15, 20, 6, 7, 0, 5, 2, 12, 12, 3, 5, 18, 8, 17, 1, 5, 18, 4, 5, 0>
![Page 9: BugsWorld Project](https://reader036.fdocuments.in/reader036/viewer/2022082505/56812b26550346895d8f2c69/html5/thumbnails/9.jpg)
Translator Continued…
CodeGenerator
ParserTokenizer
string ofcharacters
(source code)
string oftokens
abstractprogram
string ofintegers
(object code)
![Page 10: BugsWorld Project](https://reader036.fdocuments.in/reader036/viewer/2022082505/56812b26550346895d8f2c69/html5/thumbnails/10.jpg)
What You Will Do Build the translator
Implement abstract program component (Lab#2, Closed Lab #4)
Implement parser extension (Lab #3) Implement code generator extension (Lab
#4) Implement tokenizer component (Lab #5)
Complete the client Implement interpreter (Closed Lab #6)