>>11
Oh come on, I haven't even written a level generator yet.
It's probably a good idea to use something more abstract than tiles for the level generation process.
Name:
Anonymous2007-04-17 11:55 ID:v7YeOWaZ
>>12
I have now written a level generator. Please bear in mind that the pathfinding algorithm (esp from Data.Graph.Inductive) does not have a penalty for diagonal movement, and will thusly use it a lot. Also, I don't think I have ensured that the corridors keep away from the walls of the rooms.
>>13
Eh, just generate Nethack-like levels. Then there's no worry about corridors getting too close to rooms. (Also, nethack style levels look less busy.)
Name:
Anonymous2007-04-17 12:13 ID:v7YeOWaZ
>>14
It's annoying having to care about what's a room and what is not!
Hmm... I could assign a higher weight to tiles next to open tiles, that would keep corridors separate as well!
>>20
Was >>16 meant to quote >>19? I still want to see it.
Also, I'm not >>17, but yes, I tried finding NetHack's level generation code and I couldn't :-(. Granted I didn't try very hard, but it's certainly not in an obvious location.
Speaking of which, can anyone point me to where the level generation is in the source code?
Name:
Anonymous2007-04-18 4:08 ID:iBr/ioVT
>>1
why do that when the shit been ported so many times already in the last 20years?
*bang*
..33 and counting.
Name:
Anonymous2007-04-18 4:22 ID:QHvHeZag
>>25
Because we're not all EXPERT JAVA DEVELOPERS working on ENTERPRISE READY MULTIMILLION LOC WEBAPPS
>>22
I just make a node for every tile (using y*w+x as node id) and then add edges between all adjacent tiles.
If I need to do something like pathfinding, I only add nodes that satisfy certain conditions, such as being floors.
>>24 Speaking of which, can anyone point me to where the level generation is in the source code?
Dunno lol, I think it's spread over several files. Ah, the mk*.c files.
Name:
Anonymous2007-04-18 7:19 ID:QHvHeZag
>>28
Is your code as ugly as mine? I'm trying to figure out if roguelike code is inherently ugly, or I'm doing it wrong.
e.g. displayInventory :: H ()
displayInventory = do
gs <- get
let is = (inventory . player) gs
outStr 0 0 " Your inventory: "
mapM_ (\(n,l) -> outStr 3 n ((['a'..'z'] !! (n-1)) : ". " ++ (itemname l)))
(zip [1..] (take 22 is))
io $ C.refresh
Name:
Anonymous2007-04-18 7:28 ID:4cFEfsE+
>>29
I'm afraid I haven't got any terribly bad-looking examples!
Oh, wait...
randomValues :: RandomGen g => g -> ((Int, Int, Int, Int, Compass), g)
randomValues g =
let (x, g1) = randomR (2, 76) g -- Magic numbers, motherfucker, do you use them?
(y, g2) = randomR (2, 20) g1
(w, g3) = randomR (2, 10) g2
(h, g4) = randomR (2, 6) g3
(c, g5) = random g4
in ((x, y, w, h, c), g5)
Name:
Anonymous2007-04-18 13:05 ID:4cFEfsE+
Looks a bit better with only orthogonal connections. Still some random issues with unconnected rooms, corridors that trail off into the edges, and other fun stuff :) *Main> main
The easiest way is probably to trace a line from the point of sight to every tile on the map. If the line intersects a solid tile, do not draw the final tile, else do so.
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;