Hi There!

I'm Dan Schlegel, an Associate Professor in the Computer Science Department at SUNY Oswego

CSC344 – Assignment 4

Microproject

Read the below project description. Then, given a laser emitter height and list of triples which represent mirror locations and orientations, generate the path the laser follows. Use the characters / and \ to represent the mirror orientations. For example, using the example given below, the following is output:

Main Project: Frickin Laser Beams!

You’ve just started a new gig as a physical security penetration tester, and your latest job makes use of a laser tripwire system. Being more on the brains than brawn side of the spectrum, you decide not to risk trying to maneuver through the lasers, and instead to divert them using a clever collection of mirrors you recently acquired so that you can just walk through.

Conveniently, the facility only makes use of lasers which shoot straight across the room horizontally – no funny angles. You therefore set all of your mirrors to 45 degrees and get to work. You will need to create an area free of the laser at least 6 feet tall by 2 feet wide, located as shown in the image below. The room is 12 feet wide and 10 feet tall. It is convenient to think of the room as a 12×10 grid. There may be obstacles on the ceiling of varying sizes (but always conforming to the grid), making the job a bit more difficult. You also only have 8 mirrors (each of which fits perfectly in, and occupies an entire, 1×1 grid space).

Lasers!

In Prolog you will create a program which automatically figures out where the mirrors should be placed, given a height of laser emitter, and the coordinates of obstacles on the ceiling. You must output where these mirrors will go.

Summary Constraints and Assumptions

You will only need to divert one laser.

The laser must exit the emitter and enter the detector horizontally.

You may assume the emitter is on the left (in X coordinate 1) and the detector is on the right (in X coordinate 12).

You may not place mirrors in the same squares as the emitters, detectors, obstacles, or walking path.

Mirrors can be assumed to magically float in the air (they have a complex rigging which will “just work” for any situation).

Mirrors are reflective on both sides, so there are only two orientations (/ or \).

Since the mirrors are at 45 degree angles, the laser direction shifts by 90 degrees.

You have only 8 mirrors (but realize you will need either 0, 4, 6, or 8 to solve any configuration).

Obstacles on the ceiling are rectangular, conforming to the grid.

The human always walks through a rectangle 6 blocks high by 2 blocks wide, with the 2 blocks at the base occupying spaces 5 and 6.

Pressing ‘;’ after an answer should result in another possible answer, achieved through backtracking.

Tips

It is probably a good idea to begin by writing rules which generate the set of blocks which are occupied by obstacles.

Be thinking about:
– the state space – mirrors should only go in blocks which the laser passes through.
– how to know if you’re done – what do you need to do to check if the puzzle is solved?