Temperature system, with heat transfer between nodes

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Temperature system, with heat transfer between nodes

by MirceaKitsune » Mon Jun 17, 2013 13:46

I've been thinking about a system that would allow a lot of interesting things to be possible. What if various areas of the world could have temperatures registered to them? Even better, individual nodes influenced by the environment. Temperatures would depend on several factors of influence like in real life.

The heat and humidity of biomes would play a primary role in setting the default air temperature of an area, although there would be other factors as well. Height would be one, while seasons and meteorological conditions another. Then we could have objects that generate heat, such as working furnaces or fire... which can be used to warm up closed spaces.

There are a lot of things temperature values would be useful for. Those are a few I can think of:

- First of all, this would be required for a weather system. We'd want no weather in overly hot areas, rain in warm areas, snow in cold ones. Temperatures at cloud height should also influence *when* weather happens, not just what type of weather it will be.

- Temperatures cause various materials to act differently. In Minetest, this means some nodes would morph into other nodes. Water should morph into ice when it's too cold and vanish away when too hot. Leafs should also account temperature; Normal leafs when temperature is normal, dry leafs when it's too cold or hot, dead leafs when it's extremely cold or hot. Food can get rotten if the chest it's left in is too hot. Taking the idea further, even stone can melt into lava at ludicrous heat, end every node can get covered in ice at insane cold.

- Heat can influence the player. If temperatures in an area are extremely cold (to unnatural amounts) the player will gradually lose health. If it's insanely hot, the player will catch fire. Distance fog could also be changed to reflect temperature and give a feel to the player (blue-ish fog when it's cold, red-ish fog when it's hot, white-ish fog at normal temperatures).

- We could have mobs or other entities that only spawn and survive at some temperatures, regardless of biome.

Next question is how and where to implement such a system. It could be done either in C++ (possibly faster but less flexible) or Lua (possibly slower but easier to work with). Then how should we actually do it? If we are to go all the way, temperature should be an individual node property (meta option). Such would allow for realistic temperature transfer between nodes, and each node would have a property as to how quickly it absorbs heat from neighboring nodes. Heat could be passed through walls, fires could be used to warm up rooms in cold biomes, and much more. This would be totally awesome! Only question is how much CPU such a system would use when thousands of nodes are loaded and transferring heat between each other.

Personally I vote for doing this in Lua, depending on how fast it would be. Temperature transfer can be updated every few seconds so it might not be a big issue. If done in Lua, I might be able to get started on the system myself. But first I'd like to hear what the other devs think and if they'd agree to adding something like this in minetest_game.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Mon Jun 17, 2013 14:14

I was thinking about this as well. It would be possibly better and faster to do this per X/Z rather than per node (X/Y/Z), so it is the surface temperature.

This could be easy to do, but not easy to do in a way that is cpu efficient.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Jun 17, 2013 14:28

rubenwardy wrote:I was thinking about this as well. It would be possibly better and faster to do this per X/Z rather than per node (X/Y/Z), so it is the surface temperature.

This could be easy to do, but not easy to do in a way that is cpu efficient.


Wouldn't work out for how I want to do this (realistic temperature transfer).

I am however thinking of a way that could prevent having to run register_abm for each node. If we consider that two nodes touching each other are transferring heat, there's no need for both to execute the same code, since one gives / takes heat anyway. So the abm can be registered once every 4 nodes, accounting that each node running the code checks every neighbor including diagonals.

######
#$##$#
###### ($ = nodes with register_abm, # = neighbor nodes that run no code)

Problem is that then some neighbors would only transfer heat to others, on a 2 x 2 basis. So instead we'd need 2 node pauses like this:

#####
#$#$#
#####

Anyway I'll see how it works out when I get to it... and especially how fast it's going to be if fully done in Lua.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Mon Jun 17, 2013 14:45

ABMs are definitely not good for calculating heat.

