The AI Contest #2 (Real TV) - The API

in #aicontest7 years ago

Here's the API for AI contest #2

The Real TV show problem

All you need to know about the problem is described on the contest page. You're on an island and cooperate for a common challenge, then vote for elimination of one player. Like on TV.


AiContest

The rules

Available Player AI scripts will be instantiated a total of 11 times, with different strength scores, ranging from 0 to 10. Then, for each phase, Player instances are randomly dispatched into islands of 12 instances, adding only the minimal amount of bots to fill the missing slots. A total of 100 phases are run, which means that each Player will visit one hundred different tropical islands. Lucky AIs!

On each island, every day:

  • First, players vote for elimination
  • Players who voted for themselves are considered traitors, and all traitors leave the island
  • Non-traitor players have to solve a trial together. The sum of their strength must be equal or more than the difficulty, or they collectively fail and the island is disbanded
  • Then the remaining player with the most votes leaves the island. If there's a tie, players are called again for tie break. In case of a second tie, the weakest player leaves. If they are same strength, the leaver is randomly chosen
  • Next day starts unless there is only one player left (that player wins) or no player at all (no winner and no points awarded)
difficulty = 7*n - 3        
   # where n is the number of non-traitor players currently on the island


Island

Points are awarded:

  • 3 points to each player who participate in beating a challenge
  • 100 points for the last man standing on an island (plus up to 36 points awarded for beating the challenges)
  • No extra point awarded if all survivors betray at once
  • 100 points distributed among all traitors if the team fails the challenge

Bots will spawn with strength randomly selected from allowed values (0 to 10). They vote for elimination of the weakest player 80% of the time, for the strongest 20% of the time (including itself). As usual, bots are recreated anew for each phase.

Here are the constants:

    PLAYERS_PER_ISLAND = 12

    PHASES_PER_GAME = 100
    SCORE_FOR_TRIAL = 3
    SCORE_FOR_LASTMAN = 100
    SCORE_FOR_EACH_TRAITOR = 0
    SCORE_FOR_ALL_TRAITORS = 100

    INSTANCES_STRENGTH = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    INSTANCES_PER_PLAYER = len(INSTANCES_STRENGTH)
    
    DIFFICULTY_A = 7           # round difficulty is A*n + B
    DIFFICULTY_B = -3


Island

Implement this

class Player:
    
    def getSteemUser(self):                              # return your steem name
        return "@gbd"

    def voteForElimination(self, context):               # override this
        # return either a Player or a PlayerContext
        # invalid entries and voting for self will be interpreted betraying

    def voteForTie(self, context):                       # override this
        # return either a Player or a PlayerContext
        # It is too late for betrayal, invalid entries will be ignored

And here's the Context object you'll get as argument

class PlayerContext:
    # self.id               a unique string identifier for this instance
    # self.name             classname this player is implementing
    # self.previousMoves    [(PlayerContext, PlayerContext)] 
    #                          votes cast by this instance: (firstVote, TieBreak)
    # self.strength         strength of that instance
    # self.score            score of that instance (updated at the beginning of day)

class GameContext:
    # self.totalBots        total number of bots in the whole arena
    # self.totalHumans      total number of non-bot instances in the whole arena
    # self.phaseIndex       index of the phase 
    #                          (ie. number of islands you've been in before this one)

class Context:
    # self.islandIndex          probably not useful for you
    # self.game                 GameContext object
    # self.activePlayers        {id: PlayerContext}, players still on the island 
    #                               at the beginning of the day
    # self.betrayers            {id: PlayerContext}, those who will share the 
    #                               bounty if you lose
    # self.eliminatedPlayers    {id: PlayerContext}, those who lost
    # self.currentTies          {id: PlayerContext}, only available in case of a tie

And here's your first opponent

from Game.Const import Const
from Game.Player import Player
        
class LikesThemStrong (Player):     # Always votes for the weakest (including itself)
    
    def getSteemUser(self):
        return ""

    def voteForElimination(self, context):
        return min(context.activePlayers.values(), key=lambda p: p.strength)

    def voteForTie(self, context):
        return min(context.currentTies.values(), key=lambda p: p.strength)

And here you go!

You have until friday february 23 to submit AI scripts to the contest. Up to 5 AIs and one prize per account. You have two ways to submit an AI script, in order of preference:

  • Directly file a pull request on the project github
  • Post a comment with a link to the code hosted on a gist or somewhere else online

And don't forget to leave a reply with a link and a short explanation of how your AI works

Read my previous posts

Vote the Ai Contest posts to add money to the prize pool !

(many thanks to the authors I link to, including anonymous Wikipedians)
*Source of images: Pixabay, Creative Commons CC0

Sort:  

To bring some fuel to the game: Follower will designate a champion and vote to champion's advantage

Se here's mine:

  1. Clueless - has no idea what he's doing
  2. ImNotPlayingWithYouGuys - is sure the team will fail

Overall I'm sure they'll work great in the same team :)

Looks like the previous experiences left you with a bad impression, am I right? You know, bad guys don't always win.
Also, it took me some time to tune the constants, maybe that means trivial bots will leave some room for grown ups this time...

Anyway: great start to populate the Arena

Just choosing optimal strategy ;) Besides, it's just first iteration, hopefully I'll find time to make smarter bots as well before the deadline.

Your leaver ranks second or first on contrib. I will fix that.

hey, thanks! I think I tried it with Python 2, where .values() returns list.

Right. I should have mentioned that.

It's a shame so few people play this games. Maybe if you setup another challenge we can get some "marketing" support from groups like @minnowsupport?

Thanks for the advice, but I'm considering leaving this idea behind: it takes quite some time to setup an arena... I'll keep you informed

So is this contest (#2) is cancelled?

If I find some a bit of free time, I will try to set up something similar. I will make sure to notify you.

You are most welcome to take #aicontest to the skies! I will definitely compete (Might even contribute if you don't want to code the arena alone)

Coin Marketplace

STEEM 0.24
TRX 0.21
JST 0.036
BTC 97319.92
ETH 3332.05
USDT 1.00
SBD 3.33