Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in rust, do extra crdit too. The purpose of this lab is to give students experience implementing a finite state machine in Rust. Finite state

in rust, do extra crdit too.

The purpose of this lab is to give students experience implementing a finite state machine in Rust. Finite state machines are used in a variety of applications in programs. They are especially useful in communications protocols, where each communicating side is expecting a set of symbols in a specific order. This case requires the implementation of two interacting state machines. Another good example of the use of a state machine in game development where a character can be in one of a limited number of states at one time and be limited from moving between certain states. For example, a character who is sitting cannot start running without first standing.

For this exercise the student must first define the transition diagram and draw a finite state machine for a game character with at least the following states: laying, sitting, standing, walking, running, jumping, falling, dead, where dead is a final state. The inputs are the arrow keys, or the characters {h,j,k,l} which represent {left, down, up, right}. All states must be reachable using the input language.

Explain your choices of transitions.

Implement your finite state machine in Rust, and include a main program which allows the user to input a string in the language of the state machine. The program should with each transition display a representation of the character in the state. If the string is accepted, complete a final display and exit.

(hint: infinite loop -> read input, perform action(s), display)

Design a second state machine which maintains the direction the character if facing. Include the design in your report.

Implement the second state machine into your code. Include with the display of the representation of the character an indication of the direction of the character

(Extra credit) Extend your program to track the location of your character. Assume the character starts as some location (0,0). Track the location based on orientation, momentum associated with a state (note: if you can jump while walking, or running, you may need to adjust your original design to account for this), and previous location. Include with your representation of your characters state and orientation, a representation of their location.

(Extra credit) Add a character state crash which is entered if a character enters a location already occupied by an object, or obstacle. The location of the character upon crash should be just prior to the crash point.

(Extra credit) Make your representations graphical.

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

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

5. Are my sources compelling?

Answered: 1 week ago

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago