The Cake Cutting Contest

37

8

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.

Blue

Posted 2015-10-05T07:55:29.883

Reputation: 26 661

1

In case you think that the algorithm boils down to ceil(degrees/people), please see the contests sandbox entry here http://meta.codegolf.stackexchange.com/a/7095/32686.

– Blue – 2015-10-05T07:58:31.987

Can we save information to a file? – TheNumberOne – 2015-10-05T13:05:28.010

Sure as long as it puts it in the directory ./data/ (Also, the controller doesn't scrape, I do that manuallyish) – Blue – 2015-10-05T13:07:38.307

How long is the contest open? – recursive – 2015-10-05T15:37:37.537

10I 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. – Random832 – 2015-10-05T17:49:01.610

10Happy Birthday :) – TheNumberOne – 2015-10-05T19:33:56.317

Link to controller? – TheNumberOne – 2015-10-05T19:53:58.723

2Results 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. – Blue – 2015-10-05T20:11:46.133

@TheNumberOne Link to controller and answer puller (no they're not very pretty) https://github.com/muddyfish/cake-cutting-contest

– Blue – 2015-10-05T20:30:25.520

How many degrees of cake did that round start with? Adding it all up, I get 3303. – ETHproductions – 2015-10-05T21:00:14.937

3600, no, I'm not sure what happened there. I have checked the recent logs and they seem right. I won't be looking at this more until tomorrow, sorry if any issues arise. – Blue – 2015-10-05T21:03:06.443

I get 3600 for the sum. 719+4+0+0+2+0+0+0+297+256+0+0+330+0+5+296+360+720+257+354=3600 – Cabbie407 – 2015-10-05T21:37:45.313

Well, maybe I missed some. I was just doing a quick calculation on my tablet. But Slim and Flaming Chainsaw (and a few others) are not going to win by any stretch. ;) – ETHproductions – 2015-10-05T21:48:39.327

You don't say? I think Magician will win. – Blue – 2015-10-05T21:50:07.597

It would've, if it hadn't been changed... – ETHproductions – 2015-10-05T21:51:57.337

At some point, statelyimitator was winning with other 1/3 of the cake! – Blue – 2015-10-05T21:54:44.123

Happy my bot fails gracefully when faced with magically created cake. – histocrat – 2015-10-05T22:18:07.533

Can't wait to see how my bots do next time the controller is run :) This is an awesome AI experimentation challenge! – ETHproductions – 2015-10-05T23:24:38.220

1Well, here is another set of results {u'Reallythecake': 376, u'FlamingChainsaw': 0, u'Gentleman': 227, u'EatThe\u03c0': 0, u'Relinquisher': 0, u'CakeEater': 282, u'Imitator': 34, u'Moses': 243, u'StatelyImitator': 485, u'Greedy': 5, u'ALittleOffTheTop': 211, u'Fatbot5000': 372, u'Magician': 720, u'Meek': 226, u'CharityBot': 0, u'Hungry': 212, u'Impatient': 0, u'FloorBot': 0, u'Dieter': 4, u'Fair': 0, u'Slim': 0, u'Pig': 0, u'BobBarker': 203} [u'Magician'] – Blue – 2015-10-05T23:41:14.687

That's weird, both of mine got 0. I wonder what went wrong? – ETHproductions – 2015-10-05T23:42:56.627

Just checking now in case it's something I did wrong – Blue – 2015-10-05T23:44:12.553

If you've generated debug info, such as how much each bot bidded for each time around, that might be useful. – ETHproductions – 2015-10-05T23:45:08.637

Yeah I have that. You want it? If so how? – Blue – 2015-10-05T23:46:04.560

Upload to GitHub, maybe? – ETHproductions – 2015-10-05T23:47:07.377

Log file (log.log) is on the repo – Blue – 2015-10-05T23:52:14.707

OK, fixed a bug where the controller gave the current number of people for both args – Blue – 2015-10-05T23:59:02.393

@muddyfish Can you push the bugfix to github? – TheNumberOne – 2015-10-06T12:54:42.177

@muddyfish Could you update the GitHub repository to the same code which produced the log file, please? It seems your script is invoking Node.js wrong. – Toothbrush – 2015-10-06T14:39:31.527

1How was there 3600 degrees of cake per round? Your challenge explicitly states One cake, so the maximum should be 360? Is there more than one cake? – AdmBorkBork – 2015-10-06T15:17:01.240

I just noticed that in the debug file, Relinquisher bid for the entire cake every time. Was this due to the bug you fixed? – ETHproductions – 2015-10-06T15:27:52.647

@TimmyD could be a tiered cake. Or have strange fractal geometries. – histocrat – 2015-10-06T15:31:30.620

@toothbrush The reason that node.js isn't working is because I've never used it and am probably going to look up a way to run it tomorrow unless someone does a pull request on how to fix it as well as installation instructions for me :) Also, pushed bugfix – Blue – 2015-10-06T15:51:01.703

"There will be 17 rounds, the overall winner will be the entry with the most wins overall."

But, you can only "win" once, right? Then you're out of the game. – Jasmine – 2015-10-06T19:50:19.923

I mean the controller will run a full game 17 times – Blue – 2015-10-06T20:06:12.923

3Please format the leaderboard in a more reader-friendly manner. – SuperJedi224 – 2015-10-07T01:24:47.510

Muddyfish, initially mybot showed the score of 0, but now its not in the list why – Kishan Kumar – 2015-10-07T04:19:23.410

When will this actually start and how long will the interval between the rounds be to tune the robot? Just asking, because I don't have too much time at the moment. – Cabbie407 – 2015-10-07T05:20:54.107

@superjedi you're welcome to edit the question if you want. Kishan Kumar, your bot takes input from stdin rather than argv, I was pretty sure I had already commented but I guess I forgot. Cabbie, I haven't decided yet. – Blue – 2015-10-07T05:47:02.177

@muddyfish now my bot takes input from argv. – Kishan Kumar – 2015-10-07T11:42:52.220

@TimmyD There is only one cake, I'm just using a very weird measurement where the are 3600 degrees in a circle (think gradians weird) – Blue – 2015-10-07T17:18:43.587

2@muddyfish gradians? Much more like cakeians, right? – Jan – 2015-10-07T23:04:50.490

Can we access the internet? – Beta Decay – 2015-10-08T06:00:38.750

@muddyfish can you please add the time in the log file. And I couldn't find all the bidding of my bot. – Kishan Kumar – 2015-10-08T06:06:28.470

No, you can't access the internet (yes, I can see that it would be useful), by time, dou you mean the actual times? Bot's aren't allowed to look in the log files. – Blue – 2015-10-08T10:17:02.117

1@muddyfish I m not able to see all my biddings in the log.log file – Kishan Kumar – 2015-10-08T11:56:44.663

I spent a while trying to code one in Piet, but the lack of decimals makes it too hard :( – Domino – 2015-10-08T19:34:57.627

@muddyfish how much time will be between your announcing of when the challenge starts and the actual start? Will it be like 'okay, starting now!' or will you announce 'challenge starts tomorrow!'? I would love to enter another bot, but I still need to get the weighting function sorted … – Jan – 2015-10-08T20:36:34.300

Yes I restarted the contest because I realised the way I was starting it overwrote the log file the website reads from. Sorry! – Blue – 2015-10-16T11:30:09.853

What happened there? Log overflow? Okay... I thought it stopped. Nevermind. – Cabbie407 – 2015-10-16T17:21:02.063

I updated the site server so it has 2 log files that you can look at. the second one hasn't been cleaned in ages so it has lots of non-contest data in it – Blue – 2015-10-16T17:36:03.343

1Hooray, Relinquisher managed to come in 4th and 5th a few times, and consistently scored 1700+! :) Thanks for this awesome experiment! – ETHproductions – 2015-10-17T17:57:00.800

2That was certainly a fun contest! – Jan – 2015-10-17T18:20:52.007

Answers

5

Meek, awk

BEGIN{srand();print int(rand()>=.5?ARGV[2]/2.89:ARGV[1]/10-rand()*13)}

I saw this once in a simulation.

Cabbie407

Posted 2015-10-05T07:55:29.883

Reputation: 1 158

Have an upvote, your bot's doing damn well =O – Jan – 2015-10-16T12:34:56.433

Thanks. Well it's no coincidence. I actually ran the controller myself, trying to write a smarter bot. But most of the time it was beaten by the most simple bots. So I ended up using a pretty simple strategy, which won most of the time with a randomly sized cake. – Cabbie407 – 2015-10-16T16:33:58.143

13

Magician, Java

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

The number 720 is magical.

This is was meant to test the controller and is not a serious entry.

TheNumberOne

Posted 2015-10-05T07:55:29.883

Reputation: 10 855

3

I think this was actually winning the contest the way it was originally, with a score of 720 here.

– PhiNotPi – 2015-10-05T20:33:17.500

10

Slim, Python 2

print 0

This bot's on a diet.

Blue

Posted 2015-10-05T07:55:29.883

Reputation: 26 661

10

