37
\$\begingroup\$

It's my 17th birthday and you're invited to my party!

And as always at parties, there will be cake.

One cake...

And you need as much of it as possible.

As this is a fair party, each of us will say how much of my cake we want and the person who said the smallest amount will get it. Then everyone else gets to repeat the process until the cake is gone.

Challenge

  • Given the input through command line arguments in the form of total-degrees degrees-left total-people people-left, output to standard output integer-bid-in-degrees.
  • If your bid was the lowest, you receive that amount of cake and are out for the round.
  • If your bid wasn't lowest, your bot gets to bid on the remaining cake.
  • In the case that the lowest bids are the same, the person removed will be chosen at random.
  • At the end of a round, once all the cake is gone or there is nobody left to bid on it, the person with the most cake wins!
  • In the case at the end of a round and two people have the same sized biggest slice, the winner is chosen at random from the drawing entries.

Gameplay

  • There will be 17 rounds, the overall winner will be the entry with the most wins overall.
  • In the case of a draw, rounds will be played until there is a clear winner.
  • Each day, I will update the current scores so that people can upgrade their entry.

Submission

You should write your entry as

Bot Name, Language

Insert
Code
Here

Explanation/Random stuff here

If your entry isn't formatted in this way, the controller will NOT be able to run your entry. If I find this has happened to your entry, I will either notify you in a comment, and/or edit the answer into the correct format.

Your entry and file storage

  • Your bot may store files in the ./data/ directory and nowhere else.
    • Not required but please store your files as botname*
    • You may not write files in this format if botname is not your entries name.
    • This means you are allowed to overwrite other files you find that don't appear in this format. You shouldn't do this deliberately, please be sporting.
    • Your bot must not assume that the files it requires are present but it can assume ./data/ exists.
    • This is because I occasionally wipe the ./data directory, I will do this when the rounds actually start. (But not between them)
  • Your bot may not delete files at all
  • Your bot is only allowed to read files in the ./data/ directory
    • This means you may look at other entries files

Results:

Meek won the contest! Well done @Cabbie407

And now for some random stats:

A list of positions each bot came in: (Well done to any bot appearing in this list, you came in the top 5 at least once!)

  1. Meek, Meek, Eidetic, Eidetic, Meek, Eidetic, Eidetic, Meek, Meek, Meek, Saucy, Meek, Givemethecake, Givemethecake, Givemethecake, Meek, Eidetic

  2. Eidetic, Eidetic, Meek, AlCakeSurfer, Eidetic, AlCakeSurfer, Meek, MyFairPlusAThird, Eidetic, Eidetic, Eidetic, Eidetic, MyFairPlusAThird, MyFairPlusAThird, Meek, MyFairPlusAThird, AlCakeSurfer

  3. Reallythecake, AlCakeSurfer, AlCakeSurfer, Meek, AlCakeSurfer, Meek, AlCakeSurfer, AlCakeSurfer, Reallythecake, AlCakeSurfer, Meek, MyFairPlusAThird, Eidetic, Eidetic, Eidetic, Eidetic, Reallythecake

  4. AlCakeSurfer, Reallythecake, MyFairPlusAThird, MyFairPlusAThird, MyFairPlusAThird, MyFairPlusAThird, MyFairPlusAThird, Eidetic, AlCakeSurfer, MyFairPlusAThird, MyFairPlusAThird, Relinquisher, Relinquisher, bill, bill, Relinquisher, MyFairPlusAThird

  5. bill, MyFairPlusAThird, bill, bill, bill, bill, Relinquisher, Relinquisher, MyFairPlusAThird, Relinquisher, bill, Reallythecake, bill, ALittleOffTheTop, ALittleOffTheTop, bill, bill

The full log file for the cometition whilst running can be found here. Sorry about the format change partway through.

I will not be running the contest again, if you want to post more entries, you're welcome to do so, the controller can be found on my github repo for this contest.

\$\endgroup\$
  • 10
    \$\begingroup\$ I request a ring cut around the outside perimeter. Technically 0 degrees (the cake still has 360 degrees when I'm done, after all) and I get all the side icing. \$\endgroup\$ – Random832 Oct 5 '15 at 17:49
  • 10
    \$\begingroup\$ Happy Birthday :) \$\endgroup\$ – TheNumberOne Oct 5 '15 at 19:33
  • 2
    \$\begingroup\$ Results for one round if anyone's interested, {u'StatelyImitator': 719, u'Dieter': 4, u'Reallythecake': 0, u'Greedy': 0, u'Meek': 2, u'FlamingChainsaw': 0, u'Slim': 0, u'CharityBot': 0, u'Gentleman': 297, u'ALittleOffTheTop': 256, u'EatThe\u03c0': 0, u'Pig': 0, u'CakeEater': 330, u'BobBarker': 0, u'FloorBot': 5, u'Fatbot5000': 296, u'Moses': 360, u'Magician': 720, u'Hungry': 257, u'Imitator': 354} [u'Magician']. If your bot has a score of 0, it's doing something wrong. \$\endgroup\$ – Blue Oct 5 '15 at 20:11
  • 3
    \$\begingroup\$ Please format the leaderboard in a more reader-friendly manner. \$\endgroup\$ – SuperJedi224 Oct 7 '15 at 1:24
  • 2
    \$\begingroup\$ @muddyfish gradians? Much more like cakeians, right? \$\endgroup\$ – Jan Oct 7 '15 at 23:04

