程序代写 CSE 10

BugsWorld Introduction
27 February 2019 OSU CSE 1

• You will be working on projects related to various aspects of a game called BugsWorld:

Copyright By PowCoder代写 加微信 powcoder

– The Game
– The Simulator – The Language – The Compiler
27 February 2019

The Game: It’s a Bug’s World!
27 February 2019 OSU CSE 3

The Simulator
• The BugsWorld game is played on a system consisting of:
– Clients – Displays
27 February 2019 OSU CSE 4

The Simulator
• The BugsWorld game is played on a system consisting of:
The server keeps track of “the world”, processes client requests, resolves conflicts.
27 February 2019

The Simulator
• The BugsWorld game is played on a system consisting of:
Each client program simulates creature (bug) behavior for all creatures of one species.
27 February 2019

The Simulator
• The BugsWorld game is played on a system consisting of:
– Displays
Each display shows the current state of the world, plus some statistics about the simulation.
27 February 2019

Each process can run
on a different computer (distributed simulation).
The Simulator
• The BugsWorld game is played on a system consisting of:
– Clients – Displays
27 February 2019 OSU CSE 8

The Language
• The behavior of each species is determined by a
program in the language BL
• Primitiveinstructions:move,turnleft,turnright,
infect, skip
• Control structures: IF-THEN, IF-THEN-ELSE,
• Definingnewinstructions:INSTRUCTION-IS
• Conditions:testwhether“next”cellisempty, friend, enemy, or wall (plus true and random)
27 February 2019 OSU CSE 9

BL Program Example
PROGRAM TryToGuess IS
INSTRUCTION FindObstacle IS WHILE next-is-empty DO
move END WHILE
END FindObstacle …
27 February 2019 OSU CSE 10

BL Program Example
PROGRAM TryToGuess IS
INSTRUCTION FindObstacle IS WHILE next-is-empty DO
move END WHILE
END FindObstacle …
See next slide…
27 February 2019

BL Program Example (Cont’d)
WHILE true DO
FindObstacle
IF next-is-enemy THEN
infect ELSE
IF next-is-wall THEN turnleft
END IF END IF
END WHILE END TryToGuess
27 February 2019
OSU CSE 12

BL Features
• Precise syntax • Case sensitive • Matching ENDs
• Identifiers:
– Start with any of ‘a’..’z’, ‘A’..’Z’
– Followed by any of ‘a’..’z’, ‘A’..’Z’, ‘0’..’9′, ‘-‘
27 February 2019 OSU CSE 13

PROGRAM TryToGuess IS INSTRUCTION FindObstacle IS
WHILE next-is-empty DO move
END WHILE END FindObstacle
WHILE true DO
FindObstacle
IF next-is-enemy THEN
infect ELSE
IF next-is-wall THEN turnleft
END IF END IF
END WHILE END TryToGuess
<20, 15, 20, 6, 7, 0, 5, 2, 12, 12, 3, 5, 18, 8, 17, 1, 5, 18, The Compiler 27 February 2019 OSU CSE 14 PROGRAM TryToGuess IS INSTRUCTION FindObstacle IS WHILE next-is-empty DO move END WHILE END FindObstacle WHILE true DO FindObstacle IF next-is-enemy THEN infect ELSE IF next-is-wall THEN turnleft END IF END IF END WHILE END TryToGuess This string of integers is the object code for the BL program source code shown on the left. <20, 15, 20, 6, 7, 0, 5, 2, 12, 12, 3, 5, 18, 8, 17, 1, 5, 18, The Compiler 27 February 2019 OSU CSE 15 Compiler Structure string of characters (source code) string of tokens (“words”) abstract program integers (object code) 27 February 2019 Code Generator • You will implement at least major parts of all three pieces of the BL compiler: – Tokenizer – Code Generator 27 February 2019 OSU CSE 17 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com