Thread: Anybody up for a game?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262

    Anybody up for a game?

    Hello all,

    I had an idea for a nice little game... So just checking in to see if anybody is interested in joining. You know the game where a group of people write a story, but everybody is allowed to write only a single sentence? That, except for coding.

    The goal is to finish a small and easy assignment, but everybody is only allowed to write either a single line or a single expression or statement (where grouped expressions count as multiple expressions, you all understand the rules by now more or less and it's too much hassle to write it out in a formal and "uncheatable" way so I won't even bother).
    The question is if we can write the assignment like that. It will be difficult: people must consider what variables are going to be used, and understand each other's variable naming. It might even be good practice to write easily readable code, and to learn to read other programmer's code.

    If enough are interested, we can do it. If not, this thread will die anyway...

  2. #2
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    What's the program supposed to do?

    Also, I suggest you start it with the int main, return 0, includes, etc. otherwise no one will start b/c they don't want to waste their one line on the meaningless crap.

    EDIT: FWIW, I like the idea. It does sound fun.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    169
    Quote Originally Posted by User Name: View Post
    What's the program supposed to do?
    Compile?

    I like this idea.

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I'd rather each person write a module. Interfacing modules offers the same challenges as one line per person but is also more constructive and useful in the end.

  5. #5
    Novice
    Join Date
    Jul 2009
    Posts
    568
    Sounds like fun. I'm in!
    Disclaimer: This post shows my ignorance at the time of its making. I claim ownership of but not responsibility for all errors in it. Reference at your own peril.

  6. #6
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Sure, why not!
    Devoted my life to programming...

  7. #7
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Okay, good, I guess there's enough people to join then. Does anybody have a good assignment to do this for? Like a homework question they remember, that's difficult enough (I'd say it should become between 50-100 lines of code)...

  8. #8
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    You should get all the participants to sign-up first, so you can pre-determine the order (first to reply could be complicated since you may have to think a bit before posting).

    assignment ideas:
    - sorting is always classic (especially if you don't say which algo in advance)
    - Compute word frequencies in a file, output sorted list.
    - Compute word to document associations in a directory of files (inverted index)
    - ...

  9. #9
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by Perspective View Post
    You should get all the participants to sign-up first, so you can pre-determine the order (first to reply could be complicated since you may have to think a bit before posting).

    assignment ideas:
    - sorting is always classic (especially if you don't say which algo in advance)
    - Compute word frequencies in a file, output sorted list.
    - Compute word to document associations in a directory of files (inverted index)
    - ...
    Hmmm that's a good question, whether people should sign up. If it is avoidable, I think that's better because people might only read the thread later on. Here are my proposed rules, and my question to you guys: do you guys agree with it?

    * The application is to be written in C++. [Or should we make it C? C++ allows a relatively more difficult assignment as things like sorting can easily be done using the STL]
    * A person may only add to the application if two others added after his/her last addition. [unless it's turn based, but then it's obvious]
    * An addition may only be appended to the source code; changing is not allowed.
    * A single addition may contain only one of the "blacklisted" characters and if it does this character must be the last character, with the only exception of whitespaces.
    * The blacklisted characters are: a semicolon ( ; ) and an opening brace ({).
    * The use of the "comma operator" is forbidden. Comma's are allowed of course in function definitions, function calls and to declare more than one variable on a single line. [otherwise you can add as many expressions as you wish, comma seperated]
    * Comments are not allowed, nor is communicating the purpose of certain additions in any other method to the other participants.
    * Macro's are not allowed.
    * At every addition, one may also add a single "#include" statement any place in the code.
    * Any person making an addition that makes it impossible (which is to say, no participant can find a solution) to successfully complete the application because of a logic error, the person loses and no longer participates; the application is restored to the version before his last change and the game continues. Syntax errors are exempted from this for typo's and the like.

    So, a valid addition would be "int main(){" (which will be my first addition). Another valid addition would be "int a, b = 2;", though it would be fairly hard to understand what a and b are supposed to be. An invalid addition would be "for(int i = 0; i < n; ++i){": that is actually three different additions, "for(int i = 0;", "i < n;" and "++i){". So that one can write a for loop, but the rest will have to know exactly what way you're going. And if someone writes something bad, the next persons will have to move in to fix the bug.

    So, what do you guys think of the rules?
    Last edited by EVOEx; 04-13-2011 at 10:31 AM.

  10. #10
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by EVOEx View Post
    So, what do you guys think of the rules?
    I think the more rules we make the less fun we're going to have. And in general, I think most of the rules proposed belong in obfuscated code contests.

  11. #11
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    *shrug*

    I'm in; it sounds like fun, but I do have some suggestions.

    Let's start small; all the way around. We have several people who've joined. Let's start a simple first attempt with those guys and a simple project. Actually playing the game will attract more attention than just talking about it. While playing the first game, rotating off a list unless someone hasn't posted within 24 hours where upon that name is skipped, people can sign up for the next round.

    Let's start with a profile. For example, a great C++ jumping off would be something like what I've posted here. It covers a lot of ground fast.

    Start a new post noting that round one has started with the rotation list. If the discussion goes on to long, the interest will drop to those who've not bothered to follow everything.

    Code:
    #include <algorithm>
    #include <cmath>
    #include <cstdlib>
    #include <fstream>
    #include <iostream>
    #include <sstream>
    #include <string>
    
    int main
    (
        int argc
      , char ** argv
    )
    {
        return(0);
    }



    sorting is always classic (especially if you don't say which algo in advance)
    If this is done in C++, this may be perfect.

    Compute word frequencies in a file, output sorted list.
    My vote is for this; at least, for a first attempt.

    Compute word to document associations in a directory of files (inverted index)
    This can't be done without stepping outside of C++ standard libraries unless a list of files is provided.




    An addition may only be appended to the source code; changing is not allowed.
    We will never be able to fix broken code; one bad addition destroys the game. It doesn't have to be a logic bug to break source you know.

    The use of the "comma operator" is forbidden. Comma's are allowed of course in function definitions, function calls and to declare more than one variable on a single line.
    We can police ourselves easier without fine grained rules like that. We all know what one statement means; we don't need to get complicated. For example, if I start a statement with any expression evaluating to an `lvalue', I can chain any number of expressions using the logic operators by forcing those expressions to evaluate to a value.

    So, let's just stick with "one simple/complex statement", accounting for the constructs necessary to do something useful with control constructs in one shot instead of three. Also, if you don't allow some complex additions, initializing some variables is right out.

    Comments are not allowed, nor is communicating the purpose of certain additions in any other method to the other participants.
    Okay, so no one will follow my code if I don't want them to follow it. I'm out.

    Is that seriously what you want? Again, one participant has a bad day and garages the game just because he is cranky making the addition as convoluted as possible?

    How about "self describing code only" or "consider changing the addition if a comment would be necessary".

    Macro's are not allowed.
    That's silly. If you consider that creating a macro would take multiple expressions, no one could game that path, and using the macro would also count towards the "one simple/complex statement" rule.

    At every addition, one may also add a single "#include" statement any place in the code.
    That's actually not bad, but I think if we stick to the standard library and other rules simply allowing free additions to the include list is fine.

    Any person making an addition that makes it impossible to successfully complete the application because of a logic error, the person loses and no longer participates; the application is restored to the version before his last change and the game continues. Syntax errors are exempted from this for typo's and the like.
    Again, not a bad rule, but I don't want to play that kind of game, and with the above referenced "no communication" rule I can force most people following me to lose.

    If we our going to play something like this, can't we just have a little fun with it?




    Why not? Isn't this standard compliant?
    That code can compile, but why impose such bad design decisions?

    It also prevents a lot of class and template conventions.

    Soma

  12. #12
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    cout << "Ok guys, the next few lines should recursively call the aggregation function while accumulating the total in the variable 'total'. Don't forget to check the base case of an empty structure and initialize the memory for the return data\n";

  13. #13
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by EVOEx
    * An addition may only be appended to the source code; changing is not allowed.
    Even with the exception for #include, I note thats this means that if the game starts with the global main function, then no other functions will be defined.

    Quote Originally Posted by EVOEx
    * The blacklisted characters are: a semicolon ( ; ) and an opening brace ({).
    So <% and ??< are not blacklisted (or rather, restricted)?

    Quote Originally Posted by EVOEx
    * Comments are not allowed, nor is communicating the purpose of certain additions in any other method to the other participants.
    You might want to clarify what "any other method" really means. As-is, your "for(int i = 0;" is invalid because i is a typical name for a loop index, and indeed the variable is used as a loop index, so the purpose of the variable was communicated by its name.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  14. #14
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by laserlight View Post
    Even with the exception for #include, I note thats this means that if the game starts with the global main function, then no other functions will be defined.
    Why not? Isn't this standard compliant? I've never read the standard completely so I'm not sure:
    Code:
    #include <iostream>
    
    int main()
    {
      void test();
      test();
    }
    
    void test()
    {
      std::cout << "TEST" << std::endl;
    }
    Quote Originally Posted by laserlight View Post
    So <% and ??< are not blacklisted (or rather, restricted)?
    Fair point. Any other way to circumvent the rules you can think of? ;-).

    Quote Originally Posted by laserlight View Post
    You might want to clarify what "any other method" really means. As-is, your "for(int i = 0;" is invalid because i is a typical name for a loop index, and indeed the variable is used as a loop index, so the purpose of the variable was communicated by its name.
    Also a good point... I'll edit the rules soon ;-).

  15. #15
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    In a nutshell, be careful what you write, there's no turning back!
    Oh, i have a feeling that the code in the end will be a big mess!
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Should I use a game engine in making a RPG game?
    By m3rk in forum Game Programming
    Replies: 6
    Last Post: 01-26-2009, 04:58 AM
  2. Guessing game: how to quit the game?
    By hzr in forum C Programming
    Replies: 5
    Last Post: 12-18-2008, 10:53 AM
  3. craps game & dice game..
    By cgurl05 in forum C Programming
    Replies: 3
    Last Post: 03-25-2006, 07:58 PM
  4. Game Designer vs Game Programmer
    By the dead tree in forum Game Programming
    Replies: 8
    Last Post: 04-28-2005, 09:17 PM
  5. Game Designer vs Game Programmer
    By the dead tree in forum General Discussions
    Replies: 2
    Last Post: 04-27-2005, 03:50 AM