41 Answers 41

1
\$\begingroup\$

FloorBot, Python

from sys import argv
from math import floor
degrees_left = int(argv[1])
print(floor(degrees_left*0.65))

Bids 65% of the remaining cake in hopes of beating both the greedy bots and the "Price is Right" bots.

\$\endgroup\$
  • \$\begingroup\$ Cue next bot bidding 84%... \$\endgroup\$ – Geobits Oct 5 '15 at 15:05
  • 6
    \$\begingroup\$ @Geobits I have another idea for a bot that scrapes this post and bids 1% less than any other percentage based bot. :P \$\endgroup\$ – Morgan Thrapp Oct 5 '15 at 15:09
  • \$\begingroup\$ Again, argv[1] needs to be converted to an int \$\endgroup\$ – Blue Oct 5 '15 at 19:36
  • \$\begingroup\$ @muddyfish Oops, duh. Fixed. \$\endgroup\$ – Morgan Thrapp Oct 5 '15 at 19:37
  • \$\begingroup\$ @MorganThrapp Hmm. A bot challenge based on reading the source code of the other bots would be fun, not that I would participate. \$\endgroup\$ – mbomb007 Oct 5 '15 at 21:37
1
\$\begingroup\$

this_bot_wants_it_all_possible, PHP

  echo 359;

This bot wants it all possible.

\$\endgroup\$
  • 1
    \$\begingroup\$ At the moment, cakes have 3600 degrees \$\endgroup\$ – Blue Oct 6 '15 at 10:33
  • \$\begingroup\$ Also, your bot doesn't have a correct header (and I don't have a PHP environment at the moment) \$\endgroup\$ – Blue Oct 6 '15 at 16:55
1
\$\begingroup\$

FairShare, Python 2

import sys

def FairShare(TotalDegrees, DegreesLeft, TotalPeople, PeopleLeft):

    FairShare = TotalDegrees / TotalPeople
    FairShareNow = DegreesLeft / PeopleLeft

    if PeopleLeft == 1:
        return DegreesLeft

    elif FairShare > FairShareNow:
        return FairShare

    elif FairShare == FairShareNow:
        return FairShare

    elif FairShare < FairShareNow:
        return FairShareNow

print FairShare(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4]))

Here I come with my tiny Python skills! :D max() and min() are things.

Pretty simple. If my fair share at the beginning is more than my fair share now, return my fair share now. If my fair share at the beginning is equal to to my fair share now, return my fair share at the beginning minus one. If my fair share at the beginning is less than my fair share now, return my fair share now.

Edited so that if FairShare is the last in the round, takes all the cake.

\$\endgroup\$
  • 1
    \$\begingroup\$ SYS argvs need to be mapped to ints \$\endgroup\$ – Blue Oct 6 '15 at 10:34
  • \$\begingroup\$ @muddyfish Fixed. Whoops. \$\endgroup\$ – The_Basset_Hound Oct 6 '15 at 10:52
1
\$\begingroup\$

DruuuuuunkBot, Python

import sys,random
tD,dL,pN,pL=map(int,sys.argv[1:])
a=dL/(pL+1)
if a < 0:
 a = dL
print(a)

Tries to be educated in his guesses, but he's a tad drunk, resulting in wide errors. Said bot is now less drunk. He doesn't like people, so he just wants to get out of here pronto! But now he want a little more cake.

\$\endgroup\$
  • \$\begingroup\$ Last line should be print(tD/(random.random()) \$\endgroup\$ – Blue Oct 6 '15 at 16:39
1
\$\begingroup\$

Try to Win, C++

#include<iostream>
#include<stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
    int td, dl, tp, pl;
    td = atoi(argv[1]);
    dl = atoi(argv[2]);
    tp = atoi(argv[3]);
    pl = atoi(argv[4]);
    if (pl == 1)
    {
        cout << dl;
        return 0;
    }
    else if(pl < 10 )
    {
        int sn = dl / pl;
        int sb = td/ pl;
        int si = td / tp;

        if (sn > si + 1)
        {
            cout << sn;
            return 0;
        }
        if (sn = si + 1)
        {
            cout << sn;
            return 0;
        }
        if (sn == si)
        {
            cout << sn;
            return 0;
        }
        if (sn < si)
        {
            cout << si;
            return 0;
        }

    }
    else
    {
          cout<<td/13;
    }
    return 0;
}
\$\endgroup\$
  • \$\begingroup\$ Doesn't return anything, I'm passing args via argv. \$\endgroup\$ – Blue Oct 6 '15 at 16:23
  • \$\begingroup\$ @muddyfish i m very sorry. I forgot to take input \$\endgroup\$ – Kishan Kumar Oct 6 '15 at 17:18