Mapgen v7 has a heat perlin noise. Grab this perlin noise and take it as a base for your heat calculation.
Add on_place() and on_dig() callbacks to nodes that emit heat (furnaces, torches, lava) where you set a "heat_add" value in metadata of nodes in a certain radius. When calling get_temperature(pos) add this value to the base perlin noise.
Additionally you can increase/decrease the value a bit based on daytime if you are above y=0.

Some pseudo code to explain my idea better:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function get_temperature(pos)
    local heat = heat_perlin(pos)
    heat = heat+meta(pos):get_value("heat_add")
    if pos.y >= 0 then
        if night then
            heat = heat -10
        end
    end
    return heat
end


Snow could run an ABM that checks if the heat is too high, and remove itself.
Flowers and grass can turn into dry_shrub.
The player could get damage if its too cold and move slower if its too warm.
 

User avatar
cornellius
Member
 
Posts: 82
Joined: Sat Dec 01, 2012 05:08

by cornellius » Mon Jun 17, 2013 14:52

LOL i think Temperature system is too hard even minecraft don't have anything about temperature
All Humans Need Is Forgiveness, God Is The First One Who Forgive All Humans So Humans Must Forgive Other Humans
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Mon Jun 17, 2013 15:00

cornellius wrote:LOL i think Temperature system is too hard even minecraft don't have anything about temperature

ಠ_ಠ
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Mon Jun 17, 2013 15:29

maybe you could start off with the same behaviour of all nodes, defining the behaviour through lua later? more than that, wouldn't the temperature stuff work more or less similiar to light stuff?
 

User avatar
Dan Duncombe
Member
 
Posts: 904
Joined: Thu May 09, 2013 21:11

by Dan Duncombe » Mon Jun 17, 2013 16:10

If you do do it make it a gamemode in itself, then it would be even easier to decide between 'today I want to play with temperature on!' and 'today I want to play with temperature off!'
Some Mods: Castles Prefab Camouflage
My Games: Nostalgia Realtest Revamped
Servers: See above games.
 

User avatar
mauvebic
Member
 
Posts: 1550
Joined: Fri Jan 27, 2012 11:32

by mauvebic » Mon Jun 17, 2013 17:15

I worked on something similar back when biomes were ridiculously small - though i gave it up when i saw the new mapgen would have humidity values of it's own.

I dont know if the current mapgen distributes biomes according to heat/humidity values (ill bet no for now) but your first considerations should be how those values affect biomes, if those values change over time (ie, to produce desertification).

Before dropping my version of it, i had heat/humidity distributed circularly on the map, from hottest - desert at center (0,0,0), to frigid tundra at the map edges (x||z >= 30K). I figured that would encourage people to build out from center without venturing too close to map edges where things get buggy. If you're gonna use the mapgen values, it prolly wouldn't hurt to have a (weather) map of heat/humidity to see how theyre distributed and how they might interact.

Finally, you can't have heat/humidity without thinking about weather. Perhaps you might want to include values for barometric pressure and make use of jeija's rain/snow mod.
"Fuck the hat." - Paulie Gualtieri
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Jun 17, 2013 17:40

I thought of a better way to attempt this while away, which wouldn't require either register_abm or the set_meta / get_meta functions. I could use a Lua table containing other lua tables, of the form { pos_x, pos_y, pos_z, temperature } that would hold all loaded nodes. I can create a loop using minetest_after(5) which goes through the tables and slowly evens the values of all entries against their neighbors. That would prolly be the quickest way and performance decrease shouldn't even be noticeable.

But from what PilzAdam is saying about mapgen v7 having a perlin heat map, my idea might actually be pointless. Since that sounds accurate enough to do the bidding I wanted this idea to. This heat map should be possible to use for all my ideas (weather, water turning to ice, etc). Only use I believe my idea would still have then is to warm up houses in snow biomes. But at best, I will look into that when v7 is stable and I can take a closer look at its perlin heat.
Last edited by MirceaKitsune on Mon Jun 17, 2013 17:41, edited 1 time in total.
 

User avatar
mauvebic
Member
 
Posts: 1550
Joined: Fri Jan 27, 2012 11:32

by mauvebic » Mon Jun 17, 2013 18:10

