Roguelike in Haskell
1
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>
2
Name:
Anonymous
2007-04-11 7:33
ID:WZvz0yqV
Needs more non-rectangular rooms.
3
Name:
Anonymous
2007-04-11 7:55
ID:W8YLrdRl
Needs more cowbell
4
Name:
Anonymous
2007-04-11 8:41
ID:rfxdz013
>>1
is this supposed to impress me?
why dont you post the implementation of pLevel LOL.
5
Name:
Anonymous
2007-04-11 8:53
ID:Vgzv11QG
>>2
FAGGOT
*Level> let crossRoom = let box = Room (7,5) in foldObjs1 [(TPath GenericFloor True 5, 11, 9), (TPath GenericFloor False 3, 16, 6), (TPath GenericFloor False 3, 10, 6),(TPath GenericFloor True 5, 11, 5), (box,10,5), (box,5,5),(box,15,5), (box,10,1), (box,10,9)]
*Level> printLevel crossRoom
-------
|.....|
|.....|
|.....|
------.....------
|...............|
|...............|
|...............|
------.....------
|.....|
|.....|
|.....|
-------
*Level>
And no this isn't supposed to be user-editable.
6
Name:
Anonymous
2007-04-11 8:54
ID:Vgzv11QG
>>4
levelToString :: Level -> [String]
levelToString = map2 tileToChar . dungeon
printLevel :: Level -> IO ()
printLevel = putStr . unlines . levelToString
???
7
Name:
Anonymous
2007-04-11 8:56
ID:WZvz0yqV
>>5
Very good. Now show us a goatse-shaped level.
8
Name:
Anonymous
2007-04-11 8:56
ID:rfxdz013
>>6
is this supposed to impress me?
why dont you post the implementation of tileToChar LOL.
why dont you post the implementation of dungeon LOL.
9
Name:
Anonymous
2007-04-11 9:39
ID:bW7pC3Kg
Angband-style dungeon for the lazy ;)
main = getStdGen >>= putStrLn . show . fillBox (10, 10) (15, 15) (Tile Wall) . fst . randomMapG (80, 24)
##..##..#...##.....#######..##.# #.##.###.##.######.#.##.#.###.##.#..#...#..##..
..##.####...#.#...#...##..#.#.######.##...##.....#...##....#.#.#.....##.#.##.#.#
......#...#.....###...##.#.#.#..#.#..##.##.#.#.##...##.#......##.#.#.......###..
...##.###.#..#...#..###..###.###..#.##.##...#.#.##.#.#..#.#.#....##.#....#.# #..
.####.#..#..###..##.........#.###.#..###.#...#.#....#####...#.##.###..#.##.#####
##.###..####.###...#..##.....##.##.##.#.####...###.#.#.###...######..##.#..##...
.#..#.#...#######......###.#....#.####.#..#...#..###.####...#.#.###....#..##..#.
.###.#..###...#.##...###..##.......##.#####.##.##.#....#..##.......#..##.##.##..
##.##.##.#..##..#...###.#..####...###.#.##.#..#.##.#..##.#.##.#...#..##.#.######
#.#..#.###...#..#..#####...##.##...#...#..##..####.#####..#.##..#.#..#..#.#...#.
####...#.######......##.##.....##....#..#.#.#.#..#.....#.#.#.#..#..###..###.#...
#.#..#.#.## #...###.##.##.#.####...##.#..#####.##..#...#.###......#.#..###...#
#..##.#...# #.#.######..############..#.#.#...###..#.##..###.#....##..###.#...
.######.#.# ###..####.#.###.#..##.#..##...#........##...##...###......####.###
...##.....### #..###..#####.##.#..####.#...#.....#..#.###..####.#.##.#.#..#...#
#.##...###..####...#...##.#..#.#..#.###.#.####.....##..#.####.#.#####.....#.....
#...#####.##......#..###...#...#.####.###.#.#.#####..#.######..#.#.#.##.##.##.##
.#.##..###....#.##.##...#.###.....##.#..#.##..# #...#...##.##..###..#..####.##..
...#..##.##.#..##..#....##.##.##...#.#...#.#.######..#.#....#.#####.#..#..#.#..#
.#.#.#.#.#.#...#.#.#.##..#.#..##.....##.#.#.....##..#..#...#....##.###....#..##.
##.#..##....#.#.####..##.#......#.#....#.#.####.#.#.#####....##...#..##.#####.#.
...##..##.#.#....#..#######...##..#..#..#.#.####..##.#.#...#.##.###.##..###..##.
.##.##.#######..#.###..#.###..#....#...#......#..#.###..####..####.#####.#...#.#
#####..##.#.##...###.#.##.#..###...##.###.##......#..#.##..###.##.## #..#.....##
10
Name:
Anonymous
2007-04-11 9:54
ID:/tU3b9ZU
x <=> y
11
Name:
Anonymous
2007-04-11 12:34
ID:Heaven
>>9
Wow, that dungeon fails hard.
12
Name:
Anonymous
2007-04-12 4:16
ID:rKYdamuA
>>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.
13
Name:
Anonymous
2007-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.
*Main> main
#### ####
#..##### ##..##
##...##.##### ##....#
##...........# ##.#...#
##.#..........# ##.##...#
##.##########.## ##.###...#
#### ##.## ##.## ##.## #...#
##..###.## ##.## ##.## #####
#....#.## ##.## ##.##
#...#.## ##.## ##.##
#...### ##.## ##.##
#...# ##.## ##.##
##### ##.## ##.##
##.## ##.##
##.## ##.##
##.## ##.##
##.## ##.##
##.## ##.##
##.## ##.##
##.## ##.##
##.###.##
##...##
14
Name:
Anonymous
2007-04-17 11:59
ID:FKR6Bpsx
>>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.)
15
Name:
Anonymous
2007-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!
16
Name:
Anonymous
2007-04-17 17:28
ID:ImMm6e2X
17
Name:
Anonymous
2007-04-17 17:45
ID:iFsiwib7
Why not just copy the room-generating algorithm from NetHack's code? Of course it would need to be HASKELLIFIED but you'd see about weighting issues.
18
Name:
Anonymous
2007-04-17 21:21
ID:FKR6Bpsx
>>17
Then you'd get Nethack levels. A new roguelike obviously needs its own feel, rather than lifting Nethack's verbatim.
19
Name:
Anonymous
2007-04-17 22:15
ID:qCX9sxf1
>>1
source code or it didn't happen
20
Name:
Anonymous
2007-04-18 2:39
ID:4cFEfsE+
>>17
I take it you have never looked at NetHack's level generation? (Just finding it is a challenge in itself.)
>>16
I'm afraid you'd punch me in the face if you saw the code. It's like THREE HUNDRED lines of code.
21
Name:
Anonymous
2007-04-18 2:42
ID:QHvHeZag
>>17 has obviously never seen NetHack source code. ughhh
22
Name:
Anonymous
2007-04-18 3:00
ID:QHvHeZag
>>16
I'm interested how you turn the level into a Data.Graph.Inductive. Presumably you then use Data.Graph.Inductive.Query.SP?
23
Name:
Anonymous
2007-04-18 3:34
ID:QHvHeZag
24
Name:
Anonymous
2007-04-18 3:38
ID:C5Aoeq+y
>>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?
25
Name:
Anonymous
2007-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.
26
Name:
Anonymous
2007-04-18 4:22
ID:QHvHeZag
>>25
Because we're not all EXPERT JAVA DEVELOPERS working on ENTERPRISE READY MULTIMILLION LOC WEBAPPS
27
Name:
Anonymous
2007-04-18 4:27
ID:iBr/ioVT
>>26
it's called unix. you may have heard of it?
28
Name:
Anonymous
2007-04-18 6:38
ID:4cFEfsE+
>>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.
29
Name:
Anonymous
2007-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
30
Name:
Anonymous
2007-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)
31
Name:
Anonymous
2007-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
###
######.#####
#..........#
#..........#
############ #..........#
#..........# #..........#
#..........## ######.#####
#...........# #.#
#...........# #### #.#
###########.# ##..# ###.#
#.# #...# #...#########
#.# #...# #...........#
#.# #.#.# #...........#
######.# #.#.# #...........# ###
#......# #.#.#######################.......#######.#
#......################.#.......................................#
#.......................#########################################
#......########.....#####
#...............#####
#################
32
Name:
Anonymous
2007-04-18 13:44
ID:zGR/KFF7
FUCK YOUR SHITTY HASKELL CODE ID WRITE THIS IN C?
33
Name:
Anonymous
2007-04-18 14:55
ID:9dZe8HuP
>>29
You could do "is <- gets (inventory . player)" rather than the get and let. Assuming that you're using the State monad.
34
Name:
Anonymous
2007-04-18 15:21
ID:QHvHeZag
>>33
Yeah. RWST actually.
35
Name:
Anonymous
2007-04-19 6:19
ID:BMLHNaX3
Quack quack motherfuckers
36
Name:
Anonymous
2007-04-19 6:43
ID:WjtYJ7dF
You hit Hurr'k Or'drl!
--------- ------------------------
|..)c>..| |.................?....|
|.....<.| |......................|
----@---- |...................%..------------
T -----.............................|
##### |.............................|
# ----------------------#--------
# #
# #
# # #
# # #
# ------------------------ # #
# |........~~~~~~~~~.....| # #
# |...~~~~~~~~~~~.........#############################
# |.....~~~~~~...........| # #
####.......................| --------.------ #
------------------------ |.............| #
|.............|
|.............|
---------------
Monos, healthy 64
how 2 implement line-of-sight??1
37
Name:
Anonymous
2007-04-19 8:55
ID:1SlyAwrT
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░████████████░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░████████████████░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░████████████████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░████████████████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░████░░██████░░██████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░██░░██░░██░░██░░████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░██░░██░░██░░██░░████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░██░░▒▒▒▒▒▒▒▒██░░████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒██████░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░██░░▒▒▒▒▒▒▒▒░░░░██████░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░████░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░████░░░░░░░░░░░░░░░░░░██████████░░░░░░░░░░░░
░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░░░░░██████████░░░░░░░░░░
░░░░░░░░░░░░░░████░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░
░░░░░░░░░░░░░░████░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░
░░░░░░░░░░░░████░░░░░░░░░░░░░░░░░░░░░░░░░░██████████░░░░░░░░
░░░░░░░░░░░░████░░░░░░░░░░░░░░░░░░░░░░░░░░██████████░░░░░░░░
░░░░░░░░░░██████░░░░░░░░░░░░░░░░░░░░░░░░░░██████████░░░░░░░░
░░░░░░░░░░██████░░░░░░░░░░░░░░░░░░░░░░░░░░██████████░░░░░░░░
░░░░░░░░░░▒▒▒▒██░░░░░░░░░░░░░░░░░░░░░░░░░░██████████░░░░░░░░
░░░░░░░░░░▒▒▒▒▒▒██░░░░░░░░░░░░░░░░░░░░░░▒▒████████▒▒░░░░░░░░
░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░░░░░░░░░░░░░░░░░░▒▒▒▒████▒▒▒▒░░░░░░░░
░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒████░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░
░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████░░░░░░░░░░░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░
░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░
░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░
░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░
░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██████████████████▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░
░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░░██▒▒▒▒▒▒▒▒░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
38
Name:
Anonymous
2007-04-19 18:23
ID:7c7yA9iO
>>37
that doesn't look like a duck to me... and i doubt it quacks like one either...
39
Name:
Anonymous
2007-04-20 9:03
ID:L41CZWK3
>>36
'tis a great challenge!
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.
If you are lucky, it might look good right away!
40
Name:
Anonymous
2007-04-20 9:45
ID:1CwSmVRF
>>38
Are ducks touring-complete?
Newer Posts