SadBot :(, C++

#include<iostream>
#include<cstdlib>
#include<stdlib.h>
int main(int argc, char**argv) 
{
    if (argc!=5){std::cout<<"Incorrect number of arguments";return 1;}
    double list[4];

    list[0]= atof(argv[1]); // total Degrees
    list[1]= atof(argv[2]); // degrees left
    list[2]= atof(argv[3]); // total people
    list[3]= atof(argv[4]); // people left


    std::cout<<list[1]/list[3]; // degrees left/ people left

    return 0;
}

Formerly FairBot

FairBot just wants an equal portion :(

He wants to split the cake evenly amongst all the participants.

(He fully expects the other bots to rip him off though because he knows they're mean)

(Like really. He is lonely, he just wants the other bots to like him)

(He just got out of a bad relationship and is going through a really rough patch, so if you could just give him a pat on the back and a smile to make him feel better it would really mean a lot. )

EDIT changed program to take input from argv/c instead of stdin (fair bot is still sad.... He wants to change his name to sadbot (which is kinda why he wants cake))

Liam

Posted 2015-10-05T07:55:29.883

Reputation: 3 035

Can you make it so it takes the args from argv rather than stdin? – Blue – 2015-10-06T16:22:04.213

As you have commanded, so it is done. – Liam – 2015-10-06T20:06:53.567

1You can change your name to sadbot if you want. – Blue – 2015-10-06T20:20:45.053

Also, the brackets need to be put inside the code block – Blue – 2015-10-06T20:23:19.560

Ok, now I'm getting 'atof' was not declared in this scope – Blue – 2015-10-06T20:28:13.987

atof should be in the C++ standard (should even work in C if I'm not mistaken). I added some includes so hopefully it should work now. – Liam – 2015-10-06T20:30:40.403

g++ $1 -o ./bots/$2; ./bots/$2 $3 $4 $5 $6 – Blue – 2015-10-06T20:35:44.133

Is it still throwing the error after you add the extra includes? – Liam – 2015-10-06T20:36:50.117

Nope, your bot scored 0, (it prints out 0.00833333 when ran as sh "./commands/c++.sh" "./bots/SadBot.cpp" SadBot 3600 3600 30 30) – Blue – 2015-10-06T20:43:23.070

I have the input order backwards. I'll swap it around. Wow I'm bad at this. Should now cout 120 in that situation. – Liam – 2015-10-06T20:44:33.543

Ok, now its getting 144/3600 pieces (winner is getting 649) – Blue – 2015-10-06T20:57:34.773

1And hence he is a sad bot. – Liam – 2015-10-06T20:58:36.230

9

Halver, Ruby

def halver(total_degrees, degrees_left, total_people, people_left)

  if people_left == 1
    degrees_left
  else
    degrees_left/2 - 1 
  end

end

p halver(*ARGV.map(&:to_i))

Scrupulously, unimpeachably fair. Half the cake for me, half the cake for everyone else.

histocrat

Posted 2015-10-05T07:55:29.883

Reputation: 20 600

8

CharityBot, Python 2

print -360

Adds another cake to the mix!

(The controller will see this as a request for 0 cake, will not actually add to the size of the cake)

Blue

Posted 2015-10-05T07:55:29.883

Reputation: 26 661

7

Stately Imitator, Ruby

def stately_imitator(total_degrees, degrees_left, total_people, people_left)

  current_winner_path = './data/current_winner'
  previous_cake_path = './data/previous_cake'

  first_move = (total_people == people_left)

  current_winner = first_move ? 0 : File.read(current_winner_path).to_i
  previous_cake = first_move ? total_degrees : File.read(previous_cake_path).to_i

  last_slice = previous_cake - degrees_left
  current_winner = [current_winner, last_slice].max

  File.open(previous_cake_path, 'w') { |f| f.puts(degrees_left)   }
  File.open(current_winner_path, 'w'){ |f| f.puts(current_winner) }

  if first_move
    degrees_left / 2
  else
    average_left = degrees_left.fdiv(people_left).ceil
    bid = [average_left, current_winner+1].max
    [bid, degrees_left].min
  end

end

p stately_imitator(*ARGV.map(&:to_i))

Variant of Imitator (if you'd rather only one entry per player, this supersedes that one). Keeps precise track of the largest slice taken already, and always bids enough to beat that slice. Will also never bid lower than its fair share of the remainder. Assumes a read/writable './data' directory already exists; the files can either be there already or not.

histocrat

Posted 2015-10-05T07:55:29.883

Reputation: 20 600

In case you didn't notice, I have multiple answers too (but only one of them is sensible) – Blue – 2015-10-05T20:15:47.043

there's good news and bad. Bad - there's a bit that changes your config files. Good - your bot actually does better! 505/3600, it won the last round I did! – Blue – 2015-10-07T06:26:16.113

6

Dieter, Java

public class Dieter {
    public static void main(String... args){
        System.out.println("4");
    }
}

It doesn't want to bid for too much cake, so it chooses a small but guaranteed random slice.

DankMemes

Posted 2015-10-05T07:55:29.883

Reputation: 2 769

1If you downvote my posts please explain why. Otherwise I can never improve! – DankMemes – 2015-10-05T14:18:37.153

18Oh. I just assumed you could guess that the downvote was because it appears you're just blatantly using an xkcd ref for laughs/votes, not caring that it will most likely never win a single game. – Geobits – 2015-10-05T14:40:29.973

1Yeah, I downvoted too. You can find this "joke" all over this site, it's just not funny anymore. – CommonGuy – 2015-10-05T16:07:18.050

3

We have a standard loophole addressing the use of fake random numbers (in which this particular xkcd is explicitly referenced). Since the challenge doesn't require randomness in the submissions, this isn't necessarily a violation of the loophole, but still. ಠ_ಠ

– Alex A. – 2015-10-05T17:14:52.783

1I understand. Right now I can't really write/debug code so I thought I'd submit something stupid and make a real entry later. – DankMemes – 2015-10-05T17:40:24.303

3I understand that, but don't then act surprised if someone downvotes your "something stupid". – Geobits – 2015-10-05T18:50:53.177

2Up vote to counter people with no humor – Bobby – 2015-10-06T11:16:16.393

1Downvote to counter people with stale humor. – Blorgbeard is out – 2015-10-07T05:37:06.953

5

Flaming Chainsaw, Java

public class FlamingChainsaw
{
    public static void main(String[]args)
    {
        if(args.length<4){return;}
        if(Integer.parseInt(args[3])<3){System.out.println(0);}
        else{System.out.println(args[1]);}
    }
}

Have you ever tried holding a cake-cutting contest with a chainsaw? Well, now you have. It's rather disruptive.

PhiNotPi

Posted 2015-10-05T07:55:29.883

Reputation: 26 739

2I find that I can usually tune out the chainsaw noise, but it sure does make a mess when you use it to cut the cake. – Alex A. – 2015-10-05T15:45:30.373

3This is an exotic way to light the candles. – TheNumberOne – 2015-10-06T12:20:54.357

5

Gentleman, Java

import static java.lang.Integer.parseInt;
import java.io.*;
import java.util.*;

public class Gentleman{
    private final static String FILE_NAME = "data/Gentleman.txt";

    static {
        new File("data").mkdir();
    }

    public static void main(String[] args) throws Exception{
        int totalCake = parseInt(args[0]);
        int cakeLeft = parseInt(args[1]);
        int totalPeople = parseInt(args[2]);
        int peopleLeft = parseInt(args[3]);

        if (totalCake == cakeLeft){
            System.out.println(cakeLeft);
        } else {
            int previousCake = load();
            int cakeDiff = previousCake - cakeLeft;

            if (cakeDiff > optimal(previousCake, peopleLeft + 1)){
                System.out.println(peopleLeft == 1 ? cakeLeft : Math.min(cakeLeft, cakeDiff + 1));
            } else {
                System.out.println(cakeLeft);  //Hey, I might get lucky :)
            }
        }
        save(cakeLeft);
    }

    private static void save(int cake) throws Exception{
        PrintStream out = new PrintStream(FILE_NAME);
        out.print(cake);
    }

    private static int load() throws Exception{
        Scanner in = new Scanner(new File(FILE_NAME));
        return in.nextInt();
    }

    private static int optimal(int cake, int people){
        return (cake + people - 1) / people;
    }
}

He waits for people who eat a fair share or less before he eats any cake. To prevent the greedy from getting extra cake, he takes as large a portion as possible.

TheNumberOne

Posted 2015-10-05T07:55:29.883

Reputation: 10 855

4

Bob Barker, Java

public class BobBarker{
    public static void main(String[] args){
        System.out.println((int)Math.floor(Integer.parseInt(args[1]) * .84));
    }
}

This is probably going to be replaced with a more thought-out solution later, but I'm curious if this will work. This is just to catch any bots that try and go for maximum, and do a modified Price is Right strategy to steal their answer. Might lead to escalation with increasing integer subtractions, that'd be neat.

EDIT: Escalation commences, counter-posting against FloorBot

thefistopher

Posted 2015-10-05T07:55:29.883

Reputation: 151

I moved your description to the bottom to match the challenge's formatting requirements. – PhiNotPi – 2015-10-05T14:49:52.077

@PhiNotPi, woops, forgot about that requirement. Thanks for fixing it! – thefistopher – 2015-10-05T14:50:42.710

Hah, I just had the same thought

– AdmBorkBork – 2015-10-05T14:51:04.907

Well, the answer parser looks at the first line and then at the first code block. Also, you need to convert args[1] to an int before doing subtraction. – Blue – 2015-10-05T19:29:12.407

@thefistopher you still need to do int conversion – Blue – 2015-10-05T20:46:18.747

@muddyfish Sorry! Is it working now? – thefistopher – 2015-10-05T21:43:40.783

Yep, your bot's getting 299 of 3600 pieces, the winner has 701. Good luck! – Blue – 2015-10-05T21:49:00.753

OMG! it's Bot Barker! – Aureliano Far Suau – 2015-10-06T16:20:01.710

4

Eidetic, Python 2

import random, math, sys, json

total_degrees, degrees_left, total_people, people_left = map(int, sys.argv[1:])
#try:
#    inp_f = open("./data/Eidetic.json", "r")
#    out = json.load(inp_f)
#except (IOError, ValueError):
out = {"last_cake": 0,
           "runs": 0,
           "total_runs": 0,
           "total_rounds": 0,
           "training":  [[0.0], [0.0], [0.12903225806451613], [16.774193548387096], [400.83870967741933], [720.0], [995.8709677419355], [996.9437634408603], [997.6], [997.6], [997.6], [998.5991397849463], [996.6770967741936], [998.8122580645161], [1011.5467420570814], [1017.7717824448034], [1227.155465805062], [1280.7840603123318], [1435.8028540656974], [1553.3689822294023], [1793.5330640818527], [2299.178101402373], [3183.924709689701], [2231.666666666667], [2619.4789644012944], [1270.9288025889969], [741.2718446601941], [480.4757281553398], [122.66990291262135], [27.54736842105263]]}

#else: inp_f.close()

def write_out():
    out_f = open("./data/Eidetic.json", "w")
    out_f.write(json.dumps(out))
    out_f.close()

def get_last_winner(): # Find the bid of the last winner
    bid = out["last_cake"]
    return max(bid, degrees_left) - degrees_left

def train():
#    print degrees_left # If you get that much, your probably safe.
#    sys.stderr.write("\nEidetic - Training len %s, no runs: %s, no_rounds: %s, last winner: %s\n"%(len(out["training"]), out["runs"], out["total_rounds"], get_last_winner()))
    if len(out["training"]) <= out["runs"]: out["training"].append([])
    out["training"][out["runs"]].append(get_last_winner())

def get_best_round():
    data = out["training"][out["runs"]+1:]
    mean = [sum(i)/(float(len(i)) or 1) for i in data]
    bid = max(mean+[0]) - 0.5
    sys.stderr.write("\nEidetic - mean %s\n"%mean)
    return bid

def main():
    reset = total_people == people_left
    if reset:
        out["total_rounds"] += 1
        out["runs"] = 0
    train()
    bid = get_best_round()
    print bid
#    sys.stderr.write('\nEidetic Bid: '+str(bid)+'\n')
    out["total_runs"] += 1
    out["runs"] += 1
    out["last_cake"] = degrees_left
    write_out()

main()

I ran this bot in the controller a couple of times to train it up a bit, it remembers the bids required to win each round and then once trained, it goes out into the real world and votes with the rest of them.

Blue

Posted 2015-10-05T07:55:29.883

Reputation: 26 661

That's a clever way to do it; you're ahead of the pack now. I wonder if this could still get one-upped, though... – ETHproductions – 2015-10-08T21:37:44.877

3

CoffeeJunkie, Coffeescript

#!/usr/bin/env node

# Require node fs
fs = require("fs")

# Happy birthday ;)
CAKECONSTANT = Math.round("""
                 /
               ,( ),
                 Y
                |-|
                | |
       _..--''''| |''''--.._
     .'   @_/-//-//>/>'/ @  '.
    (  @  /_<//<'/----------^-)
    |'._  @     //|###########|
    |~  ''--..@|',|}}}}}}}}}}}|
    |  ~   ~   |/ |###########|
    | ~~  ~   ~|./|{{{{{{{{{{{|
     '._ ~ ~ ~ |,/`````````````
        ''--.~.|/

""".length / 250 + Math.random())

# Some constants
OLD = "./data/CoffeeJunkie_oldcake.txt"
NEW = "./data/CoffeeJunkie_newcake.txt"

# How much cake do I want?
wantCake = (total_c, rest_c, total_p, rest_p) ->
    round = total_p - rest_p
    fairness = rest_c // rest_p

    switchMemory() if round is 0

    fairest_round = tryToRemember(total_p)
    tryToMemorize(fairness)

    if round >= fairest_round then fairness - CAKECONSTANT else total_c // 2

# Ok I should try to remember the last cake...
switchMemory = () ->
    try
        fs.renameSync(NEW, OLD)
    catch error

# What happend with the last cake?
tryToRemember = (rounds) ->
    try
        last_cake = fs.readFileSync(OLD, "utf-8")
        last_cake.trim().split(" ").map(
            (i) -> parseInt(i)
        ).reduce(
            (x, y, z, li) -> if y > li[x] then z else x
            0
        )
    catch error
        rounds / 2

# Watch what happens!
tryToMemorize = (fairness) ->
    try
        fs.appendFileSync(NEW, " " + fairness)
    catch error

# Coffee is ready, so... GO!
console.log(wantCake(process.argv[2..]...))

What exactly is a cake without a good cup of coffee?

The CoffeeJunkie prefers coffee over a slice of cake, but nevertheless wants to try some. He will always be fair to other participants and will try to remember what happened to the last cake. However, his excessive coffee consume has weakened his memories...

Cipher

Posted 2015-10-05T07:55:29.883

Reputation: 1 321

Can you rename the language to either coffeescript of node.js? – Blue – 2015-10-06T17:50:49.260

Done, though you need node.js to run and install: npm install -g coffee-script; coffee CoffeeJunkie.coffee – Cipher – 2015-10-07T09:04:25.877

Are you sure that's a candle on your cake? It looks a little more... phallic :D – Beta Decay – 2015-10-16T18:01:48.167

@BetaDecay ...any better? :D – Cipher – 2015-10-19T07:38:25.017

@Cipher That's good :D – Beta Decay – 2015-10-19T16:02:26.567

3

Saucy, Ruby

def saucy(total_degrees, degrees_left, total_people, people_left)

  current_winner_path = './data/saucy_current_winner'
  previous_cake_path = './data/saucy_previous_cake'

  first_move = (total_people == people_left)

  current_winner = first_move ? 0 : File.read(current_winner_path).to_i
  previous_cake = first_move ? total_degrees : File.read(previous_cake_path).to_i

  last_slice = previous_cake - degrees_left
  current_winner = [current_winner, last_slice].max

  File.open(previous_cake_path, 'w') { |f| f.puts(degrees_left)   }
  File.open(current_winner_path, 'w'){ |f| f.puts(current_winner) }

  if first_move
    degrees_left
  else
    average_left = degrees_left.fdiv(people_left).ceil
    beats_past_players = current_winner + 1
    beats_future_players = degrees_left/4 - people_left**2
    [average_left, beats_past_players, beats_future_players].max
  end

end

p saucy(*ARGV.map(&:to_i))

Saucy is willing to accept slightly less than half of the remaining cake, so long as it's more than anyone else has gotten or is likely to get (based on secret sauce).

histocrat

Posted 2015-10-05T07:55:29.883

Reputation: 20 600

3

AlCakeBot, Python

import sys, math

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

fraction_left = (degrees_left + 0.0)/ total_degrees
fraction_gone = 1.0 - fraction_left

factor = (math.sin(fraction_gone * math.pi / 2.0))**2
fraction = (factor/2.0) + 0.5

if total_degrees == degrees_left:
   print(int(math.floor(total_degrees/2.0) - 1))
else:
   print(int(math.floor(degrees_left * fraction)))

This is my first PCG post; I hope this works out as intended …

I love cake. No matter which kind. My colleagues know. And so does my bot. If the entire cake is still there, he will bid for just under half of it, hoping to get the biggest slice immediately. If not, he should bid for something between half the remaining cake and all the remaining cake, using a squared sine as a weighting function (½ + sin² (fraction gone) / 2). The reasoning being that there should be a chance for an overall larger (but fractionally smaller) slice early in the game and there also being little point in trying to be a gentleman in the late game.

Since I’m not very much into programming, I’ll appreciate any error pointed out. Now let’s eat some cake =D

Jan

Posted 2015-10-05T07:55:29.883

Reputation: 151

2

IWMBAICBIWT, Python

import sys

degreesleft = int(sys.argv[2])
peopleleft = int(sys.argv[4])

print(round(degreesleft/peopleleft))

IWMBAICBIWT (It was my birthday and I cried because I wanted to) assumes that there is a relationship between the degrees left and the number of people left. Let's hope it works!

Should work in all Pythons.

Edit:

Storing sys.argv in inputs was a bit wasteful...

Beta Decay

Posted 2015-10-05T07:55:29.883

Reputation: 21 478

It should be degreesleft = int(inputs[2]); peopleleft = int(inputs[4]) and it's bidding 1 all the time – Blue – 2015-10-06T20:55:46.297

@muddyfish Edited – Beta Decay – 2015-10-07T05:52:32.180

2

Stately Sabotage, Ruby

def stately_sabotage(total_degrees, degrees_left, total_people, people_left)

  current_winner_path1 = './data/current_winner'
  previous_cake_path1 = './data/previous_cake'
  current_winner_path2 = './data/statelysabotage-current_winner'
  previous_cake_path2 = './data/statelysabotage-previous_cake'

  first_move = (total_people == people_left)

  current_winner = first_move ? 0 : File.read(current_winner_path2).to_i
  previous_cake = first_move ? total_degrees : File.read(previous_cake_path2).to_i

  last_slice = previous_cake - degrees_left
  current_winner = [current_winner, last_slice].max

  File.open(previous_cake_path2, 'w') { |f| f.puts(degrees_left)   }
  File.open(previous_cake_path1, 'w') { |f| f.puts(total_degrees) }
  File.open(current_winner_path1, 'w'){ |f| f.puts(current_winner) }
  File.open(current_winner_path2, 'w'){ |f| f.puts(1) }

  if first_move
    (degrees_left / 2) - 1
  else
    average_left = degrees_left.fdiv(people_left).ceil
    bid = [average_left, current_winner+1].max
    [bid, degrees_left].min
  end

end

p stately_sabotage(*ARGV.map(&:to_i))

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.

This bot decided that in order to eliminate competition, it should not be sporting.

This is a clone of Stately Imitator, except that this one messes up Stately Imitator's persistence files (as they aren't prefixed with the bot name) so that it makes the wrong decisions and is chosen last.

Riking

Posted 2015-10-05T07:55:29.883

Reputation: 249

1'You should not do this deliberately' Doesn't this count? – Blue – 2015-10-06T22:43:49.097

3This is why we can't have nice things. – histocrat – 2015-10-06T22:56:11.847

@muddyfish I took it in the RFC2119 sense. "there may exist valid reasons in particular circumstances when the particular behavior is acceptable or even useful, but the full implications should be understood" – Riking – 2015-10-07T01:44:55.730

2

Trader, R

args <- sapply(commandArgs(TRUE),as.integer)
fraction <- args[2]/args[4]
if(args[3]==args[4]){
    cat(fraction, "\n", file="data/trader.txt")
}else{
    cat(fraction, "\n", file="data/trader.txt", append=TRUE)
}
history <- scan(file="data/trader.txt", quiet=TRUE)
if(tail(history,1) != max(history)){
    cat(floor(fraction)-1)
    }else{
        cat(args[2])
        }

Keeps track of the evolution of the degrees left vs people left ratio and when that ratio starts lowering, it asks for a reasonably fair slice, otherwise asks for the whole remaining cake. Invoked using Rscript trader.r total-degrees degrees-left total-people people-left.

plannapus

Posted 2015-10-05T07:55:29.883

Reputation: 8 610

2

guest, Python 2

print ord('d')*4

user193661

Posted 2015-10-05T07:55:29.883

Reputation: 221

3This isn't code golf you know ;) – Blue – 2015-10-07T22:41:16.503

2

bill, Python 2

import sys
t,r,p,s=map(int,sys.argv[1:])
print(t-ord('d')*4)/(ord('\n')+ord('\t'))

A fairish bet.

user193661

Posted 2015-10-05T07:55:29.883

Reputation: 221

2

AlCakeSurfer, Python

import sys, math

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

fraction_left = (degrees_left + 0.0)/ total_degrees
fraction_gone = 1.0 - fraction_left
fair_share = fraction_left/people_left
modified_fair_share = fair_share + 0.05

weighting = 0.5 * fraction_gone + 0.5 - modified_fair_share
surfing = (math.cos(fraction_gone * math.pi))**2

print(int(math.floor((weighting * surfing + modified_fair_share)* total_degrees)))

Since AlCakeBot did so badly (and I expect him to do even worse in the contest) here’s my second entry. I called him Surfer, because he has a very nice up-and-down wave function that makes him feel like a surfer.

In principle, he bids according to cos² (x * pi), where x is the fraction of cake that has been taken. This surfing wave is modified with a weighting function that causes him to start at less than a fair share less than half of the cake, reduces his bids to just above a fair share around when half of the cake is gone, and then speeds back up to bidding for the entire cake later. He will never bid less than a fair share of the remaining cake plus 5 % (percent of the entire cake, that is).

Note that while they may be brothers, if he gets a significantly larger slice than AlCakeBot, the latter is not even getting a single crumb of that. They would share chocolate or biscuits, but not cake!

Jan

Posted 2015-10-05T07:55:29.883

Reputation: 151

Wow, I got lucky in early rounds and it quickly went South once others optimised their bots =O – Jan – 2015-10-16T18:44:18.267

1

Hungry, Java

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

Always wants its fair share of the remaining cake.

CommonGuy

Posted 2015-10-05T07:55:29.883

Reputation: 4 684

1

Cake Eater, Java

public class CakeEater{
    public static void main(String[]args){
        int a=Integer.parseInt(args[1]),b=Integer.parseInt(args[2]),c=Integer.parseInt(args[3]);
        System.out.println((int)Math.min(a,((1.2+Math.random()*0.15)*a)/c));
    }
}

It eats cake. That's about it.

SuperJedi224

Posted 2015-10-05T07:55:29.883

Reputation: 11 342

1

A Little Off The Top, Python 2

import math, sys

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

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

def noms(total_degrees, degrees_left, people):
  bid = get_equal_share(total_degrees,people)-1
  return min(degrees_left, bid)

print noms(total_degrees, degrees_left, people_left)

Since the "perfect" algorithm tries to split the cake evenly between the bots, we're going to take just a sliver less than that. Demands its full fair share of the overall cake, even in subsequent rounds, but skews that number upward since it's based on how many people are left.

I haven't programmed in Python in a long while, so let me know if my code is broken...

AdmBorkBork

Posted 2015-10-05T07:55:29.883

Reputation: 41 581

1

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.

Morgan Thrapp

Posted 2015-10-05T07:55:29.883

Reputation: 3 574

Cue next bot bidding 84%... – Geobits – 2015-10-05T15:05:43.210

6@Geobits I have another idea for a bot that scrapes this post and bids 1% less than any other percentage based bot. :P – Morgan Thrapp – 2015-10-05T15:09:12.267

Again, argv[1] needs to be converted to an int – Blue – 2015-10-05T19:36:03.380

@muddyfish Oops, duh. Fixed. – Morgan Thrapp – 2015-10-05T19:37:13.693

@MorganThrapp Hmm. A bot challenge based on reading the source code of the other bots would be fun, not that I would participate. – mbomb007 – 2015-10-05T21:37:58.193

I've restrained myself from cheating like this, it would be easy for me to write a script that scraped other entries with the data structure (you have it too now.) – Blue – 2015-10-05T21:53:41.570

1

Imitator, Ruby

def imitator(total_degrees, degrees_left, total_people, people_left)

  case people_left
  when total_people
    degrees_left - 5
  when 1
    degrees_left
  else
    average_already_won = (total_degrees - degrees_left).fdiv(total_people - people_left)
    average_left = degrees_left.fdiv(people_left)
    guess_for_current_winning_score = average_already_won * (1.25 ** (total_people - people_left - 1))
    bid = [average_left, guess_for_current_winning_score].max.ceil
    [bid, degrees_left].min
  end

end

p imitator(*ARGV.map(&:to_i))

The goal is to get more cake than anyone else, not to maximize your cake. Thus, this bot won't settle for any less than what previous bots have already taken. (This version uses heuristics for that check, I just noticed we're actually allowed to save state so I'll probably post a stateful variant later).

histocrat

Posted 2015-10-05T07:55:29.883

Reputation: 20 600

1

EatTheπ, Node.js

var π = Math.PI, e = Math.E;
var [totalπ, πLeft, totalPeople, peopleLeft] = process.argv.slice(2);
console.log(Math.min(totalπ * Date.now() * π % (πLeft * totalPeople / peopleLeft) % totalπ, πLeft / e * π, πLeft) | 0);

Really likes π, and thinks that cake means is π.

Toothbrush

Posted 2015-10-05T07:55:29.883

Reputation: 3 197

Then why is it eating cake? :P – TheNumberOne – 2015-10-05T15:48:22.927

1@TheNumberOne Because it isn't fed anything else :( – Toothbrush – 2015-10-05T16:03:02.773

2@TheNumberOne Now it thinks that cake is π... Why did you ask that? – Toothbrush – 2015-10-05T16:09:39.000

I had to remove the escaped quotes from the command script and rewrite the second line of the script like this var totalπ=process.argv[2], πLeft=process.argv[3], totalPeople=process.argv[4], peopleLeft=process.argv[5]; to make this work with the controller. It got 97 out of 3600 in the field of 41 bots. – Cabbie407 – 2015-10-09T19:26:51.563

1

Really the cake, Bash

#!/bin/bash
echo "$RANDOM 652 / $2 * 100 / $2 $4 / + p" | dc

And here is a picture of the real cake.

A picture of the actual cake

James

Posted 2015-10-05T07:55:29.883

Reputation: 119

1

Relinquisher, Java

import static java.lang.Integer.parseInt;
public class Relinquisher {
    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(((peopleLeft + 10.0) * cakeLeft) / (totalPeople + 10.0));
        System.out.println((int) answer);
    }
}

A basic variant of my other bot, Impatient. This one tries to take the whole thing at first, but as more and more guests get their share, its desire to get the most possible slowly diminishes. I'm not too into this one; just wanna see how well it does.

ETHproductions

Posted 2015-10-05T07:55:29.883

Reputation: 47 880

Needs a ; in the mathsy line – Blue – 2015-10-05T23:26:41.307

@muddyfish Whoops, thought I put it there before. Thanks for pointing that out! – ETHproductions – 2015-10-05T23:27:47.017

Also needs to be cast as an int as does the other one – Blue – 2015-10-05T23:31:19.330

Thought it already is...? – ETHproductions – 2015-10-05T23:32:16.860

Require int found double? – Blue – 2015-10-05T23:34:20.853

Should this last edit fix the problem? – ETHproductions – 2015-10-05T23:34:45.207

Yep, works for this, just change impatient now – Blue – 2015-10-05T23:36:06.527

Haha, already done again :) Sorry for being such a n00b with Java. – ETHproductions – 2015-10-05T23:36:18.260

OK, when ran as sh "./commands/java.sh" "./bots/Relinquisher.java" Relinquisher 3600 3600 23 21 it returns 0 all the time as does the other one – Blue – 2015-10-06T00:08:37.680

That's really weird. I have no idea what could be causing that. – ETHproductions – 2015-10-06T00:13:16.587

Does Java do floating division by default? – Blue – 2015-10-06T00:14:57.933

Not sure, but it may not in this case, since everything is integers. Perhaps changing the 10s to 10.0 would do it. – ETHproductions – 2015-10-06T00:16:46.637

@muddyfish I've switched around the order of operations so the multiplication is done first, and also changed the 10s. Does it work now? – ETHproductions – 2015-10-06T15:23:00.800

1

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.

The_Basset_Hound

Posted 2015-10-05T07:55:29.883

Reputation: 1 566

1SYS argvs need to be mapped to ints – Blue – 2015-10-06T10:34:10.583

@muddyfish Fixed. Whoops. – The_Basset_Hound – 2015-10-06T10:52:02.560

1

this_bot_wants_it_all_possible, PHP

  echo 359;

This bot wants it all possible.

zozo

Posted 2015-10-05T07:55:29.883

Reputation: 217

1At the moment, cakes have 3600 degrees – Blue – 2015-10-06T10:33:27.280

Also, your bot doesn't have a correct header (and I don't have a PHP environment at the moment) – Blue – 2015-10-06T16:55:23.793

1

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;
}

