Thread: Contest - Traveller's Dilemma

  1. #1
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401

    Contest - Traveller's Dilemma

    Here's a very simple contest open to all skill levels.

    Write a function that competes in a game that illustrates the Traveller's Dilemma.

    *snip*

    Before I start spouting off stuff about entries, is there any interest in this contest?

    [edit] There seems to be interest. Scroll down for the details.
    Last edited by pianorain; 06-14-2007 at 08:36 PM. Reason: Consolidating rules so that things are less ambigious.
    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

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I'd like to play, but someone is probably going to enter with
    Code:
    int f() { return 2; }
    and crush the tournament.

    Please go into detail about how the contest works.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Here's my first entry.
    Code:
    int dwks_1(void) {
        return (rand() % 99) + 2;
    }
    Here's my second.
    Code:
    int dwks_2(void) {
        return 100;
    }
    And here's my third.
    Code:
    int dwks_3(void) {
        return 2;
    }
    The 2-100 range is inclusive, right?

    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?

    [edit] citizen beat me to it. [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "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


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Quote Originally Posted by citizen View Post
    I'd like to play, but someone is probably going to enter with
    Code:
    int f() { return 2; }
    and crush the tournament.
    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.
    Quote Originally Posted by dwks View Post
    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

  5. #5
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401

    Rules

    Traveller's Dilemma Contest

    Schedule / Deadline
    Start Date: June 15th, 2007
    End Date: June 30th, 2007

    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.

    E-mail: [email protected]
    PM: pianorain

    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:
    Code:
    class TravellersDilemma
    {
    public:
    	virtual int ChooseNumber(int previousEarning, int lowerBound,
    		int upperBound, int bonus) = 0;
    	virtual ~TravellersDilemma(){};
    };
    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 Rules
    I.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 Judging
    II.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.
    Last edited by pianorain; 06-15-2007 at 08:01 AM. Reason: Multiple entries allowed. Multiple simulations added; clarified about multiple 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

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I think you should make the end date June 31st.

    Each round will consist of 10 turns.
    ...
    The winner is the writer of the function that accumulates the most total points over all five games.
    So the ten turns is actually five games?

    Okay, could be interesting. Can we submit more than one entry?
    dwk

    Seek and ye shall find. quaere et invenies.

    "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


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Quote Originally Posted by dwks View Post
    So the ten turns is actually five games?
    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.
    Quote Originally Posted by dwks View Post
    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.
    Last edited by pianorain; 06-14-2007 at 03:01 PM.
    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

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Hmm, I think I might have to try this....

    Quote Originally Posted by pianorain View Post
    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?
    Last edited by MacGyver; 06-14-2007 at 04:24 PM.

  9. #9
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Quote Originally Posted by MacGyver View Post
    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?
    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

  10. #10
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    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.

    Oh, and it looks like you edited in the rules above, in case others missed it.

    >> 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?

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

  11. #11
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Quote Originally Posted by Daved View Post
    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.
    Quote Originally Posted by Daved View Post
    >> 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.
    Quote Originally Posted by Daved View Post
    Also, can you provide the opponent's proposal from the previous round as well, or is that part of the game to not know?
    That's part of the game.
    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

  12. #12
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    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.

  13. #13
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Quote Originally Posted by Daved View Post
    My preference would be to have the bounds be higher (5-15?, 10-100?)...
    Higher bounds works.
    Quote Originally Posted by Daved View Post
    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

  14. #14
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    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.

  15. #15
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Quote Originally Posted by Daved View Post
    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.
    Aye, I plan to once I finish this next version of it.
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Expression Evaluator Contest
    By Stack Overflow in forum Contests Board
    Replies: 20
    Last Post: 03-29-2005, 10:34 AM
  2. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  3. WANTED: Contest Master
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-23-2003, 10:15 PM