In this challenge, your bot has landed on an island with the stereotypical knights and knaves. Knights always tell the truth, and knaves always lie. The objective is to find the correct 32 digit hexadecimal string before anyone else, by asking knights and knaves and trying to trick other bots into giving you answers or accepting fake ones.
Knights and Knaves
Every bot will be given an array of 48 people, who are the same for all bots. The bots do not know whether any one person is a knight or knave. Each person is assigned two characters of the 32 digit string. Exactly half of all people are knights, and half are knaves: a knight will always give you the correct characters and their indexes within the result string; a knave, however, will give an incorrect character each time along with the correct index. These incorrect characters will always be the same for any one bot, so a knave is indistinguishable from a knight without outside help or some deductive skills. Every character of the string is known by exactly three people, and no person has the same character twice.
In order to find knaves, bots can interact with one another. One bot will request help from another for a specific character of the string, and the second bot can return any character. It is up to the first bot to decide if this character is real or fake, likely by asking for more help and comparing the results.
In order to prevent help-vampire bots, no bot can have more outgoing help requests than twice the number of incoming requests it has answered, plus four.
Every bot is assigned a random Unique ID (UID) number each round. This number is used to communicate with other bots, and ranges from 0 to one less than the number of bots. It can request help from another bot using the function
sendRequest(uid, index), and read from responses with
readResponses(), which is formatted as an array/list of objects containing
Additionally, a bot can view the requests sent to it using
viewRequests(). Each request is an object containing two properties:
uid. To reply to a request, use the function
replyRequest(uid, index, char). There must be a request in
viewRequests() from that UID asking about the index specified in order for this to work, and
char must be a hexadecimal character.
replyRequest will output false if something is invalid (UID for
sendRequest, and no request to reply to for
replyRequest), and true otherwise.
The bot will receive three arguments as input to its function. The first is an array/list of each knight/knave, with each one represented as an array/list of two objects (
char are their properties).
The second argument is the number of bots. UIDs range from zero to one less than this number. Finally, the third argument is an empty object, which the bot can use to store any information it needs.
- A bot may not read or modify any variables outside of its function arguments and local/function scoped variables it creates
- A bot may not execute any functions declared outside its scope, aside from the four interaction functions (
- Your bot's guess is submitted by return value. If it does not know, it can return null/false/undefined, or a random guess. Each bot has a win count. If multiple bots guess correctly in the same turn, this increments by
- Standard Loopholes are prohibited, per the usual
- Controller, Chatroom
- By the way, this is not a dupe. The other questions based around knights and knaves have a very different objective, they are just similar in their topic