Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 5 6 [7] 8 9 ... 13

Author Topic: Procedural content creation: Random plant creation script  (Read 35640 times)

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Procedural content creation: Random plant creation script
« Reply #90 on: March 19, 2011, 09:43:33 pm »

this is cool. One thing though, I genned a world, and the civilization that I embarked from doesn't seem to have access to any of the normal plants. They don't have access to all of the random plants either, though, so I think that this may be normal. The file with the normal plants is still there, and it seems unchanged, so thats all good.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #91 on: March 19, 2011, 10:15:37 pm »

Gotta share this one:
Spoiler (click to show/hide)

And

Spoiler (click to show/hide)

I culled both of these but I wanted to share anyways.

Why did you cull them?  Obviously, you should have made some Cream of Cream Mushroom Soup!

Sometimes, you can just say that a plant has a really odd name, since some real-world plants do have odd names like "Weeping Willow", so a Beard Sister that has thread might just have a fiberous cotton-like material that looks like a beard to some people... umm... although I'm not sure why that would make someone prefer it for its "familialness"...

I guess it was named by someone teasing their sister by saying the plant looked just like them?
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

Bohandas

  • Bay Watcher
  • Discordia Vobis Com Et Cum Spiritum
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #92 on: March 19, 2011, 10:32:22 pm »

I find that this utility really comes into its own when you use it simply as a jumping-off point, and punch up the better results a bit before adding them to the raws.

For example:

Original:

[PLANT:BEAN_MAGICIAN]
   [NAME:magician bean]
   [NAME_PLURAL:magician beans]
   [ADJ:magician bean]
   [PICKED_TILE:58]
   [PICKED_COLOR:7:0:0]
   [WET]
   [DRY]
   [BIOME:NOT_FREEZING]
   [USE_MATERIAL_TEMPLATE:STRUCTURAL:STRUCTURAL_PLANT_TEMPLATE]
      [MATERIAL_VALUE:4]
   [BASIC_MAT:LOCAL_PLANT_MAT:STRUCTURAL]
      [EDIBLE_RAW]
      [EDIBLE_VERMIN]
      [EDIBLE_COOKED]
   [GROWDUR:300]
   [VALUE:4]
   [USE_MATERIAL_TEMPLATE:EXTRACT:PLANT_EXTRACT_TEMPLATE]
      [STATE_NAME_ADJ:ALL_SOLID:frozen magician bean oil]
      [STATE_NAME_ADJ:LIQUID:magician bean oil]
      [STATE_NAME_ADJ:GAS:boiling magician bean oil]
      [MATERIAL_VALUE:4]
      [DISPLAY_COLOR:7:0:0]
      [EDIBLE_RAW]
      [EDIBLE_COOKED]
      [EXTRACT_STORAGE:BARREL]
      [PREFIX:NONE]
   [EXTRACT_BARREL:LOCAL_PLANT_MAT:EXTRACT]
   [USE_MATERIAL_TEMPLATE:SEED:SEED_TEMPLATE]
      [MATERIAL_VALUE:1]
      [EDIBLE_VERMIN]
      [EDIBLE_COOKED]
   [SEED:magician bean seed:magician bean seeds:7:0:0:LOCAL_PLANT_MAT:SEED]
   [SUMMER]
   [AUTUMN]
   [FREQUENCY:100]
   [CLUSTERSIZE:5]
   [PREFSTRING:magicians]
   [PREFSTRING:magicalness]
   [SHRUB_COLOR:7:0:0]
   [DEAD_SHRUB_COLOR:0:0:1]


Brushed up:

[PLANT:BEAN_MAGICIAN]
   [NAME:magician bean]
   [NAME_PLURAL:magician beans]
   [ADJ:magician bean]
   [PICKED_TILE:58]
   [PICKED_COLOR:7:0:0]
   [WET]
   [DRY]
   [BIOME:NOT_FREEZING]
   [USE_MATERIAL_TEMPLATE:STRUCTURAL:STRUCTURAL_PLANT_TEMPLATE]
      [MATERIAL_VALUE:4]
   [BASIC_MAT:LOCAL_PLANT_MAT:STRUCTURAL]
      [EDIBLE_RAW]
      [EDIBLE_VERMIN]
      [EDIBLE_COOKED]
   [GROWDUR:550]
   [VALUE:4]
   [USE_MATERIAL_TEMPLATE:EXTRACT:PLANT_EXTRACT_TEMPLATE]
      [STATE_NAME_ADJ:ALL_SOLID:frozen magician bean oil]
      [STATE_NAME_ADJ:LIQUID:magician bean oil]
      [STATE_NAME_ADJ:GAS:boiling magician bean oil]
      [MATERIAL_VALUE:4]
      [DISPLAY_COLOR:7:0:0]
      [EDIBLE_RAW]
      [EDIBLE_COOKED]
      [EXTRACT_STORAGE:BARREL]
      [PREFIX:NONE]
   [EXTRACT_BARREL:LOCAL_PLANT_MAT:EXTRACT]
   [USE_MATERIAL_TEMPLATE:MILL:PLANT_POWDER_TEMPLATE]
      [STATE_NAME_ADJ:ALL_SOLID:imperial magic dye]
      [STATE_COLOR:ALL_SOLID:ASH_GRAY]
      [DISPLAY_COLOR:0:0:1]
      [MATERIAL_VALUE:25]
      [POWDER_DYE:CLEAR]
      [PREFIX:NONE]
   [USE_MATERIAL_TEMPLATE:SEED:SEED_TEMPLATE]
      [MATERIAL_VALUE:2]
      [EDIBLE_VERMIN]
      [EDIBLE_COOKED]
   [SEED:magician bean seed:magician bean seeds:7:0:0:LOCAL_PLANT_MAT:SEED]
   [SUMMER]
   [AUTUMN]
   [FREQUENCY:10]
   [CLUSTERSIZE:4]
   [PREFSTRING:illusions]
   [PREFSTRING:magicalness]
   [SHRUB_COLOR:7:0:0]
   [DEAD_SHRUB_COLOR:0:0:1]
Logged
NEW Petition to stop the anti-consumer, anti-worker, Trans-Pacific Partnership agreement
What is TPP
----------------------
Remember, no one can tell you who you are except an emotionally unattached outside observer making quantifiable measurements.
----------------------
Έπαινος Ερις

Bohandas

  • Bay Watcher
  • Discordia Vobis Com Et Cum Spiritum
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #93 on: March 20, 2011, 04:45:15 pm »

Oh, by the way, for the next version I recommend that you set it to give the [SAVAGE] tag to plants with names from the WILD symbol group.
Logged
NEW Petition to stop the anti-consumer, anti-worker, Trans-Pacific Partnership agreement
What is TPP
----------------------
Remember, no one can tell you who you are except an emotionally unattached outside observer making quantifiable measurements.
----------------------
Έπαινος Ερις

Jay

  • Bay Watcher
  • ☼Not Dead Yet☼
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #94 on: March 20, 2011, 05:28:37 pm »

I find that this utility really comes into its own when you use it simply as a jumping-off point, and punch up the better results a bit before adding them to the raws.

For example:

Original:

Spoiler (click to show/hide)


Brushed up:

Spoiler (click to show/hide)
I agree.
Broiling peppers:
Spoiler (click to show/hide)
Gooonions:
Spoiler (click to show/hide)
I don't have the originals for them, unfortunately.
Logged
Mishimanriz: Histories of Pegasi and Dictionaries

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #95 on: March 20, 2011, 05:45:59 pm »

Also of note to those who have mentioned it, I'm currently dabbling at a random creature generator, that will make a raw file for a creature with some respects for size, biome, and activity.  There's less likely to be thin, hairless dogs in glaciers, and less likely to have woolly mammoths in deserts.

Spectre Incarnate

  • Bay Watcher
  • Possibly inside a dragon's toothy maw.
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #96 on: March 21, 2011, 07:15:46 am »

Very nice! I can't wait to try this program out, cause I just love random generators for brainstorming ideas off of. Thank you for making this.

