Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will make a model of Smaugs world in which each visitor, sheep, and cow is a process, and Smaug is also a process. These

You will make a model of Smaugs world in which each visitor, sheep, and cow is a process, and Smaug is also a process. These processes interact in the same way as the characters in Smaugs world interact. Each sheep, cow, hunter, or thief process interacts with Smaug only once, after interacting the process terminates. As a first step in creating this simulation you will build state diagrams. describing each kind of process (Smaug, sheep, cow, treasure hunter, thief).

SMAUGS WORLD

The fierce dragon Smaug is guarding his hoard of treasure. Smaug is a large and perpetually hungry dragon with a very sensitive nose. Smaug likes to sleep on his bed of treasure. He only wakes up to eat, to battle any foolhardy treasure hunter that decides to try and kill him to win all of his treasure, or to play with any thief that tries to sneak in and steal some of his treasure.

Smaug is a magical dragon who lives in a cave. The only entrance to Smaugs cave is in a secluded valley. When a sheep or a cow wanders into that secluded valley it is enchanted and cannot leave the valley. When anyone wishes to visit Smaugs cave they have to travel along a magical path that seems. to go on forever in order to find the valley.

If he does not smell a snack or a visitor to his valley he goes to sleep.When Smaug has no visitors he eats and sleeps. Smaug is particularly fond of sheep as a tasty snack. His nose is so sensitive he only wakes up to eat if he smells three sheep and two cows in the valley. While he is eating those five beasts, he ignores any additional beast that wanders into the valley and becomes enchanted. When he is done eating the five beasts he takes a short nap (he does not go to sleep, just naps). When he wakes he takes one deep breath to see if he can smell another snack or a visitor to his valley. If he smells another snack of three sheep and two cows he will eat it before he takes another short nap. After the short nap he will take another deep breath. He will continue to eat snacks and take naps as long as there are snacks available. If he does not smell a snack or a visitor to his valley he goes to sleep.

This quiet existence is occasionally interrupted by the arrival of visitors. Visitors to Smaugs cave are trying to obtain some of Smaugs treasure. Smaugs treasure is more important to Smaug that any tasty snack. Smaugs enchanted path will cause visitors to walk in circles, never finding his cave, until Smaug is ready to interact with them. Therefore, Smaug does not worry about interrupting his snacks to interact with visitors and protect his treasure. If Smaug is awake (eating a snack) or napping Smaug will detect any new visitors on the path when he takes a deep breath (after finishing his nap after his snack). If Smaug is asleep (not napping) his nose will wake him up when any visitor is walking along the magical path.

If there no snacks and there are visitors Smaug will interact with the next visitor.

Sometimes Smaug wakes up and smells one or more visitors walking along the path AND a snack is waiting to be eaten. If he smells a snack, he will eat the snack first. When he wakes up from his nap after eating his last snack he will then eat his interact with the visitor. After Smaug finishes dealing with all visitors and snacks he is exhausted and goes to sleep.

Smaug has two types of visitors, treasure hunters who plan to battle Smaug and kill him to obtain all his treasure and thieves who plan to sneak in and steal some of his treasure. When visitors arrive outside the valley that contains the entrance to Smaugs cave they must find the single magically concealed path into the valley. The spell on the path will cause then to wander through the valley not reaching Smaugs cave until Smaug is ready to meet them (after he smells them). When Smaug is ready, the spell allows the next visitor to see the entrance to the cave and enter the cave. When a treasure hunter enters Smaugs cave, Smaug fights the treasure hunter. Smaug is never killed by a treasure hunter but some fight well enough that Smaug gets tired and allows them to leave with a reward of 10 gems. for providing him with exercise. If Smaug defeats a treasure hunter he will let the treasure hunter leave (instead of eating him) if the treasure hunter bribes him with 5 jewels. Since treasure hunters do not like to be eaten they always take five jewels with them just in case they are defeated (most are). When a thief enters Smaugs cave Smaug plays with the thief. If the thief wins the game he is sent home with 8 gems, if the thief loses he must pay 20 gems. to leave the cave. No thief is stupid enough to come without 20 gems. in his pocket. Smaug enjoys playing games with thieves, but finds fighting treasure hunters to be a boring task. Therefore, Smaug will always choose to let a thief come to play before he lets a treasure hunter come to fight. After playing with a thief or fighting a treasure hunter Smaug goes to sleep.

Design your model using state diagrams. Develop one state diagram describing Smaug, one describing a sheep, one describing a cow, one describing a thief and one describing a treasure hunter. State diagrams. for treasure hunter and for thief must include an initial state in which the treasure hunter or thief has not yet reached the path into the valley (is travelling to the path). State diagrams. for sheep and cows should include a state when the sheep and cows are grazing, before they wander too close to the valley containing the dragons cave and are enchanted. Be sure to include the state diagrams. with your submitted solution.

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

Organizing Your Speech Points

Answered: 1 week ago