If youre using the default heatmap then yeah your job just got real easy. Start off by writing a thermometer (like the handheld compass mod or something using hud) and start coming up with cases for different sets of values.

Though, these (presumably large) lua tables, how would you keep them in sync with the world as other players/mods make changes, without using more resources than an abm?
"Fuck the hat." - Paulie Gualtieri
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Jun 17, 2013 18:28

mauvebic wrote:If youre using the default heatmap then yeah your job just got real easy. Start off by writing a thermometer (like the handheld compass mod or something using hud) and start coming up with cases for different sets of values.

Though, these (presumably large) lua tables, how would you keep them in sync with the world as other players/mods make changes, without using more resources than an abm?


I was thinking of a thermometer too. Not as a HUD mod but an item, similar to how Minecraft has the compass and clock. Although Minetest doesn't support changing the graphics of hand held items yet, so maybe as a decoration instead.

Anyway, using the heat map temperature is easy to calculate at an accurate level without storing any list. Just combine it with the light value at that node, and offset to get a correct measurement unit (C* or F*). Only sunlight has the max_light value so we can determine if something is left in the sun which would add some extra heat. Light cast by torches can add a tiny amount of heat too.
Last edited by MirceaKitsune on Mon Jun 17, 2013 18:29, edited 1 time in total.
 

User avatar
mauvebic
Member
 
Posts: 1550
Joined: Fri Jan 27, 2012 11:32

by mauvebic » Mon Jun 17, 2013 19:49

Another possible value for air could be oxygenation that peaks at y=0 (or has a default 0 value for space maps). Then you'd need oxygen farms (trees) at high/low altitudes as well as heat.
"Fuck the hat." - Paulie Gualtieri
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Tue Jun 18, 2013 03:53

MirceaKitsune wrote:But from what PilzAdam is saying about mapgen v7 having a perlin heat map, my idea might actually be pointless. Since that sounds accurate enough to do the bidding I wanted this idea to. This heat map should be possible to use for all my ideas (weather, water turning to ice, etc). Only use I believe my idea would still have then is to warm up houses in snow biomes. But at best, I will look into that when v7 is stable and I can take a closer look at its perlin heat.

In a way there is already a heatmap, the snow mod is very popular and as far as i know VanessaE is using that heatmap in her mods? I used it in my fork of the jungletree mod to keep jungles away from snow biomes.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
--Snow biomes are found at 0.53 and greater perlin noise.
local perlin1 = env:get_perlin(112,3, 0.5, 150)

So it is actually a coldmap not a heatmap ;] Snow biomes above 0.53, so 0.53 is zero degrees celcius. Just set perlin1 = -1.5 to to be hot desert temp and set perlin1 = 1.5 to be extreme cold and you instantly have a heatmap running in mapgenV6.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

User avatar
Linxx
Member
 
Posts: 401
Joined: Wed May 16, 2012 00:37

by Linxx » Tue Jun 18, 2013 04:06

PilzAdam wrote:ABMs are definitely not good for calculating heat.

Mapgen v7 has a heat perlin noise. Grab this perlin noise and take it as a base for your heat calculation.
Add on_place() and on_dig() callbacks to nodes that emit heat (furnaces, torches, lava) where you set a "heat_add" value in metadata of nodes in a certain radius. When calling get_temperature(pos) add this value to the base perlin noise.
Additionally you can increase/decrease the value a bit based on daytime if you are above y=0.

Some pseudo code to explain my idea better:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function get_temperature(pos)
    local heat = heat_perlin(pos)
    heat = heat+meta(pos):get_value("heat_add")
    if pos.y >= 0 then
        if night then
            heat = heat -10
        end
    end
    return heat
end


Snow could run an ABM that checks if the heat is too high, and remove itself.
Flowers and grass can turn into dry_shrub.
The player could get damage if its too cold and move slower if its too warm.

what about using the empty bottles and being able to fill them up and heat them and being able to drink them to prevent cold and the same but just normal water for heat ...
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 2 guests

cron