×

Langue

Fermer
Atelier 801
  • Forums
  • Dev Tracker
  • Connexion
    • English Français
      Português do Brasil Español
      Türkçe Polski
      Magyar Română
      العربية Skandinavisk
      Nederlands Deutsch
      Bahasa Indonesia Русский
      中文 Filipino
      Lietuvių kalba 日本語
      Suomi עברית
      Italiano Česky
      Hrvatski Slovensky
      Български Latviešu
      Estonian
  • Langue
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Script] Random Map Generation
1 / 2 › »
[Script] Random Map Generation
Mikuhl
« Citoyen »
1382993520000
    • Mikuhl#3311
    • Profil
    • Derniers messages
    • Tribu
#1
  0
This is something I made quite a while ago when Lua was first released in Tribe Houses. Probably not the cleanest of code but it is quite cool. I prettied it up a bit and decided to release it.

https://paste.moepl.eu/view/6b511c52

a dit :
coord_x = {40, 80, 120, 160, 200, 240, 280, 320, 360, 400,
440, 480, 520, 560, 600, 640, 680, 720, 760}
coord_y = {80, 120, 160, 200, 240, 280, 320, 360}
wide_height = 40
wide_length = {120, 160, 200}
tall_height = {120, 160, 200}
tall_length = 40
theme_1 = {5, 6}
theme_2 = {1, 2}
theme_3 = {0, 4}
theme_4 = {10, 11}
theme_5 = {7,9}
theme_6 = {12}

tfm.exec.disableAutoNewGame(true)
map = {}

