Page 1 of 1

The Coolness of Being Random

PostPosted: Sat Jun 15, 2013 15:04
by cypher-neo
On this one RPG game I play with friends, my friends nicknamed me "The Lord of Chaos", because when I sense that I'm losing I become completely random, making illogical moves just for fun and to watch my friends pull their hair out when their well-thought-out plans suddenly derail.

I kind of did the same thing with Minetest, just for fun. And it turned out to be really cool!

Let me explain.

One of the fundamental assumptions of Minetest is that better pickaxes always mine faster. So steel will always mine faster than wood, and mese than steel.

I was playing around with LUA the other night, and just for fun, I made it all random...

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
-- Initialize the Psuedo-random generator
math.randomseed( os.time() )
RANDOMWOOD = math.random()
RANDOMSTONE = math.random()
RANDOMSTEEL = math.random()
RANDOMMESE = math.random()
RANDOMDIAMOND = math.random()
RANDOMOBSIDIAN = math.random()


Then in the code for the pickaxes, I modified the digging times to (x^y) where x is a long time (but incrementally shorter for each higher range of pick - so wood has the longest increment of 50, but mese has an increment of 25). This doesn't necessarily mean mese is faster though. So for example, a wood pick...

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
minetest.register_tool("random:pick_wood", {
    description = "Wooden Pickaxe",
    inventory_image = "default_tool_woodpick.png",
    tool_capabilities = {
        full_punch_interval = 1.2,
        max_drop_level=0,
        groupcaps={
            cracky = {times={[3]=50^RANDOMWOOD}, uses=10, maxlevel=1},
        },
        damage_groups = {fleshy=2},
    },
})


And a mese pick looks like this!

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
minetest.register_tool("random:pick_mese", {
    description = "Mese Pickaxe",
    inventory_image = "default_tool_mesepick.png",
    tool_capabilities = {
        full_punch_interval = 0.9,
        max_drop_level=4,
        groupcaps={
            cracky = {times={[1]=40^RANDOMMESE, [2]=30^RANDOMMESE, [3]=20^RANDOMMESE}, uses=20, maxlevel=3},
        },
        damage_groups = {fleshy=5},
    },
})


So, how does this affect the game?
Well, here's how it works. A Pseudo-random seed is generated every time you open a Minetest world that uses this mod. This seed in turn generates new random numbers, and those in turn affect the speed of the pick.

Now this makes Minetest a little more interesting, because instead of a mad dash to get the best pick at the beginning of the game, you have to experiment with each type of pick to determine which is the best. Sometimes, wood picks will be amazingly fast, but mese picks slow. Sometimes steel is like greased lightning, and sometimes steel takes 30 seconds to mine a node. It's all variable!

So the question is, if wood is like greased lightning, will you use wood picks even though they don't last long? Or will you take your time and use other pick types because they can mine more nodes even though they may be slower?

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
math.randomseed( os.time() )

And if you close the game, it experimentation starts over... Because the pseudo-random number is based on the OS time of the computer, every time you open a Minetest world that uses this mod, the pick times change! Which means you need to experiment again. LOL!

I love being random.

If anyone wants a copy of this mod, let me know...

PostPosted: Sat Jun 15, 2013 16:12
by sfan5
What about something real random:
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
$ hd /dev/random
00000000  b5 1c 78 0c ce a9 bb 53  a0 e6 51 be 9e d1 b2 ce  |..x....S..Q.....|
00000010  0e 11 87 74 9c 22 92 24  5b 2d 68 14 03 c9 af 13  |...t.".$[-h.....|
00000020  96 42 85 30 5f e8 ba 37  31 10 f5 19 f3 23 f8 90  |.B.0_..71....#..|
00000030  38 c0 b3 af a5 b0 d4 d4  f7 77 50 4c d5 c0 ea ab  |8........wPL....|
00000040  88 06 c2 f0 9b bf 5e b8  0e a9 07 cc a6 d0 0d b9  |......^.........|
00000050  a3 db 65 dd 1b a7 09 f8  d7 01 f0 03 5c 53 6b 49  |..e.........\SkI|
00000060  eb ce bb 52 9d bc a7 fb  88 f9 eb ca 2b e8 5e 1e  |...R........+.^.|
00000070  80 e4 8e 5e ea 0a e5 bb  17 05 64 8a ac 5b 86 6c  |...^......d..[.l|
00000080  1c a8 30 aa c9 19 63 fc  25 45 23 3b 1f 3d 51 e9  |..0...c.%E#;.=Q.|
00000090  5c 4a 7a f1 1c 3e 7b 7a  de e8 42 d4 08 4e ef 4c  |\Jz..>{z..B..N.L|
000000a0  18 d3 26 35 f0 5d ac 98  7d a5 9c 4a 87 58 f5 b7  |..&5.]..}..J.X..|
^C

</troll>
Nice Idea, would be an interesing challenge to play the game when everything mines slowly..

PostPosted: Sat Jun 15, 2013 16:16
by jmf
Carot juice is propietary.
EDIT: Although the GNU guys made a nice, free/libre replacement

PostPosted: Sat Jun 15, 2013 16:32
by PilzAdam
builtin already does math.randomseed(os.time()), you dont have to do it again.

PostPosted: Sat Jun 15, 2013 17:14
by tinoesroho
Sounds like a hoot- I'd love to play it on my LAN server.

PostPosted: Sat Jun 15, 2013 22:26
by cypher-neo
sfan5 wrote:What about something real random:
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
$ hd /dev/random
00000000  b5 1c 78 0c ce a9 bb 53  a0 e6 51 be 9e d1 b2 ce  |..x....S..Q.....|
00000010  0e 11 87 74 9c 22 92 24  5b 2d 68 14 03 c9 af 13  |...t.".$[-h.....|
00000020  96 42 85 30 5f e8 ba 37  31 10 f5 19 f3 23 f8 90  |.B.0_..71....#..|
00000030  38 c0 b3 af a5 b0 d4 d4  f7 77 50 4c d5 c0 ea ab  |8........wPL....|
00000040  88 06 c2 f0 9b bf 5e b8  0e a9 07 cc a6 d0 0d b9  |......^.........|
00000050  a3 db 65 dd 1b a7 09 f8  d7 01 f0 03 5c 53 6b 49  |..e.........\SkI|
00000060  eb ce bb 52 9d bc a7 fb  88 f9 eb ca 2b e8 5e 1e  |...R........+.^.|
00000070  80 e4 8e 5e ea 0a e5 bb  17 05 64 8a ac 5b 86 6c  |...^......d..[.l|
00000080  1c a8 30 aa c9 19 63 fc  25 45 23 3b 1f 3d 51 e9  |..0...c.%E#;.=Q.|
00000090  5c 4a 7a f1 1c 3e 7b 7a  de e8 42 d4 08 4e ef 4c  |\Jz..>{z..B..N.L|
000000a0  18 d3 26 35 f0 5d ac 98  7d a5 9c 4a 87 58 f5 b7  |..&5.]..}..J.X..|
^C

</troll>


LMAO!

PostPosted: Sat Jun 15, 2013 22:46
by Jordach
hd /dev/urandom
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
 no idea on the output.

PostPosted: Sun Jun 16, 2013 00:15
by tinoesroho
You guys are doing it all wrong. Want something truly random? Noise from space. Problem is, you'll need an SDR card to capture it, but hey.

I would, though, like to play it.

PostPosted: Mon Jun 17, 2013 00:27
by cypher-neo
tinoesroho wrote:I would, though, like to play it.


I'll zip you up a copy and post it, with complete directions.

PostPosted: Mon Jun 17, 2013 05:48
by tinoesroho
Sounds sweet, cowboy. :-)

PostPosted: Wed Jun 19, 2013 17:24
by cypher-neo
cypher-neo wrote:
tinoesroho wrote:I would, though, like to play it.


I'll zip you up a copy and post it, with complete directions.


Anyone who wants to play this game... the game was released at http://forum.minetest.net/viewtopic.php?pid=95609#p95609