Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello. This is for C++, any help would be amazing. In this program, you will write an interpreter for a language similar to the Lightbot

Hello. This is for C++, any help would be amazing.

image text in transcribedimage text in transcribedimage text in transcribed

In this program, you will write an interpreter for a language similar to the Lightbot language. The interpreter will take as input an initial board configuration, including the location of the robot (the robot always starts facing to the right), and a program. It must then compute the resulting board configuration, and determine whether the bot will win the level or not (by switching on all the lights and stopping without dying). "Switching" on a square toggles the light if there is one, and does nothing otherwise. Language Commands: Left rotate left 90 degrees Right rotate right 90 degrees Forward go forward one square Switch toggle light if there is one in the current square If Condition { Statements } Check the condition. If it is true, execute the statements, otherwise skip to after the close } Possible conditions: forwardopen, backopen, leftopen, rightopen forwardclosed, backclosed, leftclosed, rightClosed hasLight, lighton, lightoff Repeat N { Statements } Repeat the statements N times Break Break out of a loop Procedure procedureName { Statements } Define a procedure called procedureName. When it is run, do the Statements. If you reach the end of the statements, return to the calling procedure. Also return on a Return statement. Return Return from the current procedure procedureName Call the procedure. Execute its statements. When control returns, begin execution at the next location. Stop Stop the program In this program, you will write an interpreter for a language similar to the Lightbot language. The interpreter will take as input an initial board configuration, including the location of the robot (the robot always starts facing to the right), and a program. It must then compute the resulting board configuration, and determine whether the bot will win the level or not (by switching on all the lights and stopping without dying). "Switching" on a square toggles the light if there is one, and does nothing otherwise. Language Commands: Left rotate left 90 degrees Right rotate right 90 degrees Forward go forward one square Switch toggle light if there is one in the current square If Condition { Statements } Check the condition. If it is true, execute the statements, otherwise skip to after the close } Possible conditions: forwardopen, backopen, leftopen, rightopen forwardclosed, backclosed, leftclosed, rightClosed hasLight, lighton, lightoff Repeat N { Statements } Repeat the statements N times Break Break out of a loop Procedure procedureName { Statements } Define a procedure called procedureName. When it is run, do the Statements. If you reach the end of the statements, return to the calling procedure. Also return on a Return statement. Return Return from the current procedure procedureName Call the procedure. Execute its statements. When control returns, begin execution at the next location. Stop Stop the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

Students also viewed these Databases questions

Question

Explain how a certain behavior could be legal but not ethical.

Answered: 1 week ago