some real-world plants do have odd names like "Weeping Willow", so a Beard Sister that has thread might just have a fiberous cotton-like material that looks like a beard to some people...
Exactly... behold, the screw pine. http://img1.eyefetch.com/Portfolio%5Caussie_bluey%5C57711.jpg:-X  ;D
« Last Edit: March 30, 2011, 03:02:18 am by Spectre Incarnate »
Logged
The in-game text has punctuation!  Who knew?
Mister Adams,
How many licks does it take to get to the [candy] center of a Dwarf Fortress?

Bohandas

  • Bay Watcher
  • Discordia Vobis Com Et Cum Spiritum
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #97 on: March 21, 2011, 10:16:05 am »

I find that this utility really comes into its own when you use it simply as a jumping-off point, and punch up the better results a bit before adding them to the raws.

For example:

Original:

Spoiler (click to show/hide)


Brushed up:

Spoiler (click to show/hide)

Which brings me to another suggestion for the next tweak to the generator, namely that plants with names from the MAGIC or MYSTERY symbols should be permitted to have clear dyes (remember, the argument for POWDER_DYE isn't the color of the dye, its the color that the dye turns the cloth.)
Logged
NEW Petition to stop the anti-consumer, anti-worker, Trans-Pacific Partnership agreement
What is TPP
----------------------
Remember, no one can tell you who you are except an emotionally unattached outside observer making quantifiable measurements.
----------------------
Έπαινος Ερις

Bohandas

  • Bay Watcher
  • Discordia Vobis Com Et Cum Spiritum
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #98 on: April 01, 2011, 01:27:56 pm »

I recently got a poisonous plant whose syndrome has no effects. (I think it has something to do with my custom language files)



[PLANT:ROSE_SLOTH_SIN]
   [NAME:slothrose]
   [NAME_PLURAL:slothroses]
   [ADJ:slothrose]
   [PICKED_TILE:5]
   [PICKED_COLOR:0:0:1]
   [WET]
   [DRY]
   [EVIL]
   [BIOME:NOT_FREEZING]
   [USE_MATERIAL_TEMPLATE:STRUCTURAL:STRUCTURAL_PLANT_TEMPLATE]
      [MATERIAL_VALUE:3]
   [BASIC_MAT:LOCAL_PLANT_MAT:STRUCTURAL]
   [GROWDUR:300]
   [VALUE:3]
   [USE_MATERIAL_TEMPLATE:EXTRACT:PLANT_EXTRACT_TEMPLATE]
      [STATE_NAME_ADJ:ALL_SOLID:frozen slothrose essence]
      [STATE_NAME_ADJ:LIQUID:slothrose essence]
      [STATE_NAME_ADJ:GAS:boiling slothrose essence]
      [MATERIAL_VALUE:12]
      [DISPLAY_COLOR:0:0:1]
      [EXTRACT_STORAGE:FLASK]
      [PREFIX:NONE]
      [SYNDROME]
         [SYN_NAME:slothrose poisoning]
         [SYN_AFFECTED_CLASS:GENERAL_POISON]
         [SYN_CONTACT]
         [SYN_INHALED]
         [SYN_INJECTED]
   [EXTRACT_STILL_VIAL:LOCAL_PLANT_MAT:EXTRACT]
   [USE_MATERIAL_TEMPLATE:SEED:SEED_TEMPLATE]
      [STATE_NAME_ADJ:ALL_SOLID:slothrose seed]
      [MATERIAL_VALUE:1]
   [SEED:slothrose seed:slothrose seeds:0:0:1:LOCAL_PLANT_MAT:SEED]
   [SPRING]
   [SUMMER]
   [FREQUENCY:100]
   [CLUSTERSIZE:5]
   [PREFSTRING:slothfulness]
   [PREFSTRING:sinfulness]
   [PREFSTRING:evils]
   [SHRUB_COLOR:0:0:1]
   [DEAD_SHRUB_COLOR:0:0:1]
Logged
NEW Petition to stop the anti-consumer, anti-worker, Trans-Pacific Partnership agreement
What is TPP
----------------------
Remember, no one can tell you who you are except an emotionally unattached outside observer making quantifiable measurements.
----------------------
Έπαινος Ερις

Sphalerite

  • Bay Watcher
    • View Profile
    • Drew's Robots and stuff
Re: Procedural content creation: Random plant creation script
« Reply #99 on: April 01, 2011, 01:36:40 pm »

Yeah, the script uses the plant adjective word to decide which syndrome to assign, so if there are custom words and it picks one that's not coded in the script it just doesn't assign a syndrome.  I suppose I should have it pick a random syndrome in that case.
Logged
Any intelligent fool can make things bigger and more complex... It takes a touch of genius --- and a lot of courage to move in the opposite direction.

veok

  • Bay Watcher
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #100 on: April 01, 2011, 10:31:44 pm »

Sphalerite, you are a hero.
Logged

huhu

  • Bay Watcher
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #101 on: April 02, 2011, 04:52:11 am »

Hi. I took a quick peek at the pastebin code and wondered why the tag parsing is so needlessly complicated with adding 1 character at a time. How about just:

Code: [Select]
for line in file:
tags = [tag.strip() for tag in line.partition('[')[-1].partition(']')[0].split(':')]

Which makes a list that removes spaces from edges of tags. Then again, it does create sane output already, so...
« Last Edit: April 02, 2011, 04:54:05 am by huhu »
Logged

Bohandas

  • Bay Watcher
  • Discordia Vobis Com Et Cum Spiritum
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #102 on: April 02, 2011, 01:12:52 pm »

By the way, I would like to suggest that the price of a plant's seeds should at least partially map to the price of the plant itself (I'm pretty sure that in-game most seeds cost half as much as the plant)
Logged
NEW Petition to stop the anti-consumer, anti-worker, Trans-Pacific Partnership agreement
What is TPP
----------------------
Remember, no one can tell you who you are except an emotionally unattached outside observer making quantifiable measurements.
----------------------
Έπαινος Ερις

Artanis00

  • Bay Watcher
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #103 on: April 03, 2011, 03:31:26 am »

Hi. I took a quick peek at the pastebin code and wondered why the tag parsing is so needlessly complicated with adding 1 character at a time. How about just:

Code: [Select]
for line in file:
tags = [tag.strip() for tag in line.partition('[')[-1].partition(']')[0].split(':')]

Which makes a list that removes spaces from edges of tags. Then again, it does create sane output already, so...

This bit of code fails on line with multiple tags in them, though.

Code: [Select]
>>> line = """[tag1:data][tag2][tag3:this is actually massively important]"""
>>> # Want to get ['tag1', 'data', 'tag2', 'tag3', 'this is actually massively important'] from this...
>>> [tag.strip() for tag in line.partition('[')[-1].partition(']')[0].split(':')]
['tag1', 'data']

Hard to test randomplant.py's read function, but I think both fail on quoted brackets:
Code: [Select]
>>> line = """[TILE:0:1:']':'+':'[']"""
>>> # Want to get ['TILE', '0', '1', ']', '+', '[']
>>> [tag.strip() for tag in line.partition('[')[-1].partition(']')[0].split(':')]
['TILE', '0', '1', "'"]
>>> #               ^ captured a quote?
« Last Edit: April 03, 2011, 04:04:18 am by Artanis00 »
Logged
Git - fast, efficient, distributed version control system
Github - Free public repositories, issue tracking, wikis, downloads...

huhu

  • Bay Watcher
    • View Profile
Re: Procedural content creation: Random plant creation script
« Reply #104 on: April 03, 2011, 12:53:46 pm »

Quote
This bit of code fails on line with multiple tags in them, though.

I see what you mean. The first case is easy to fix, the second one turned out to be more complex than what I first thought. Gonna work on that a bit more.

Edit: Slowly getting there, but not quite yet.

Code: [Select]
import re
rule = '\[(.*?)\]'

def open_tag(line):
    return [filter(lambda ch: ch not in "'", tag).strip() for tag in line.strip().split(':')]
   
for line in file:
    tags = [item for item in map(open_tag, re.split(rule, line)) if item[0]]
    if not tags or "[" not in line:
        continue
   
    tags.insert(0, re.findall('^(\t*)', line)[0])
    print tags
« Last Edit: April 04, 2011, 06:41:00 am by huhu »
Logged
Pages: 1 ... 5 6 [7] 8 9 ... 13