Thread: Sigmaze! -- Second Attempt.

  1. #1
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Sigmaze! -- Second Attempt.

    After an intense battle with the email-change portion of the forum, OUR HERO is once again able to post! And so, here it is, the second attempt:


    In the past, I got the idea to use that horizontal line for the top edge of a maze which would be generated randomly, and fit in my .sig. I was going to just do it on my own, but thought it would be a fun contest idea. Since the forum doesn't work the way I'd like that isn't an option. So after mulling it over a while, I've decided upon the following alternate contests:



    CONTEST ONE: Here's looking at you, kid!
    The first of the two contests is purely aesthetic. This contest is to write a program which will generate output, which when pasted into the sig will create the best looking maze.

    The sig allows for a total of 500 characters to work with. This includes whitespace and newlines. I will compile and run your entry a few times, testing the output each time. The output of your program will be copied and pasted into my sig edit window, and saved or previewed. Points will be given for each time I run it, based on how good it looks.

    You do not have to use all 500 characters, it can be less. However, if your output is more than 500 characters, it won't fit, and as such, you won't get points for that run.

    Any forum tags which the sig will parse are allowed, with one exception. (I haven't tried this, but this is disallowed: You cannot use the IMG tag. I had the wicked idea to write a program to generate an image and then use the IMG tag to include it. ) All other tags, B, I, FONT, PHP, COLOR, etc, are ok to use. Again, the only restriction is that it must be purely text based output, which fits in 500 characters or less.

    The only thing that matters here is that your sig look good and fit in 500 characters. The source code does not have to fit in the 500 characters, only its output.



    CONTEST TWO: G. F. L.
    You may have noticed my sig off and on for a while. Well, this is that contest. The goal of this contest is to write a maze generator whose source code will fit in the 500 characters allowed by the sig.

    The output of the program doesn't have to fit in 500 characters. It can, but it doesn't have to. The source code has to fit in 500 characters. The winner of this contest will be the source code which fills the following requirements:

    1) The source code must fit in 500 characters or less.
    a) If more than one entry fits in 500 characters, which ever entry takes up less space will win.
    b) If no entries fit in 500 characters, which ever is closest to 500 characters will win.
    2) The output must be random. The entry will be run multiple times, and the output will be observed. The output must be different, ie, no static mazes.

    Currently, the output of my entry looks like so (random of course):
    Code:
    #############################################
    # #     # # #       # #         #           #
    # ##### # # ### ### # ######### # ###########
    # # #     # # # # # # # #         # #   #   #
    # # ##### # # ### # # # ### ### # # # ### ###
    # #   #       # #   # #   # #   #     #     #
    # # ######### # ### # ### ####### ##### # ###
    #     #   #           #     # #       # # # #
    ### ##### ########### ### ### ### ##### ### #
    #   #   #       # #       #   # # #       # #
    # ### ######### # ### ### ### # # # # # # # #
    # #   # # #     # # # #   #         # # #   #
    # ### # # ##### # # ### ######### ######### #
    #               # # #     #     #     # # # #
    # ### # # # ### # # ### ####### # # # # # ###
    # #   # # # #                     # #       #
    # ##### # # ### ### ### ############### #####
    #   #   # # # # #   #           #   #       #
    # # ### ##### # # # ### ####### # ##### # ###
    # # #       #   # # #         #     #   #   #
    # ##### ############# # ####### # # ### ### #
    #   #     #           #       # # # #     # #
    #############################################
    Your does not have to look like mine. It doesn't have to be the same size. It doesn't have to use hash marks. It just has to draw a clearly readable ASCII maze.

    3) The maze must be resizeable. In other words, you can't hard code the size of your maze. The maze must be easily resizable. Currently, my code has the following:
    Code:
    #define Y 11
    #define X 22
    You do not have to use defines. You can use const or some other method, but it has to be easy for me to change the size of the maze. If you want to include instructions on exactly what to edit to change the size of your maze, do so, but keep in mind, if it's a complex change, I won't bother doing it, and you won't get points for resizeability.

    I will be working on this entry myself, because it's something I've been amusing myself with for a while now. If you think I've got an unfair advantage, well maybe, but it's my contest.

    No, seriously, if you're wondering, you can look at the general idea behind what I've been doing over here. Now this was before I thought up the rules for the contest, so you'll notice I'd be losing with this entry for, among size issues, hard coding my size values. But that is somewhat close to what I have now. (Actually not any more, but still somewhat close.)

    I will be updating my sig until the contest ends with my current byte count, so you can have a gague as to how close you are to my entry. Currently at the time of creating this contest, I'm over 250 bytes too large with my current entry. Unless I think up something fairly nifty, I don't see it shrinking much more than it is now.



    Info for both contests:
    1) The contest deadline is the end of the month. If you're in another time zone, don't worry too much, it's not a make-or-break deadline. Just get it to me via email as close to the end of the month as you can.

    If for some reason you can't send it via email, post it as an attachment to a post in this thread. Naturally you'll want to wait until as close to the end of the month as you can, otherwise someone may copy your entry.

    2) Code: Entries can be either C or C++. I will be compiling the entries with GCC or G++. Your code should compile error and warning free, with the following flags:

    -Wall -pedantic

    I will make minor attempts to get your code to compile, but I won't be breaking my back to do so. If you write portable code, you shouldn't have any problems with this. Any warnings will subtract from your score. Any errors will naturally prevent your code from compiling, and as such, you won't win.

    Like I said, I'll try to get it to compile, but I'm not going to jump through fire to do so. If you don't use GCC/G++, just make sure your code uses only standard functions and includes, and you shouldn't have any problems.

    3) I will accept one .c or .cpp file, a .zip file, or .tgz file as your entry. Nothing else. You should in most cases easily be able to fit this in a single .c or .cpp file. If you're using classes, I suppose a header or two will be allowed. However, if you're entering Contest Two, I will be counting the size of all source code files you send me as your entry.

    Don't bother sending me a project file from MSVC++ or what not, because I won't be using them. It should be able to be compiled simply from a command line, or I won't bother with it. Again, if you're using standard includes and functions, you should have no problems meeting this requirement.

    If you have any other questions or what not, post in this thread and we'll work out any issues.

    Have fun, and good luck.


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Sounds fun, count me in. Since I'm pretty bad at optimizing file size I'll probably just enter contest one.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I haven't tried #1 yet. I may tinker in with it a bit. Unfortunately I think I'm stuck on #2. I don't see much way to shrink my code any more. Currently counting a blank newline to end the file, which wouldn't be there in the sig, I'm at 629 bytes total, using double digit X and Y sizes for the maze. I've run out of things to shrink with my current thinking on how to generate. So unless I do a full rewrite again, I think I've gone about as far as I can go.

    I already changed the way I generate the maze completely once, but I can't think of a smaller way to do it. Of course I'll tinker with looking at it until the deadline, but I really think I've reached the crunch point here on this version.

    Maybe I'll look into making a pretty maze now for #1.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    #define Y 11
    #define X 22
    Why not just:
    Code:
    int Y=11;
    int X=22;
    a) If more than one entry fits in 500 characters, which ever entry takes up less space will win.
    b) If no entries fit in 500 characters, which ever is closest to 500 characters will win.
    Isn't this equivalent to saying: "The smallest entry will win"?

    Anyway, what are the requirements for the maze in contest two? It's not hard to generate a random resizable maze within 500 characters. Just output some '#' randomly. What is the definition of maze?
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Sang-drax
    Why not just:
    Code:
    int Y=11;
    int X=22;
    Hmm, missed an obvious one there.


    Quote Originally Posted by Sang-drax
    Isn't this equivalent to saying: "The smallest entry will win"?

    Anyway, what are the requirements for the maze in contest two? It's not hard to generate a random resizable maze within 500 characters. Just output some '#' randomly. What is the definition of maze?
    Really? Do it then. The program must generate and display the maze. The entire program must fit in 500 characters or less. The maze must be random, as described above, and must be resizable. (ie: X=40, Y=80, or whatever)

    [edit]Changed 'bytes' to 'characters', since it's characters that the forum takes and not just any byte-value.[/edit]

    Quzah.
    Last edited by quzah; 10-06-2004 at 04:24 PM.
    Hope is the first step on the road to disappointment.

  6. #6
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by quzah
    Really? Do it then.
    I think Sang-drax's point was a program like this.

    look 500 chars exactly! i win
    Code:
    #include<ctime>
    #include<iostream>
    using namespace std;
    
    unsigned int i; 
    unsigned int j;
    unsigned int width=10;
    unsigned int height=10;
    
    void drawLine();
    
    int main() {
    
      srand(time(0));
      drawLine();
    
      for(i = 0; i < height - 2; i++) {
        cout << "#";
        for( j = 0; j < width - 2; j++ ) {
          cout << ( (rand()<RAND_MAX/3)? "#" : " " );
        }
        cout << "#" << endl;
      }
      drawLine();
    
      return 0;
    }
    
    void drawLine() {
     
      for(i = 0; i < width; i++) {
        cout << "#";
      }
      cout << endl;
    }
    Last edited by Perspective; 10-06-2004 at 05:09 PM.

  7. #7
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Uh, it has to compile first.

  8. #8
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by kermit
    Uh, it has to compile first.
    you caught my pre-edit post

  9. #9
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Does the maze have to have start and end points, with a guaranteed path between them?

    My first attempt at a random generator has come in at a mere 343 bytes, meeting your requirements for #2 (I think), but I wouldn't really describe its output as a "maze".
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  10. #10
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    There is a thread on the game dev board about mazes. Just convert it to text. The algo doesn't take that many lines of code and it is guaranteed to have only one solution.

    Think recursion.

  11. #11
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I suppose I have to clarify. A perfect maze, as described here (first google hit for 'perfect maze'). If I extend it to not-quite-perfect, it would allow for multiple paths to reach each cell in the maze. However, as you'll note from the output above, not all of these cells are accessable, as such, it would be insufficient.

    [edit=quzah]Fixing link that was inadvertently removed.[/edit]
    Last edited by quzah; 10-07-2004 at 08:08 AM.
    Hope is the first step on the road to disappointment.

  12. #12
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Bubba
    There is a thread on the game dev board about mazes. Just convert it to text. The algo doesn't take that many lines of code and it is guaranteed to have only one solution.

    Think recursion.
    Actually, I've a shorter solution without recursion than with. Also, without recursion, I can do a larger maze than with. I know that wasn't the goal, but my current code I did a million cell maze. (1000x1000). But yeah, my first method was using recursion.

    My output again is as I've shown above. Each cell in mine can be reached by every other, and there's only one path throughout.

    Quzah.
    Hope is the first step on the road to disappointment.

  13. #13
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by quzah
    3) The maze must be resizeable. In other words, you can't hard code the size of your maze. The maze must be easily resizable. Currently, my code has the following:
    Code:
    #define Y 11
    #define X 22
    I would consider that hardcoding... to me, hardcoding would be like to use a random number generator or use a config file or ask the user for input every time...

    or did you mean just make it easy for you to change because you have the source?
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  14. #14
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by Quzah
    I suppose I have to clarify. A perfect maze, as described here (first google hit for 'perfect maze'). If I extend it to not-quite-perfect, it would allow for multiple paths to reach each cell in the maze. However, as you'll note from the output above, not all of these cells are accessable, as such, it would be insufficient.
    OK, that makes sense. With that definition of 'perfect maze' I have made a program that generates a random perfect maze. It's currently 415 bytes, but I haven't done any optimizations like removing newlines and removing cin.get() at the end.
    I will submit it before the contest ends.

    I find it a bit strange that the creator of the contest participtes himself, but I guess we could live with it.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  15. #15
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I could see how to do it both ways quzah. Recursion is the easiest fundmentally, is it just me or do some problems lend themselves easier to recursive solutions and on others its vice versa?

    I'd be extremely interested in the non-recursive version, although I could probably look at my recursive version and port it to a non-recursive version.

    Oh and about the contest, sorry I'm working on a huge project right now and I'm actually going to try to complete it. I know, shock of all shocks, but it's true I've buckled down for the long haul on this one.

    Good luck to all.
    Mazes are very cool. Very good contest.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with my first linked list attempt.
    By SlyMaelstrom in forum C++ Programming
    Replies: 3
    Last Post: 11-09-2005, 04:33 AM
  2. Naming folders after the date - my futile attempt
    By shoobsie in forum C++ Programming
    Replies: 2
    Last Post: 06-24-2005, 09:50 AM
  3. *NOOB* attempt to make a calc prog
    By Inferno in forum C Programming
    Replies: 3
    Last Post: 08-30-2004, 10:38 AM
  4. switch - first attempt...
    By Nutka in forum C Programming
    Replies: 4
    Last Post: 10-04-2002, 09:58 PM