The Coolness of Being Random

Post Reply
cypher-neo
Member
Posts: 46
Joined: Wed Oct 17, 2012 12:15

The Coolness of Being Random

by cypher-neo » Post

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...

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...

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!

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?

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...

sfan5
Moderator
Posts: 4095
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

What about something real random:

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..
Last edited by sfan5 on Sat Jun 15, 2013 16:12, edited 1 time in total.
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

jmf
Member
Posts: 164
Joined: Mon Nov 05, 2012 18:13
Location: Germany

by jmf » Post

Carot juice is propietary.
EDIT: Although the GNU guys made a nice, free/libre replacement
Last edited by jmf on Sat Jun 15, 2013 16:16, edited 1 time in total.
No longer active in minetest.

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

by PilzAdam » Post

builtin already does math.randomseed(os.time()), you dont have to do it again.

tinoesroho
Member
Posts: 570
Joined: Fri Feb 17, 2012 21:55
Location: Canada

by tinoesroho » Post

Sounds like a hoot- I'd love to play it on my LAN server.
We are what we create.

I tinker and occasionally make (lousy) mods. Currently building an MMO subgame and updating mods. Pirate Party of Canada member. Sporadic author. 21 years old.

My github:
https://github.com/tinoesroho/

cypher-neo
Member
Posts: 46
Joined: Wed Oct 17, 2012 12:15

by cypher-neo » Post

sfan5 wrote:What about something real random:

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!

Jordach
Member
Posts: 4534
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach
Location: Blender Scene

by Jordach » Post

hd /dev/urandom

Code: Select all

 no idea on the output.

tinoesroho
Member
Posts: 570
Joined: Fri Feb 17, 2012 21:55
Location: Canada

by tinoesroho » Post

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.
We are what we create.

I tinker and occasionally make (lousy) mods. Currently building an MMO subgame and updating mods. Pirate Party of Canada member. Sporadic author. 21 years old.

My github:
https://github.com/tinoesroho/

cypher-neo
Member
Posts: 46
Joined: Wed Oct 17, 2012 12:15

by cypher-neo » Post

tinoesroho wrote:I would, though, like to play it.
I'll zip you up a copy and post it, with complete directions.

tinoesroho
Member
Posts: 570
Joined: Fri Feb 17, 2012 21:55
Location: Canada

by tinoesroho » Post

Sounds sweet, cowboy. :-)
We are what we create.

I tinker and occasionally make (lousy) mods. Currently building an MMO subgame and updating mods. Pirate Party of Canada member. Sporadic author. 21 years old.

My github:
https://github.com/tinoesroho/

cypher-neo
Member
Posts: 46
Joined: Wed Oct 17, 2012 12:15

by cypher-neo » Post

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 ... 609#p95609

Post Reply

Who is online

Users browsing this forum: No registered users and 41 guests