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

Roguelike in Haskell

Name: dddddddddddddddddddddddddd 2007-04-11 7:21 ID:Vgzv11QG

I'm making one ^_^

Just to show off my elite level building skillz

*Level> pLevel $ foldObjs emptyLevel [(Way True 10, 23, 14), (Way False 5, 23, 9) ,(Way True 5, 15, 4), (Room (15,12), 1, 1), (Room (10, 7), 19, 3), (Room (40,7), 32, 10)]
                                                                               
 ---------------                                                               
 |.............|                                                               
 |.............|   ----------                                                  
 |.............#####........|                                                  
 |.............|   |........|                                                  
 |.............|   |........|                                                  
 |.............|   |........|                                                  
 |.............|   |........|                                                  
 |.............|   ----#-----                                                  
 |.............|       #        ----------------------------------------       
 |.............|       #        |......................................|       
 ---------------       #        |......................................|       
                       #        |......................................|       
                       ##########......................................|       
                                |......................................|       
                                ----------------------------------------       
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
*Level>

Name: Anonymous 2008-08-30 7:14

Please, for the love of god, add doors, people; otherwise, it is acceptable and even almost awesome that you are roguing in haskell.  Also, I'm sorry, but the # for walls (including corridor walls) is a terrible eyesore.  Please stop that.

Also, there is no penalty for diagonal movement (at least in nethack and many other roguelikes), and, in fact, diagonal movement is considered faster.

As someone hinted earlier, the nethack level generation code is available in mklev.c and mkmaze.c.  It's actually pretty straightforward (at least from what I can tell in a couple of minutes of looking at it).

mklev.c's meat is pretty much to make the rooms, then build doors between them and connect with corridors.  Here is the make rooms code:
STATIC_OVL void
makerooms()
{
    boolean tried_vault = FALSE;

    /* make rooms until satisfied */
    /* rnd_rect() will returns 0 if no more rects are available... */
    while(nroom < MAXNROFROOMS && rnd_rect()) {
        if(nroom >= (MAXNROFROOMS/6) && rn2(2) && !tried_vault) {
            tried_vault = TRUE;
            if (create_vault()) {
                vault_x = rooms[nroom].lx;
                vault_y = rooms[nroom].ly;
                rooms[nroom].hx = -1;
           
        } else
            if (!create_room(-1, -1, -1, -1, -1, -1, OROOM, -1))
            return;
    }
    return;
}

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