Random Tome -- sourceforge download

All new ideas for the upcoming releases of ToME 4.x.x should be discussed here

Moderator: Moderator

Message
Author
asthmatic_thematic
Higher
Posts: 79
Joined: Tue Aug 19, 2008 7:15 pm

Random Tome -- sourceforge download

#1 Post by asthmatic_thematic »

Here is the source code to generate the wilderness for RandomTome--it's simply Tome, with a randomized wilderness West. Rel, the Far East, etc., are unchanged. It works for mac and unix; the same stuff should work with a pc, if you have a compiler like gcc. I've played some medium-long games on it; but I haven't verified that one can, for example, win the entire game using the random map.

All the files are available at SourceForge.
http://sourceforge.net/projects/infiwild/files/

There is compiling required... Download all the files under infiwild; put them in the same directory. (Some place where some spewed out side-files won't bother you.) Use a terminal to go to that directory, and then type
./run.bsh

[update: see below: I've simplified everything, so you just need the files at infiwild, and then simply type g++ world22.c. at a terminal to generate the executable, and then run it. also you can place the file eyal-2 below INSIDE the files of your tome application ("view contents" of package), so there's no need to recompile tome.]

This will generate a file eyal-2.lua (along with other stuffing). (In the off-chance it freezes, just ctrl-c and restart--it does that once every twenty times or so, due to difficulties placing certain sites I'm still working on.) Go to the t-engine directory:
game/modules/tome/data/maps/wilderness/
and rename the file eyal.lua to something like eyal.original, and move the file eyal-2.lua into that directory, and rename it eyal.lua.

Then compile tome.

Run it, and you should be able to play about as normal; you'll just need to explore to find things.

Please let me know, under these comments or in my message box here at the Tome forums, if you have any problems compiling or running.

The immediate future is improving this a bit--what other requirements are needed to make the gameplay run roughly as it does without randomization? A list of current structural requirements is below. Then, the next step is to simplify and elegantify the program, and convert it as much as possible to lua.

Thanks, all!

---
(all these have default requirements of being accessible from derth, unless otherwise stated.)

(((spots and zones)))
"reknor") near iron council
"lumberjack-town") near woods
"telmur")
"antimagic")
"angolwen") inaccessible in mountains
"angolwen-portal") near angolwen
"last-hope") medium-far from derth
"iron-throne") in mountains
"demon-plane-arrival")
"zigur")
"shertul-fortress")
"halfling-ruins")
"tempest-peak") inaccessible in mountains

(((playerpops)))
"allied") trollmire
"dwarf") reknor
"shaloren") scintillating camp
"low-undead")

"lumberjack-cursed") near lumberjack town
"angolwen") (see angolwen)
"infinite-dungeon") random locations
"mark-spellblaze")

(((dungeons etc)))
"derth"); central; plains or low hills
"trollmire"); near derth
"maze"); medium distance from derth
"old-forest"); near derth; woods or forest
"sandworm"); in desert
"dreadfell"); medium far from derth
"daikara"); in north, at edge of mountains
"halfling-ruins");
"kor-pul"); medium-short distance from derth
"last-hope"); medium-far from derth
"shatur"); inaccessible in forest
"elvala"); in woods
"angolwen"); (see angolwen)
"angolwen-teleport"); (see angolwen)
"scintillating-caves"); near elvala
"rhaloren-camp"); near elvala
"zigur");
"iron-council"); in mountains
Last edited by asthmatic_thematic on Fri Mar 25, 2011 12:46 pm, edited 5 times in total.

asthmatic_thematic
Higher
Posts: 79
Joined: Tue Aug 19, 2008 7:15 pm

Re: Random Tome -- sourceforge download

#2 Post by asthmatic_thematic »

Two screenshots: an old-fashioned ascii map, and a typical gameplay shot. The sandworm lair and oldforest shown: i use the flower graphic for woods, since i don't have a woods graphic yet. I also am using cold forests and palm forests and a few other things on the wilderness map.

There are still a few oddities: eg, in the upper right hand corner, the "a" in the mountains is angolwen, while the "a" a short ways away, accessible is the teleporter. Angolwen is inaccessible because it's in the mountains, and on the seaside; more like a resort than a hidden valley. Hmmm. If this bothers anyone I can change it.
Screen shot 2011-03-21 at 12.25.04 AM.png
Screen shot 2011-03-21 at 12.25.04 AM.png (57.82 KiB) Viewed 5317 times
Screen shot 2011-03-21 at 12.24.41 AM.png
Screen shot 2011-03-21 at 12.24.41 AM.png (246.74 KiB) Viewed 5317 times

Goblinz
Module Developer
Posts: 163
Joined: Tue Dec 14, 2010 3:23 am
Location: Where I need to be

Re: Random Tome -- sourceforge download

#3 Post by Goblinz »

I am having trouble compiling the down loaded files. I am using Win 7 and non of the cmd commands work. start run.bsh just prompts me for what service I would like to use to open the file. If you know window commands that would allow me to compile that would be great
Those who complain are just Volunteering to fix the problem

<yufra> every vault designer should ask themselves exactly that: What Would Grey Do?

Mithril
Archmage
Posts: 327
Joined: Fri Oct 01, 2010 5:43 pm

Re: Random Tome -- sourceforge download

#4 Post by Mithril »

Great news :D Hoping for a windows .exe for us illiterates...

Freddybear
Wyrmic
Posts: 201
Joined: Wed Dec 06, 2006 6:58 pm
Location: Mordor, Ohio

Re: Random Tome -- sourceforge download

#5 Post by Freddybear »

I would suggest building a make file for your project, and putting all the files into a zip archive on sourceforge.

By default, MinGW puts executables in a.exe instead of a.out. It's generally better to specify the executable name in the gcc command.

asthmatic_thematic
Higher
Posts: 79
Joined: Tue Aug 19, 2008 7:15 pm

Re: Random Tome -- sourceforge download

#6 Post by asthmatic_thematic »

Freddybear is totally right. I'll try to make a generic makefile, and then anyone with terminal-type control and the make command can compile this easily. That would take care of Goblinz's issue, so long as he has a pc equivalent of make and a c compiler.

I have a stupid question. My main program obviously is in c; but the data it spits out is just a lua file. Clearly the executables DG distributes have everything built into them. But can't one use the data files under the modules folder in lua interpreted mode, so one wouldn't need to recompile...? Is everything compiled right now, and nothing interpreted, unless one is running Tome directly under lua?

The way to half-help Mithril would be to combine the stupid sub-programs of the bash shell into a single program. (They're broken up solely for postprocessing ease, so I can use c++ (for its string routines) in only a small part of the project.) Then one could compile, and put a windows exe up on sourceforge. But this would still require recompiling Tome once the output of the exe file is generated, unless one was just interpreting rather than compiling the files.

More in a bit.

Freddybear
Wyrmic
Posts: 201
Joined: Wed Dec 06, 2006 6:58 pm
Location: Mordor, Ohio

Re: Random Tome -- sourceforge download

#7 Post by Freddybear »

The lua files are not compiled into the t-engine executable. T-engine calls the lua interpreter.
But the t-engine is a generic generic game engine, all the ToME4 game-specific code is in the lua language, which is probably why Darkgod wants the ToME world generator to be in lua too.

PhoenixToME
Cornac
Posts: 42
Joined: Sun Mar 06, 2011 10:24 am
Location: Dying like a moron somewhere.

Re: Random Tome -- sourceforge download

#8 Post by PhoenixToME »

The idea sounds interesting and hopefully a good start for a completely random tome, if that's possible. I mean random dungeons (random name & content), random bosses, random towns.

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Random Tome -- sourceforge download

#9 Post by darkgod »

Yeah no recompilation needed since it's all in lua :)

I fixed run.bsh to compile the first gcc line with "-lm" because it requires explicit linking to the math lib on my gentoo.

The output is starting to look really nice I must say!
It's a real shame it aint in lua I so want to add it to generate other random planets :/

*THE* ultimate thing you could do would be to make it in lua and able to take rules and let it generate a world.
Like you could say I want:
- those 5 towns
- those 18 dungeons, some of which must be clsoe to some of those towns
- not much plains
- lots of forests
- ...

If you do not want to convert it to lua maybe if you make it *very* generic it can be included in the core and thus be still usable by all modules
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

asthmatic_thematic
Higher
Posts: 79
Joined: Tue Aug 19, 2008 7:15 pm

Re: Random Tome -- sourceforge download

#10 Post by asthmatic_thematic »

I've just incorporated all the stupid little files into the main file, and deleted the shell script. The structure is so simple now that not even a make file is necessary. The changes are available on sourceforge under the same project and link above, infiwild.

So now there is only one main program: worldXX.c (where currently XX is 22). There are two included c files: dmnd-square and astarlibrary. There are two text files: brack21 (which I generate using emacs from the original ascii map), and eyal_unchanged, which has all the original eyal.lua file info which we still need.

So, just get those five files, put them in the same directory, and compile world22.c using this command:

Code: Select all

    g++ world22.c
(or whatever your c++ compiler is). You may need to run "g++ -lm world22.c" to force the math libraries to link, as DG notes.

Then do what I suggested above (run the resulting executable, and move eyal-2.lua into the tome maps wilderness folder). This is largely independent of platform now, so as long as you have a c++ compiler, you are good to go. (Only five lines of code actually use c++ in any event.)

I forgot to mention the major improvement over the last random wilderness release. The new version actually places the mountains more carefully so that adventuring through Eyal is much more fun: the mountains almost form corridors, and things naturally get hidden in valleys and around corners. This careful placement of mountains actually makes the terrain *less* realistic outside of tome, so it's just an option (GRID_MTNS, I think), but it's turned on currently. Another random world snapshot is below: the ruined dungeon is shown, along with the apprentice mage. I can't see Angolwen, but by cheating and looking at the map output of the program, the entrance is actually tucked up in the valley in the upper right, and Angolwen is a bit off the screen to the right, in higher mountains. (The mage is set to show up within 15 path moves of the Angolwen teleporter.)

Thanks for the comment, Freddybear, about the interpreter. I finally got around to looking inside the downloadable mac executable app. When one right clicks (or ctrl clicks or command clicks or whatever), and chooses "show contents of package", one can go to resources/games/modules to find the lua files. I assume the lua resources are similarly hidden on PCs. So one need not actually recompile tome to use the random wilderness. But one does need to compile worldXX.c.

If there is a big demand, I can put up on sourceforge a mac executable of worldXX.c, and try to get someone to put up a windows executable.
Screen shot 2011-03-22 at 12.56.26 PM.png
Screen shot 2011-03-22 at 12.56.26 PM.png (211.62 KiB) Viewed 5220 times
Last edited by asthmatic_thematic on Tue Mar 22, 2011 2:45 pm, edited 1 time in total.

asthmatic_thematic
Higher
Posts: 79
Joined: Tue Aug 19, 2008 7:15 pm

Re: Random Tome -- sourceforge download

#11 Post by asthmatic_thematic »

Hmm, I hadn't seen DarkGod's message when I posted...somehow he ninja'd me.

DarkGod, here's my very rough plan for converting to lua.

(1) Learn more about lua.
(2) Change c program to have a struct which carries all needed info (eg world.terrain[x][y]).
(3) Subroutinize terrain formation, passing just struct--eg MakeMountains(world).
(4) Learn more about lua again.
(5) With this better struct arrangement, convert subroutines one by one to lua, making sure results stay good.
(6) Convert the remaining main() to lua, which includes the output fprintf eyal.lua creating code.

Does that seem like a reasonable plan? My vague impression is that lua is better for scripting-type work--I know that's true by definition, sort of, but I mean coding that's more interactive rather than data intensive. I'm not sure how well conversion is going to work, since a lot of the current code is pretty data-heavy, but I think I'm willing to give it a try. Unless--is it actually *better* to make it generic and keep it in c?...?

...?

Still need some more tiles--especially for woods, so it doesn't look like the player is tripping through daisies. I also think we need graduated mountain tiles--so low hills, hills, mountains, and peaks all have different levels of ferociouslookingness. And we could also do the same thing with these mountain tiles that you currently do with trees--ie have ten different types which are used randomly. But that's not so important right now, I guess.

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Random Tome -- sourceforge download

#12 Post by darkgod »

neat!

Please get on irc #tome on irc.rizon.net and let's talk world generation :)
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Random Tome -- sourceforge download

#13 Post by Grey »

Having this available to modules would be very cool.
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

asthmatic_thematic
Higher
Posts: 79
Joined: Tue Aug 19, 2008 7:15 pm

Re: Random Tome -- sourceforge download

#14 Post by asthmatic_thematic »

So here's my idiotic very first step to the luafication process--on the level of "hello world". I'm going to do it as a standalone lua thingum for now, and make it pretty concrete, and then abstractifying it and integrating into the t-engine shouldn't be too hard. The last step will be taking instructions from a list that looks like
* town 'elvala' forest north
* town 'shatur' hills near:'elvala'
* dungeon 'scintillating-caves' far:'elvala'
or whatever is easiest to parse.

Current questions:
(1) what is the best way to do arrays for this? As userdata from c, or by just initializing a 2d table, as below?
(1b) How do I get the diamond-square fractal data into the lua array using my d-s c function, using answer from (1)?
(2) how can I temporarily incorporate the rng module t4 uses into the standalone--where do i need to stick something like "require rng" here, and what files do i need? (i'll need to eventually incorporate aStar into the standalone, too.)
(3) longer term, for integration with t4, what is _M ?

I have a simple c wrapper and error catcher around the following lua:

-- simple test

function mountains(x)
print (x[5][4]+6)
-- need rng here
end

print "hello world"

SIZE = 32

w = SIZE
h = SIZE

elev = {}
for i = 1, w do
elev = {}
for j = 1, h do
elev[j] = i*j^2
end
end

print (elev[5][4])

-- get fractal data in here

mountains(elev)

-- then do all sorts of other terrain stuff here
-- then do aStar placing of sites here

Sorry for basicness of questions, but this is my first foray into lua...

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Random Tome -- sourceforge download

#15 Post by darkgod »

Getting dmdnsquare & rng libs outside of T4 will be annoying.
Your easiest way is to simply hijack game/loader/pre-init.lua and put your code there for testing and do "os.exit()" at the end.
Then when you run tome it'll just run your script and quit.

(1) tables are very fine
(3) when making a class, _M references the current class. So function _M:foo() jsut means to make a method named foo for the current class.

As for (later) defining rules, that's the beauty of lua, you wont have to, just have them defined as lua data, like all other game data and you dont even need to parse it ;)
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Post Reply