0
\$\begingroup\$

Fatbot 5000, Python 2

import random, math, sys

total_degrees, degrees_left, total_people, people_left = map(int, sys.argv[1:])

def get_equal_share(degrees_left, people):
    return int(math.ceil(degrees_left/float(people)))

def get_greedy(degrees_left, people):
    min_bid = get_equal_share(degrees_left,people)+1
    max_bid = min_bid*2
    bid = random.randrange(min_bid, max_bid)
    return min(bid, degrees_left)

print get_greedy(degrees_left, people_left)

My example bot. Will always bid more than it's fair share of the cake but isn't so hungry it wants much more than 2 times it's fair share.

\$\endgroup\$
0
\$\begingroup\$

Moses, Java

public class Moses {
    public static void main(String[] args) {
        double[] arguments = new double[4];
        for (int i = 0; i < 4; i++) {
            arguments[i] = Double.parseDouble(args[i]);
        }
        if (arguments[3] == 1) {
            System.out.println((int)arguments[3]);
        } else {
            int myCake = (int) Math.ceil(arguments[1]/2);
            System.out.println(myCake);
        }
    }
}

Wants half of the pie. If it gets its share, the following players can at maximum get the same amount.

\$\endgroup\$
0
\$\begingroup\$

FairPlusPlus, Java

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;
import static java.lang.Math.*;

/**
 * Created 10/5/15
 *
 * @author TheNumberOne
 */
public class FairPlusPlus {

    private static int previousCake;
    private static int highestVoteWon;

    static {
        File file = new File("data/FairPlusPlus.txt");
        Scanner in = null;
        try {
            in = new Scanner(file);
            previousCake = in.nextInt();
            highestVoteWon = in.nextInt();
        } catch (Exception ignored) {
        }
    }

    public static void main(String[] arguments) throws FileNotFoundException {
        double[] args = new double[4];
        for (int i = 0; i < 4; i++) {
            args[i] = Double.parseDouble(arguments[i]);
        }
        if (args[2] == args[3]){
            highestVoteWon = -1;
        } else {
            highestVoteWon = (int) max(highestVoteWon, args[1] - previousCake);
        }

        System.out.println((int) min(max(ceil(args[1]/args[3]+(args[3]-1)/2), highestVoteWon + 1), args[1]));

        PrintStream out = new PrintStream("data/FairPlusPlus.txt");
        out.println((int) args[1]);
        out.println(highestVoteWon);

    }

}

He's mostly fair ... unless someone gets the better of him.

Assumes ./data/ directory exists.

\$\endgroup\$
  • \$\begingroup\$ Can you rename the not to FairPlusPlus? (The name not the main class) \$\endgroup\$ – Blue Oct 5 '15 at 23:29
  • \$\begingroup\$ @muddyfish Done \$\endgroup\$ – TheNumberOne Oct 5 '15 at 23:45
  • \$\begingroup\$ Also don't assume FairPlusPlus.txt exists :) \$\endgroup\$ – Blue Oct 5 '15 at 23:47
  • \$\begingroup\$ Now getting inputmismatch errors \$\endgroup\$ – Blue Oct 5 '15 at 23:48
  • 1
    \$\begingroup\$ @muddyfish Fixed. \$\endgroup\$ – TheNumberOne Oct 6 '15 at 0:31
0
\$\begingroup\$

Impatient, Java

import static java.lang.Integer.parseInt;
public class Impatient {
    public static void main(String... args){
        int cakeLeft = parseInt(args[1]);
        int totalPeople = parseInt(args[2]);
        int peopleLeft = parseInt(args[3]);
        int answer = (int) Math.ceil(((totalPeople - peopleLeft + 10.0) * cakeLeft) / (totalPeople + 10.0));
        System.out.println((int) answer);
    }
}

I don't really know Java, so I don't even know if this will compile....

It starts out hungry for 10/(totalPeople+10) of the cake, getting hungrier and hungrier as the round wears on. Not sure how it will do, but it's a fun experiment.

\$\endgroup\$
  • \$\begingroup\$ Needs a semicolon also \$\endgroup\$ – Blue Oct 5 '15 at 23:27
  • \$\begingroup\$ Already done. :) \$\endgroup\$ – ETHproductions Oct 5 '15 at 23:28
0
\$\begingroup\$

Give me the cake, Bash

#!/bin/bash
echo 3594
\$\endgroup\$
-1
\$\begingroup\$

Pig, Java

public class Pig{
    public static void main(String[] args){
        System.out.println(args[1]);
    }
}

This pig is probably not smart enough to bid low.

\$\endgroup\$
  • \$\begingroup\$ Well, at least you're testing my controller. \$\endgroup\$ – Blue Oct 5 '15 at 13:03
  • \$\begingroup\$ I know, it was bidding the total amount of cake to start with, now edited \$\endgroup\$ – Blue Oct 5 '15 at 13:10
  • \$\begingroup\$ @muddyfish It was meant to bid what was left of the cake :) \$\endgroup\$ – TheNumberOne Oct 5 '15 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.