'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 15 May 2007 at 10:20:51 am'! Lsystem subclass: #StochasticLsystem instanceVariableNames: 'randomNumberGenerator' classVariableNames: '' poolDictionaries: '' category: 'Cours-Smalltalk-GUI'! !StochasticLsystem methodsFor: 'initialisation' stamp: 'hw 3/19/2006 13:27'! initialize super initialize. randomNumberGenerator := Random new ! ! !StochasticLsystem methodsFor: 'lecture-ecriture' stamp: 'hw 3/19/2006 18:27'! uneOuPlusieurs: clef valeurs: valeurs | aux c | aux := reglesDerivation at: clef ifAbsent: nil. aux isNil ifTrue: [reglesDerivation at: clef put: valeurs] ifFalse: [aux isString ifTrue: [c := OrderedCollection new. c add: aux; add: valeurs. reglesDerivation at: clef put: c] ifFalse: [aux add: valeurs]]! ! !StochasticLsystem methodsFor: 'actions' stamp: 'hw 3/19/2006 20:33'! getRegle: regle ^regle isString ifTrue: [regle] ifFalse: [regle at: (randomNumberGenerator nextInt: regle size)]! ! !StochasticLsystem methodsFor: 'actions' stamp: 'hw 3/19/2006 20:15'! remplace: aString | tmp | ^ aString inject: '' into: [:new :ele | (tmp := reglesDerivation at: ele ifAbsent: nil) isNil ifTrue: [new , ele asString] ifFalse: [new , (self getRegle: tmp)]]! !