WumpusWars King of the Hill
This is probably going to stay in the sandbox for a few weeks, until I get the time to write the actual scoring code up... Yep, I'm both lazy and busy :P I'm not very good at coding challenges but I'm good at thinking up creative ideas, so this time my idea is to try reviving the genre of KotH, as the last one on this site (Crazyhouse Chess) has been very unsuccessful (0 submissions for pretty obvious reasons) and the others are all many months old...
Inspired by Hunt the Wumpus, an early command line game. It is somewhat popular among esolang communities as a programming challenge, especially for languages like Befunge. However, the original, singleplayer version is boring, so I wanna upgrade it. Hence I created WumpusWars, a better version of it!
Story: You are a brave hunter in a dark cave, trying to kill the Wumpus, a mysterious monster. You start with 5 arrows that can kill the Wumpus if you shoot the arrow into the same room as the Wumpus. The cave consists of large rooms and small passageways in between. It can be represented, hence, with a graph, so that the rooms are nodes/vertices and the passageways are edges. There are a total of 50 vertices in the graph, each of them having a degree of at least 3, and the graph is guaranteed to be connected. Rooms are numbered from 0 to 49. You are spawned in a random room.
The place is so dark that you cannot see anything, but you can feel, smell, and hear. Hence you have access to the functions listed in the source code below. Lemme explain what the functions are associated with in more detail:
- Bats: There are 5 rooms in total that contain bats. Entering one of them will cause you to be carried away to a random empty room ("empty room" defined as a room without bats, pits, players, or the wumpus, but there can be corpses in the room).
- Pits: There are 5 rooms in total that contain a pit. Entering one of them will cause you to BOOM! CLASH! CRACK!
- Wumpus: It remains in its own room unless either an arrow is shot by anyone anywhere, or the game is in deathmatch mode (see gamemode list for explanation). If it enters your room then... You know what. When an arrow is shot or in deathmatch mode it moves randomly to adjacent rooms. Bats and pits do not affect it.
- Players: Other players. Note that you cannot shoot a player in the same room as you because the arrow is magically explosive and shooting in the same room as your own will cause you to BOOM! CLASH! CRACK!
- Corpse: When a player is killed by anything except a pit they become a corpse, and corpses don't move (obviously). You can collect arrows from the corpses, and if the corpse has already been arrow-collected there will be 0 arrows on it.
Also, every 10 rounds an arrow will spawn in an empty room. Entering that room will cause your number of arrows to be incremented by 1. Multiple arrows can spawn in the same room which gives you several at once, but that's pretty rare.
You need to write a player program in Python and submit it as an answer to the post. Use the "PlayerName" class template. You will have to define with the
participate function which gamemodes are you participating in (the input to the function will be one of the abbreviation strings):
- Singleplayer (abbrev: "SP"). Precisely what the name says. Your score is the percentage of games in which you win (by shooting the Wumpus with an arrow). You lose if you die. After 100 rounds the game enters deathmatch mode, where the Wumpus keeps moving randomly every round regardless of whether an arrow is shot.
- Player vs Environment (abbrev: "PVE"). Same as singleplayer except that there are multiple players. The winner is the one who kills the Wumpus (if multiple players shoot it in the same round they split the point equally). If everyone dies then no one wins. Arrows have no effect on players. Deathmatch starts after 20*n rounds, where n is the number of players.
- Player vs Player (abbrev: "PVP"). Kinda PVE inverted. The Wumpus is now immortal –– but the players are not! If you get shot by other players or get eaten by the Wumpus you die and lose. The last one standing is the winner. If multiple people die last in the same round they split the point equally. It's deathmatch from start to finish.
- Among Us (abbrev: "IP" for Imposter and "CM" for Crewmate). The Wumpus is immortal. Some players become impostors. Others are crewmates. Impostors get 3 arrows at the beginning (number might change according to # of players). Crewmates start with no arrows (but can still pick randomly spawned arrows up). Crewmates are immune from arrows fired by other crewmates. If all impostors die then all crewmates (dead or alive) win a point. If all crewmates die then all impostors (dead or alive) win a point. No deathmatch.
If you have any ideas please lemme know!
def legal_moves(player) -> list:
# Returns an ordered list of adjacent rooms
# Example: [5, 8, 10]
def bats(player) -> bool:
# True if bats are in adjacent rooms, false otherwise
def pits(player) -> bool:
# True if pits are in adjacent rooms, false otherwise
def wumpus(player) -> bool:
# True if wumpus is in adjacent rooms, false otherwise
def others(player) -> bool:
# True if the shortest path from you to the nearest player passes at most 2 edges.
def arrows(player) -> int:
# Returns the number of arrows player has
def corpse(player) -> list:
# Returns a list of integers
# The length of the list is the number of corpses in the player's room
# Elements in the list are the number of arrows on each corpse
# Other functions hidden
class PlayerName: # Change the name!
def __init__(mode:str, room:int, env):
# Gamemode. Such as 'SP'.
self.mode = mode
# Current room number.
self.room = room
self.env = env
def participate() -> bool:
# Add code here...
# Return True if self.mode is a supported gamemode
# False if not
def action() -> tuple:
legal_moves = self.env.legal_moves(self)
bats = self.env.bats(self)
pits = self.env.pits(self)
wumpus = self.env.wumpus(self)
others = self.env.others(self)
arrows = self.env.arrows(self)
corpse = self.env.corpse(self)
# No methods or variables from Environment class allowed below here!
# Suggested to first check which gamemode and use strats accordingly.
# Add code here...
# Return a tuple of type (bool, int)
# The bool is True for shooting, False for moving
# The int is the cave number to shoot or move to
# An illegal move signifies doing nothing