Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

One line text game.

Name: Anonymous 2011-10-28 4:48

(Declarations don't count as a line)

#include <iostream>

int main()
{
    int input = -1, location = 0;

    do {} while (
        (
            (
                (
                    (input != -1 && input != 2 && input != 4 && input != 6 && input != 8) ||
                    (input == 2 && ((location & 2) == 2)) ||
                    (input == 4 && ((location & 1) == 0)) ||
                    (input == 6 && ((location & 1) == 1)) ||
                    (input == 8 && ((location & 2) == 0))
                ) ? 0 * printf("Cannot move in this direction from this room.\r\n")
                  : 1 + ((input == -1) ? 0 * printf("== Super Text Adventure ==\r\n") : 0)
                      + 0 * (
                             location = (input == 8) ? (location & 1) :
                             ((input == 2) ? (location | 2) :
                             ((input == 4) ? (location & 2) :
                             ((input == 6) ? (location | 1) : location)))
                            )
            )
            ?
                0 * (
                        printf("---------\r\n| %c | %c |\r\n---------\r\n| %c | %c |\r\n---------\r\nYou are in room %d.\r\n%s\r\n",
                            location == 0 ? 'X':' ',
                            location == 1 ? 'X':' ',
                            location == 2 ? 'X':' ',
                            location == 3 ? 'X':'T',
                            location + 1,
                            location == 3 ? "You have found the treasure!  You win!\r\n" :
                                                                                "Which direction would you like to move?\r\n[8] North\r\n[4] "
                                                                                "West\r\n[2] South\r\n[6] East\r\n[0] Exit\r\n<===========>")
                    )
            :
                0
        ) || (
            (location == 3 ? 0 : (1 + 0 * scanf("%u", &input)))
            && input != 0
        )
    );
}

Name: Anonymous 2011-10-28 4:50

>>1
fondle my balls while i finger my butthole

Name: Anonymous 2011-10-28 5:01

iostream->printf->scanf
hmmm
hmmmmmm
hmmmmmmmmmmm

Name: Anonymous 2011-10-28 5:42

Can any C program theoretically be written as one line?

Name: Anonymous 2011-10-28 5:44

>>4
Only if you choose not to include any header files.

Name: Anonymous 2011-10-28 5:51

>>4,5
gcc -E bla.c | sed 's/^#.*//g' | awk '{ printf "%s ", $0}' > foo.c

Name: Anonymous 2011-10-28 5:53

HALP I CAN'T FIND THE TREASURE I'VE LOOKED EVERYWHAR

Name: Anonymous 2011-10-28 9:26

10 PRINT "YOU GOT THE NEW HIGH SCORE!"

Name: Anonymous 2011-10-28 9:53

>>1
do{} while(<code>)
the fuck am I reading?

Name: Anonymous 2011-10-28 9:54

Someone should really port progn to C.

Name: Anonymous 2011-10-28 9:55

>>9
It's just like a normal while loop, except the execution takes place at the bottom. Which in this context...matters...somehow...maybe.

Name: Anonymous 2011-10-28 10:19

here's your code

#include <iostream>

int main()
{
    int input = -1, location = 0;

    do {} while (
        (
            (
                (
                    (input != -1 && input != 2 && input != 4 && input != 6 && input != 8) ||
                    (input == 2 && ((location & 2) == 2)) ||
                    (input == 4 && ((location & 1) == 0)) ||
                    (input == 6 && ((location & 1) == 1)) ||
                    (input == 8 && ((location & 2) == 0))
                ) ? 0 * printf("Cannot move in this direction from this room.\r\n")
                  : 1 + ((input == -1) ? 0 * printf("== Super Text Adventure ==\r\n") : 0)
                      + 0 * (
                             location = (input == 8) ? (location & 1) :
                             ((input == 2) ? (location | 2) :
                             ((input == 4) ? (location & 2) :
                             ((input == 6) ? (location | 1) : location)))
                            )
            )
            ?
                0 * (
                        printf("---------\r\n| %c | %c |\r\n---------\r\n| %c | %c |\r\n---------\r\nYou are in room %d.\r\n%s\r\n",
                            location == 0 ? 'X':' ',
                            location == 1 ? 'X':' ',
                            location == 2 ? 'X':' ',
                            location == 3 ? 'X':'T',
                            location + 1,
                            location == 3 ? "You have found the treasure!  You win!\r\n" :
                                                                                "Which direction would you like to move?\r\n[8] North\r\n[4] "
                                                                                "West\r\n[2] South\r\n[6] East\r\n[0] Exit\r\n<===========>")
                    )
            :
                0
        ) || (
            (location == 3 ? 0 : (1 + 0 * scanf("%u", &input)))
            && input != 0
        )
    );
}


and now here's your new code:

//deleted cause it was a pile of shit

Name: Anonymous 2011-10-28 10:23

>>9
Typical sepples shit programmer

Name: Anonymous 2011-10-28 10:55

for loop looks better

for(int input = -1, location = 0;;<rest of the code>);

Name: Anonymous 2011-10-28 11:08

>>4-6
main() {system("echo -e '#include <stdio.h>\\nmain() {printf(\"%d\\\\n\", 1+2);}'|cc -xc -&&./a;rm a");}

Name: Anonymous 2011-10-28 18:12

main() {system("c:\\windows\\winmine.exe");}

Name: Anonymous 2011-10-28 22:50


DIM SHARED inp_name AS STRING
DIM SHARED inp_choice AS INTEGER
' this is the random number
' pssshhhhdjwuief dont tell anyone
' hehehehehehehehehe :)) <3
DIM SHARED val_myrand AS INTEGER
SUB read_name
    INPUT "Enter your Name: ", inp_name
    IF LEN$(inp_name) < 1 THEN
        PRINT " - Error: You didn't enter anything :("
        read_name
    END IF
END SUB
SUB read_choice
    INPUT "Enter your guess: ", inp_choice
    IF inp_choice < 0 OR inp_choice = 0 THEN
        PRINT " - Error: Please enter a bigger number, " & inp_name & " :("
        read_choice
    END IF
END SUB
SUB do_main
    read_choice
    IF inp_choice < val_myrand THEN
        PRINT " - Nice try " & inp_name & ", but your number is too small! :("
        do_main
    ELSEIF inp_choice > val_myrand THEN
        PRINT " - Nice try " & inp_name & ", but your number is too big! :("
        do_main
    ELSEIF inp_choice = val_myrand THEN
        PRINT " - Whoooo you got it right!"
        PRINT
        ' more semicolons = more awesome
        PRINT " *************************************************"
        PRINT " *  ###########################################  *"
        PRINT " *    A  W I N N E R  I S  Y O U ! ! ! ! ! !     *"
        PRINT " *  ###########################################  *"
        PRINT " *************************************************"
        PRINT
    END IF
END SUB
RANDOMIZE TIMER
val_myrand = RND
read_name
PRINT "Hello, " & inp_name & "!"
do_main


i'm not even sure if that code actually works

Name: Anonymous 2011-10-28 22:53

>>17

Enter your Name: my dog just died
Hello, my dog just died!
Enter your guess: 54
 - Nice try my dog just died, but your number is too big! :(
Enter your guess: 9
 - Nice try my dog just died, but your number is too big! :(
Enter your guess: 0
 - Error: Please enter a bigger number, my dog just died :(
Enter your guess: 1
 - Whoooo you got it right!

 *************************************************
 *  ###########################################  *
 *    A  W I N N E R  I S  Y O U ! ! ! ! ! !     *
 *  ###########################################  *
 *************************************************


that is one emotional bitch, right there.

Name: Anonymous 2011-10-28 23:53

#!/usr/bin/env sh
/usr/games/nethack


I win.

Name: Anonymous 2011-10-29 3:30

>>19
#!/usr/games/nethack
OMG OPTIMIZED

Name: Anonymous 2011-10-29 3:52

Name: Anonymous 2011-10-29 7:04

While you faggots are doing this im doing REAL WORLD ENTERPISE CODE

Name: Anonymous 2011-10-29 8:26

If the initialization part of an if statement doesn't count as a separate line, you can write

main() {
    X;
    Y;
    Z;
}


as

main() {
    for (X; 1;)
        for (Y; 1;)
            for (Z; 1;)
                goto end;
end:
}


which is one line.  Only works if every line in your program is something you can jam in an if, though.

Name: Anonymous 2011-10-29 9:16

>>23
goto labels need to have a statement after themselves

Name: Anonymous 2011-10-29 19:42

>>24
change the break to a return then.

Name: Anonymous 2011-10-30 7:35

>>25
but then it isn't a single ``line'' anymore...
WHBT

Don't change these.
Name: Email:
Entire Thread Thread List