Kishan Kumar

Posted 2015-10-05T07:55:29.883

Reputation: 427

Doesn't return anything, I'm passing args via argv. – Blue – 2015-10-06T16:23:55.217

@muddyfish i m very sorry. I forgot to take input – Kishan Kumar – 2015-10-06T17:18:37.087

1

ALittleExtra, sh

#!/bin/sh
fair=$(expr $2 / $4)
myextra=$(expr $2 / $3)
want=$(expr $fair + $myextra)
echo $(($want<$2?$want:$2))

I just want a bit more, gets less greedy as cake dwindles

Shaun H

Posted 2015-10-05T07:55:29.883

Reputation: 732

1

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.

Conor O'Brien

Posted 2015-10-05T07:55:29.883

Reputation: 36 228

Last line should be print(tD/(random.random()) – Blue – 2015-10-06T16:39:31.707

1

MyFairPlusAThird, sh

#!/bin/sh
fair=$(expr $2 / $4)
myextra=$(expr $2 / 3)
want=$(expr $fair + $myextra)
echo $(($want<$2?$want:$2))

Shaun H

Posted 2015-10-05T07:55:29.883

Reputation: 732

0

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.

Blue

Posted 2015-10-05T07:55:29.883

Reputation: 26 661

0

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.

CommonGuy

Posted 2015-10-05T07:55:29.883

Reputation: 4 684

0

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.

TheNumberOne

Posted 2015-10-05T07:55:29.883

Reputation: 10 855

Can you rename the not to FairPlusPlus? (The name not the main class) – Blue – 2015-10-05T23:29:16.677

@muddyfish Done – TheNumberOne – 2015-10-05T23:45:46.703

Also don't assume FairPlusPlus.txt exists :) – Blue – 2015-10-05T23:47:30.227

Now getting inputmismatch errors – Blue – 2015-10-05T23:48:52.280

1@muddyfish Fixed. – TheNumberOne – 2015-10-06T00:31:11.067

0

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.

ETHproductions

Posted 2015-10-05T07:55:29.883

Reputation: 47 880

Needs a semicolon also – Blue – 2015-10-05T23:27:52.993

Already done. :) – ETHproductions – 2015-10-05T23:28:10.447

0

Give me the cake, Bash

#!/bin/bash
echo 3594

James

Posted 2015-10-05T07:55:29.883

Reputation: 119

-1

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.

TheNumberOne

Posted 2015-10-05T07:55:29.883

Reputation: 10 855

Well, at least you're testing my controller. – Blue – 2015-10-05T13:03:44.830

I know, it was bidding the total amount of cake to start with, now edited – Blue – 2015-10-05T13:10:30.227

@muddyfish It was meant to bid what was left of the cake :) – TheNumberOne – 2015-10-05T13:13:24.897