Contest - Traveller's Dilemma

This is a discussion on Contest - Traveller's Dilemma within the Contests Board forums, part of the Community Boards category; Here's a very simple contest open to all skill levels.
Write a function that competes in a game that illustrates ...

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

Well, it actually sounds a bit simple -- why not pick a tougher problem? And you'll probably need some more rules. How long is the contest open for? When will the "tournament" be run? (I'm assuming that you'll run it.) What language(s) can the entries be written in? What sort of format will the entries be required to have? Do they just return an int and take no parameters?

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

A guaranteed win in a single round, to be sure. Overall, it could do very poorly. Consider if the following functions were entered:

Code:

int f() { return 2; }

Code:

int f() { return 100; }

Code:

int f() { return 99; }

Overall, the constant 99 would win in this field with 1010, the constant 100 would net a respectable 970, while the constant 2 would earn a measly 80. Deviating from 2 does create some risk, but it offers the potential to pay off considerably.

Originally Posted by dwks

The 2-100 range is inclusive, right?

Yes, it's inclusive.

I haven't quite finished with the details, but my intent was to require submissions in C++ so that the programmer could inherit from a base class. It makes it easier to integrate all the entries into the competition program. Have a better idea?

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

Rules

Submissions
If you choose to enter, please reply stating that you have entered the contest. Before midnight on the Contest deadline you must complete a submission that meets the stated requirements and send it to the submission officer via email or private message. E-mail is preferred. The contest website can be found at http://fluff.thejefffiles.com/coding/travellersdilemma.

Introduction
Write a function that competes in a game that illustrates the Traveller's Dilemma. Here are the rules:

The object is to maximize the number of points that you earn.

A game will be arranged in a round-robin tournament in which your function will compete with each other function. Each round will consist of some number of turns.

During each turn, both you and your opponent pick a number between a lower bound and an upper bound. The one that picks the lowest number will gain points equal to the lowest number + the bonus. The one that picks the highest number will gain points equal to the lowest number - the bonus. If the numbers are the same, both players get that many points.

Five games will be run per simulation with different lower bounds, upper bounds, and bonuses, one of which will be the traditional Traveller's Dilemma (lower bound=2, upper bound=100, bonus=2). The winner is the writer of the function that accumulates the most total points over all five games.

A number of different simulations have been suggested. The following will be run:

The primary entry per programmer and 10 turns per round.

Multiple entries per programmer allowed and 10 turns per round.

The primary entry per programmer with a random amount of turns per round.

Multiple entries per programmer allowed with a random amount of turns per round.

Details
Entries will be accepted in C++. Write a class that inherits from the following abstract class:

previousEarning will be the amount of points earned in the last turn or NEW_ROUND if starting a new round. lowerBound will be the lower bound of the range of values. upperBound will be the upper bound of the range of values. bonus will be the amount of points gained if the chosen number is the smaller of the two or lost if the chosen number is the larger of the two. ChooseNumber should return a number between lowerBound and upperBound. For organizational purposes, please name the class as close as possible to your CBoard username. Use the following header file: travellers_dilemma.h

Contest Rules
Below are the current contest rules and regulations.

I. Official RulesI.I You may submit up to four entries, and they must have been submitted between the contest start and end dates. The programmer must designate one of their entries to be the primary entry.

I.II Entries submitted should be:

Substantially the developer's original design

Substantially the developer's original programming

In C++

I.III In simulations that allow multiple entries, objects of the same class may be used. In other words, each entry does not need to be its own class; the same class may be used multiple times if desired.

II. Code JudgingII.I Submitted code will be judged solely on the number of points earned during the game. Code that does not compile will be disqualified. Code that generates invalid numbers in ChooseNumber during any part of a simulation will be disqualified from that simulation.

II.II In each simulation, five games will be run with different lower bounds, upper bounds, and bonuses, one of which will be the traditional Traveller's Dilemma (lower bound=2, upper bound=100, bonus=2). The winner is the writer of the function that accumulates the most total points over all five games.