function newMap()
if place == 1 then
variation = 1
elseif place == amount then
variation = 1
else
variation = math.random(1,2)
end
if variation == 1 then
l = wide_length[math.random(#wide_length)]
h = wide_height
elseif variation == 2 then
l = tall_length
h = tall_height[math.random(#tall_height)]
end
x = coord_x[math.random(#coord_x)]
y = coord_y[math.random(#coord_y)]
if place == 1 then
cheese_x = x
cheese_y = y - 20
elseif place == amount then
hole_x = x
hole_y = y - 20
end
o = math.random(0x000000, 0xFFFFFF)
if theme == 1 then
t = theme_1[math.random(#theme_1)]
f = 0.3
r = 0.2
elseif theme == 2 then
t = theme_2[math.random(#theme_2)]
f = 0
if t == 1 then
r = 0.2
elseif t == 2 then
r = 1.2
end
elseif theme == 3 then
t = theme_3[math.random(#theme_3)]
r = 0.2
if t == 0 then
f = 0.3
elseif t == 4 then
f = 20
end
elseif theme == 4 then
t = theme_4[math.random(#theme_4)]
if t == 10 then
f = 0.3
r = 0
elseif t == 11 then
f = 0.05
r = 0.1
end
elseif theme == 5 then
t = theme_5[math.random(#theme_5)]
if t == 7 then
f = 0.1
r = 0.2
elseif t == 9 then
f = 0
r = 0
end
elseif theme == 6 then
t = theme_6[math.random(#theme_6)]
f = 0.3
r = 0.2
end

ground = "<S X='"..x.."' Y='"..y.."' L='"..l.."' H='"..h.."' T='"..t.."' P='0,0,"..f..","..r..",0,0,0,0' o='"..o.."' />"
table.insert(map, ground)
end

function newGame()
math.randomseed(os.time())
theme = math.random(1,6)
amount = math.random(5,10)
for loop = 1, amount, 1 do
place = loop
newMap()
end
tfm.exec.newGame("<C><P Ca='' F='"..math.random(0,5).."'/><Z><S>"..table.concat(map, "").."</S><D><F X='"..cheese_x.."' Y='"..cheese_y.."' /><T X='"..hole_x.."' Y='"..hole_y.."' /></D><O></O></Z></C>")
tfm.exec.setUIMapName("")
map = {}
end

function eventLoop(currentTime, timeRemaining)
for name,player in pairs(tfm.get.room.playerList) do
local alive = 0
if player.isDead == false then
alive = alive + 1
end
if alive == 0 then
newGame()
end
end
if timeRemaining <= 0 then
newGame()
end
end

newGame()

A lot is defined in the beginning so you can configure it however you like.
You will might also notice that sometimes the hole is covered up. As of now I don't know of any simple way to fix it.
Safwanrockz
« Censeur »
1382994660000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#2
  0
Amg, it seems really complex to make ;o Will try it once I get on tfm~
e/ I suggest copying the code either to pastebin or paste.moepl, because it can't be fully copied from here :x
Jsilv
« Citoyen »
1382994900000
    • Jsilv#0000
    • Profil
    • Derniers messages
#3
  0
Ctrl + A ^^
Mikuhl
« Citoyen »
1382996460000
    • Mikuhl#3311
    • Profil
    • Derniers messages
    • Tribu
#4
  0
Safwanrockz a dit :
I suggest copying the code either to pastebin or paste.moepl, because it can't be fully copied from here

Is this some mac problem or something? I can fully copy it.

This is why you dont buy macs people.
Mousechris
« Censeur »
1382996700000
    • Mousechris#0000
    • Profil
    • Derniers messages
    • Tribu
#5
  0
Jsilv a dit :
Ctrl + A ^^

Ctrl + A also copys everything else in his post
Jsilv
« Citoyen »
1382997840000
    • Jsilv#0000
    • Profil
    • Derniers messages
#6
  0
Mousechris a dit :
Ctrl + A also copys everything else in his post

Then you delete it :p
That's what I did anyway.
Mikuhl
« Citoyen »
1382998500000
    • Mikuhl#3311
    • Profil
    • Derniers messages
    • Tribu
#7
  0
I added a link for you people who dont know how to use scroll wheels.
Jsilv
« Citoyen »
1382998620000
    • Jsilv#0000
    • Profil
    • Derniers messages
#8
  0
Jaackster a dit :
I added a link for you people who dont know how to use scroll wheels.

Trackpad though pls
Xxninjazxx
« Citoyen »
1383004260000
    • Xxninjazxx#0000
    • Profil
    • Derniers messages
#9
  0
Jsilv a dit :
Trackpad though pls

wireless mouse please

Also this can make impossible maps....
Mikuhl
« Citoyen »
1383005040000
    • Mikuhl#3311
    • Profil
    • Derniers messages
    • Tribu
#10
  0
Xxninjazxx a dit :
Also this can make impossible maps....

Yeah. Not sure how to overcome this without doing advanced length and width checks. :/
Theleetcoder
« Citoyen »
1383011700000
    • Theleetcoder#0000
    • Profil
    • Derniers messages
    • Tribu
#11
  0
So cool. *-*
This script demonstrate it possible to "interract" with xml code with lua.
The *#labyrinth room too.
Shamousey
« Consul »
1383012960000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#12
  0
Theleetcoder a dit :
So cool. *-*
This script demonstrate it possible to "interract" with xml code with lua.
The *#labyrinth room too.

Of course it's possible anyway, it's just string manipulation! However #labyrinth doesn't really use any XML, it uses conjuration. #derby has a great example of random map generation, most of the maps played there are generated on-the-spot.
Theleetcoder
« Citoyen »
1383013200000
    • Theleetcoder#0000
    • Profil
    • Derniers messages
    • Tribu
#13
  0
Shamousey a dit :
Of course it's possible anyway, it's just string manipulation! However #labyrinth doesn't really use any XML, it uses conjuration. #derby has a great example of random map generation, most of the maps played there are generated on-the-spot.

:go to #derby:
EDIT: Maps are really Lua generated?! O.0
Shamousey
« Consul »
1383013860000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#14
  0
Theleetcoder a dit :
:go to #derby:
EDIT: Maps are really Lua generated?! O.0

(This may be getting a bit off-topic considering it's not related to the map generator posted in the OP).

Some maps are generated in #derby, some are user made. You can use /info to find out. Maps like this were generated.
Xanmeow
« Citoyen »
1383089760000
    • Xanmeow#0000
    • Profil
    • Derniers messages
    • Tribu
#15
  0
can you disable shaman please? when I try to do the disable shaman thing I just break it >.<
Xrstilo
1383091560000
    • Xrstilo#0000
    • Profil
    • Derniers messages
    • Tribu
#16
[Modéré par Shamousey, raison : Spam post.]
Theleetcoder
« Citoyen »
1383092820000
    • Theleetcoder#0000
    • Profil
    • Derniers messages
    • Tribu
#17
  0
Shamousey a dit :
(This may be getting a bit off-topic considering it's not related to the map generator posted in the OP).

Some maps are generated in #derby, some are user made. You can use /info to find out. Maps like this were generated.

Wow, nice algorythm *-*.
Off Topic: I'm trying to make my own map generator with Javascript and Html5 canvas to display the final map. :)
Grimrice
« Citoyen »
1386035700000
    • Grimrice#0000
    • Profil
    • Derniers messages
    • Tribu
#18
  0
error i found
Elmikle
« Consul »
1409502060000
    • Elmikle#0000
    • Profil
    • Derniers messages
    • Tribu
#19
  0
Wow! It is too awesome!
Jojololly
« Citoyen »
1409569020000
    • Jojololly#0000
    • Profil
    • Derniers messages
#20
  0
My mac can copy basically unlimited amounts of things o.o
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Script] Random Map Generation
1 / 2 › »
© Atelier801 2018

Equipe Conditions Générales d'Utilisation Politique de Confidentialité Contact

Version 1.27