Author Topic: Plant Hybridisation  (Read 693 times)

Offline Glenugie

  • Level 10
  • *
  • Posts: 64
  • Reputation: +0/-0
    • View Profile
    • The Land of Ennui
Plant Hybridisation
« on: November 07, 2009, 02:44:33 PM »
So I have a system for growing plants in my game, 3x3 grid, plants take 2 days to grow. I plan to have certain plant types hybridise with each other. So if two plants are in squares that have an adjacent empty square, or are an empty square between them, they will be destroyed, and the corresponding square will grow a hybrid plant. But I can't think of a simple way for each square to analyse the surrounding squares for the correct plant types to hybridise. Does anyone have any suggestions? :)

Thanks in advance,

~Glenugie~

Offline Sagefire135

  • Level 14
  • *
  • Posts: 107
  • Reputation: +2/-0
    • View Profile
Re: Plant Hybridisation
« Reply #1 on: November 07, 2009, 07:01:27 PM »
3x3 is pretty small, so you COULD just check every possibility. theres only 8 different ways that there can be an empty space between 2 others so it wouldn't be too bad. basically if s1 and s3 have plants that arent the same, kill them and make a new plant in s2 thats a hybrid. and do that for each of the 8 ways.

but...if you plan on having larger grids (4x4 has already has 24 different ways, 3x as many) then that would get to be impossibly hard very fast. that would probably need each square to be told to check all possible squares 2 space away with a loop and then make a hybrid if a match is found.

one thing to concider that you might have missed. what happens if there are plants on squares 1 and 9, then another is put in square 3? will the hybrid for in both 2 and 6? or just the suare that gets checked first?

EDIT: hmm, i missed the "have an adjacent empty square" part. that would add a bunch more options, total of 28 i think. Still doable with checking each option, but alot harder. and in some cases there can be 2 adjacent empty squares for the same 2 plants, again there needs to be somethign to deal with that.
« Last Edit: November 07, 2009, 07:05:34 PM by Sagefire135 »

Offline Harkins

  • Level 28
  • **
  • Posts: 424
  • Reputation: +11/-2
  • Coder, blogger, entrepreneur.
    • View Profile
    • Push CX - Blog
Re: Plant Hybridisation
« Reply #2 on: November 07, 2009, 07:51:51 PM »
What's the preferred order? It sounds like

Code: [Select]
p1|  |p2

should hybridize to
Code: [Select]
p1|p1+2|p2

and

Code: [Select]
p3|  | 
p4|  |
  |  | 

should hybridize to
Code: [Select]
p3|  | 
p4|  |
p3+4|  | 

but what does this hybridize to:

Code: [Select]
  |  |p7
p5|p6|
  |  |p8

This becomes important if you have grids >3x3.

Visit #bbg on irc.freenode.net to talk browser games anytime.

Offline Glenugie

  • Level 10
  • *
  • Posts: 64
  • Reputation: +0/-0
    • View Profile
    • The Land of Ennui
Re: Plant Hybridisation
« Reply #3 on: November 08, 2009, 03:08:00 AM »
The last would become:
Code: [Select]
  |p6+7|p7
p5|p6|p7+8
  |p6+8|p8

Offline saljutin

  • Level 22
  • *
  • Posts: 266
  • Reputation: +6/-0
    • View Profile
Re: Plant Hybridisation
« Reply #4 on: November 08, 2009, 04:41:50 AM »
first you should show us "grid" of every single unique possibility possible...so when does they hybrid and when they dont, so then we can see if you can create some function or something

Offline Sagefire135

  • Level 14
  • *
  • Posts: 107
  • Reputation: +2/-0
    • View Profile
Re: Plant Hybridisation
« Reply #5 on: November 09, 2009, 11:25:35 PM »
there is really only 2 possibilities that can occur by the original statement that adjacent empty spaces hybridize.
Code: [Select]
Linear:
|X| |Y|    |X|X+Y|Y|
| | | | -> | |   | |
| | | |    | |   | |

Angle:
|X| | |    | X |X+Y| |
| |Y| | -> |X+Y| Y | |
| | | |    |   |   | |
Judging by his latest post any time there is a place where hybridization can occur it does, and when multiple plants can hybridize in the same place, the linear combo takes priority.
Code: [Select]
So this would never happen right?
|X| |Y|    | X |X+Z| Y |
| |Z| | -> |X+Z| Z |Y+Z|
| | | |    |   |   |   |

Offline Glenugie

  • Level 10
  • *
  • Posts: 64
  • Reputation: +0/-0
    • View Profile
    • The Land of Ennui
Re: Plant Hybridisation
« Reply #6 on: November 11, 2009, 01:29:06 PM »
For Hybridisation to occur, the user has to use a spray on both slots in the plantation. So if one doesn't have the spray, it will not be considred for hybridisation.

In the last example, the only outcome should be:
Code: [Select]
|X| |Y|    | X |X+Y| Y |
| |Z| | -> |X+Z| Z |Y+Z|
| | | |    |   |   |   |

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal