LISP FUNCTIONS This is MinorPP #2. Note: You will need to complete the material in the LISP section to complete this assignment. This assignment is designed to give you a small scale preview of...


LISP FUNCTIONS






This is MinorPP #2.


Note: You will need to complete the material in the LISP section to complete this assignment.


This assignment is designed to give you a small scale preview of what's needed for HW05C.


Imagine you are writing the AI for a simple game that will require an adversarial search.


The state of the game can be represented using a list of 3 elements, such as (B B B). The list representing the game state can contain any combination of 3 values: A, B, or C. It will always have exactly 3 items. (Let's call it the "state list").


With that in mind, write the following LISP functions:




TERMINAL-TEST - this function takes a state list as it's only argument. If the list contains no B's, it is considered a terminal state and TERMINAL-TEST should return t, nil otherwise.




UTILITY - this function accepts a state list as it's only argument and evaluates the state list. If the list contains all A's, then the function returns 1. If the list contains all C's, then the function returns -1. Any other combination of A's, B's, or C's returns 0.




ACTIONS - this function accepts a state list as it's only argument and returns a list of possible actions according to the following table:

























State




Action



(B * *)



A1



(* B *)



A2



( * * B)



A3






Where :

* represents A, B, or C

State is the state list passed to the function

Action is the possible action returned given that state



So, if the state list passed to the function was (B C B), then the function should return (A1 A3).




RESULT - this function accepts a state list and an action as it's only arguments. The function then returns a state list according to the following table:





























State




Action




Returned



(B * *)



A1



(A * *)



(* B *)



A2



(* A *)



(* * B)



A3



(* * A)



Where:



State and Action are both passed as arguments and

Returned is the state list that is returned.

The * represents A, B, or C.



For example, if (B C B) and A3 were both passed as arguments, then the state list that gets returned would be (B C A).




Demonstrate your functions work by calling each one in turn, passing each of them appropriate arguments, and then printing to the screen the values they returned.


You can work on this assignment in a group of up to three people. If you do, each student must submit a copy of the assignment and you must include in comments at the top of the file the names of all three people who worked on it.





Hints:


You can complete this assignment using any of the tools found on the tutorialspoint website, even stuff not covered in the videos.


Feel free to use any secondary sources. This assignment assumes (requires) you to do some research on your own.


Write the functions anyway you like, so long as they work.





Submission Instructions:


Submit your program in a single plain-text source file.


Do not submit screenshots.


Name your file hw05b.lisp












May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here