II.III The following simulations will be run:

The primary entry per programmer and 10 turns per round.

Multiple entries per programmer allowed and 10 turns per round.

The primary entry per programmer with a random amount of turns per round.

Multiple entries per programmer allowed with a random amount of turns per round.

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

Each game consists of enough rounds for your function to compete against each other function. Each round consists of ten turns. Five games will be played with varying upper bounds, lower bounds, and bonuses. So, assuming four entries, your function will play in five games, each with three rounds that are ten turns long.

Originally Posted by dwks

Can we submit more than one entry?

Multiple entries poses an interesting twist: the possibility of collusion. You can submit up to four entries, but make sure to designate one of them to be your primary entry. In the main competition, only the primary entry from each programmer will be allowed. If there is enough interest, I'll run a second simulation that includes all the entries.

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

Each game consists of enough rounds for your function to compete against each other function. Each round consists of ten turns. Five games will be played with varying upper bounds, lower bounds, and bonuses. So, assuming four entries, your function will play in five games, each with three rounds that are ten turns long.

Edit:

To clarify:

Our function will be tried 10 times with each function and that constitues a round.

Our function will be put through as many rounds as there are "enemy functions", and that constitutes a game.

Our function will be put through 5 games in total.

Is this correct? Are those numbers set for sure or are they subject to change?

Our function will be tried 10 times with each function and that constitues a round.

Our function will be put through as many rounds as there are "enemy functions", and that constitutes a game.

Our function will be put through 5 games in total.

Is this correct? Are those numbers set for sure or are they subject to change?

Aye, that's pretty much it, except for the first line, I'd say "Our function will compete against one "enemy function" 10 times and that constitues a round".

Those numbers are "the numbers" unless someone can offer a compelling reason to change them. 10 times against a competitor in a round should be enough to allow for a myriad of strategies, and 5 games should provide a good cross sample of the possible interesting games one can derive from varying the parameters of the Traveller's Dilemma.

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

Consider randomizing the number of turns in a round. There are different (and less fun IMO) strategies if you know how many rounds there will be.

I like the idea as a separate simulation. Should the number of turns be random per game or per round? What would be an acceptable lower bound? I'm leaning towards random per round with a lower bound of 2; I don't find single-shot rounds to be especially interesting.

Originally Posted by Daved

>> previousEarning will be the amount of points earned in the last turn or NEW_ROUND if starting a new turn.

That turn should be "round", right?

Yes, good catch.

Originally Posted by Daved

Also, can you provide the opponent's proposal from the previous round as well, or is that part of the game to not know?

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

I agree that single shot rounds wouldn't be interesting unless you did it on purpose. I'm not even sure that two turn rounds would be all that interesting. My preference would be to have the bounds be higher (5-15?, 10-100?), and randomize each round rather than each game. I also think it would be best if you were to have a random turn simulation to have the number of turns not be known to the contestants' code, even during the competition. So at one point the game just stops.

My preference would be to have the bounds be higher (5-15?, 10-100?)...

Higher bounds works.

Originally Posted by Daved

I also think it would be best if you were to have a random turn simulation to have the number of turns not be known to the contestants' code, even during the competition. So at one point the game just stops.

Yes, that's pretty much how it'd have to be since there's no parameter to pass in the number of turns to the function.

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

You could always change the interface if you wanted, but I'm obviously fine with that answer.

When you have the code setup to run the simulations, could you post that so we can test on it? You don't necessarily have to publish the actual data you will be passing if you'd like it to remain secret.

If I have time I think I'll write one that assumes a random number of turns, even though that's not the official rule. If that causes it to lose so be it.

When you have the code setup to run the simulations, could you post that so we can test on it? You don't necessarily have to publish the actual data you will be passing if you'd like it to remain secret.

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein