I'm thinking I want to make a KOTH challenge that has bots play the classic game of Mafia. Bots will be placed in groups of seven, roles randomly assigned, and they play the game!
Explanation of Game Mechanics
The game proceeds in multiple turns, each turn consisting of Night followed by Day. At night, each person completes his role as will be described below. During the daytime, players (in real life) discuss the events of the night (communicated by God, a separate person who does not participate in the game besides prompting people to their roles.) Just before night, the players have the option of voting to lynch another player, the objective being to lynch a mafia member to help the town win. Choosing not to lynch is always an option if you think it is too risky to lynch someone who might be innocent.
In real life, God would tell everyone to sleep, then ask mafia to wake up and silently agree on who to kill, tell them to sleep, and continue with the other roles in a similar manner. Town wins if all the mafia are dead; mafia wins if they at least outnumber the town.
There are four roles in this game, but I have played many games with more than seven people with more ridiculous roles that are very fun to play. Each player bot is assigned an ID number indicating his role.
Mafia - There will be 2 mafia in this game. The two mafia will come to a consensus on who to kill. If one is dead the other decides on his own. The two mafia can not choose one of them to be killed. Mafia has a role of either 1 or 2, which are identical in function.
Inspector - There will be 1 in this game. At night he visits a person, and receives a report on that person's innocence. Both Mafia members will appear as guilty and the rest will appear as innocent. He can not inspect himself nor dead people. His number is 3.
Doctor - There will be 1 in this game. At night he visits a person, and that person will not die that night. Doctor can not save himself nor dead people. His number is 4.
Townsperson - Does nothing at night. Numbers 5, 6, 7.
You will write a Java player class who will have (at least) three important methods:
vote. All of these three methods will return the player to 'act' on (of course, depending on your role), given an ArrayList of information that the other players have claimed in public.
I am not very clear on how to run a KOTH challenge and what github is supposed to do and how to use it so it would be very helpful if someone could point me in the right direction. As of now I'm still working out the exact details of a Java class to run the game, as well as making a generic Player class that the answers will have to extend and use methods from.
Right now, I have a generic Player class that each answer will extend, and each Player object has two Identity objects: a public, claimed Identity and a private Identity. The private Identity will hold the players actual role (kept secret, of course), as well as a doctor arraylist of Integers and a cop arraylist of Strings. If the player happens to be a cop, the controller program will add an entry to the private cop arraylist which will serve as his way of receiving a verdict. I'll make a method called verdict() which returns the last element to make the programming easier. An example string is "4G" which means that player 4 is guilty. This player 4 may be mafia 1; player numbers are just given for discussion purposes and to identify a player based on his claims and is independent on role. Doctor is the same except integers because you only need to store who was saved that night.
The public, claimed Identity works in much the same way except that the controller will never modify it, only the player can. An identity object contains a role (an integer representing the role number), an ArrayList of strings called 'visits' (to be used if you are a cop or doctor, to store a list of people visited and any outcomes), and an ArrayList of suspicions to indicate that your bot suspects or is guessing that another player has a given role. It will also have a lynch value which can be changed during the day, and this is where a player decides on who to lynch (if at all). Finally, it will have a boolean for if the player is dead or alive. You had better not mess with this. The idea of having two is that you can claim whatever you want; so a Mafia can claim to be Cop or a townsperson and the doctor can claim to be a cop.
Initially your public claim ID is 0, indicating that you have not claimed. The program will give you your private ID, which will contain your actual role and and is not necessarily meant to be made public just yet. The program controller will only modify your private ID object, and only then if your are Doctor or Cop. It will append to the visits ArrayList in the private identity object the result of the visit; the doctor will have access to everyone he has visited, and the cop will have access to everyone he has inspected and their alignment.
The controller, each night, will ask Mafia 1 for his choice then Mafia 2 for his choice, then repeat, say, 25 times. If at any point the two mafia agree, then it stops because the Mafia have just made their choice. The number of times attempted thus far will be given to the Mafia's night method, so the code will look like
M1.night(<other players info>, 1) then
M1.night(<other players info>, 2), etc. is that arraylist of public identities previously mentioned. If no consensus, no kill. Similarly prompt cop and doctor once for their choice on who to visit.
In the day time, every player's lynch value will be 0, indicating that they do not vote yet; each player will be given 25 chances to act. An action can consist of adding to the list of suspected values, claiming a role, changing a role, changing the list of suspected values, voting to lynch someone, changing a lynch vote, etc., or more. Some actions are smarter than others, and your goal is to have a good action strategy. Upon each call of a players act() method, he will be given an arraylist of everyone else's public identity objects, as well as how many times before he has been prompted. This gives him access to what other players claim to be, who other players claim to have visited and outcomes, who they suspect as who, and who others are voting to lynch. If at any point there is a majority (more than half but not exactly half) of people wanting to lynch a person (No lynch, indicated by the value -1, counts too), then day time ends, that person is lynched and his role revealed. If majority voted -1 (no lynch) then nobody dies and day time ends.
Again, please guide me on how I should design my classes, controller, and what files I should put up and how people are going to test their bot at home. I would be glad to show you what I have so far, which includes a controller program and a dummy player class.