Answered step by step
Verified Expert Solution
Question
1 Approved Answer
USE SCALA Liar Game This game is a variant of the High-Low game. The computer's task is to find which object the user secretly picked
USE SCALA
Liar Game This game is a variant of the High-Low game. The computer's task is to find which object the user secretly picked in a list. The twist is that the user can lie. However, the number of times the user may lie is bounded. Like the Hilo class, the Liar class generates questions of the form: "Is your object in this list?" ...to which the user replies with "yes" or "no". The class implements the following public methods: question. This is a collection of objects. The implicit question is whether the secret object is in the list of not. yes (). Called by the user to indicate that the secret object is in the list. Note that it is possible for the user to lie and call this method even though the object is not in the list. no (). Called by the user to indicate that the secret object is not in the list. Note that it is possible for the user to lie and call this method even though the object is in the list. solved. This becomes true exactly when the problem has been solved. secret. This is the user's secret object, available after the problem has been solved. It is illegal to call this method before the problem is solved. lies. This is the number of times the user lied. It is only known after the problem has been solved and earlier calls to this method are illegal. progress. This is a floating point number, between 0 and 1. It measures how much progress has been made toward solving the problem. It increases with each user reply and is exactly 1.0 when the problem is solved. The algorithm used by the class is described in Paul Hartung's paper "Tell all the lies you want-Liars never win", given in the appendix. The key idea is that, when a user claims his object is in one half, all the objects in the other half can only be the secret if that claim is a lie. By keeping track of how many times the user would have had to lie for an object to be the secret, some objects can be discarded (because the user would have had to lie too much about them). Eventually, only one object is left, which is the secret. Liar Game This game is a variant of the High-Low game. The computer's task is to find which object the user secretly picked in a list. The twist is that the user can lie. However, the number of times the user may lie is bounded. Like the Hilo class, the Liar class generates questions of the form: "Is your object in this list?" ...to which the user replies with "yes" or "no". The class implements the following public methods: question. This is a collection of objects. The implicit question is whether the secret object is in the list of not. yes (). Called by the user to indicate that the secret object is in the list. Note that it is possible for the user to lie and call this method even though the object is not in the list. no (). Called by the user to indicate that the secret object is not in the list. Note that it is possible for the user to lie and call this method even though the object is in the list. solved. This becomes true exactly when the problem has been solved. secret. This is the user's secret object, available after the problem has been solved. It is illegal to call this method before the problem is solved. lies. This is the number of times the user lied. It is only known after the problem has been solved and earlier calls to this method are illegal. progress. This is a floating point number, between 0 and 1. It measures how much progress has been made toward solving the problem. It increases with each user reply and is exactly 1.0 when the problem is solved. The algorithm used by the class is described in Paul Hartung's paper "Tell all the lies you want-Liars never win", given in the appendix. The key idea is that, when a user claims his object is in one half, all the objects in the other half can only be the secret if that claim is a lie. By keeping track of how many times the user would have had to lie for an object to be the secret, some objects can be discarded (because the user would have had to lie too much about them). Eventually, only one object is left, which is the secret
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started