[squeak-dev] The Trunk: EToys-jl.237.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Sep 20 11:49:41 UTC 2016


Jens Lincke uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-jl.237.mcz

==================== Summary ====================

Name: EToys-jl.237
Author: jl
Time: 20 September 2016, 1:48:28.446902 pm
UUID: 255d2987-bffc-ef4b-bb13-a862a8adbc86
Ancestors: EToys-jl.235, EToys-tfel.236

- distanceTo calculations in Kedama between groups of turtles
- conditions in Kedama per turtle, not globally
- fix for dynamically changing the size of a Kedama world

=============== Diff against EToys-tfel.236 ===============

Item was added:
+ ----- Method: KedamaExamplerPlayer>>getXAndY (in category 'slot getters/setters') -----
+ getXAndY
+ 
+ 	^ self turtles getXAndY!

Item was changed:
  ----- Method: KedamaMorph>>dimensions: (in category 'accessing') -----
  dimensions: anExtent
  	dimensions := anExtent.
  	wrapX := dimensions x asFloat.
  	wrapY := dimensions y asFloat.
  	patchVarDisplayForm := Form extent: dimensions depth: 32.
+ 	patchesToDisplay ifNotNil: [
+ 		patchesToDisplay do: [ :ea |
+ 			ea newExtent: anExtent.
+ 		].
- 	patchesToDisplay do: [ :ea |
- 		ea newExtent: anExtent.
  	].
  	self pixelsPerPatch: self pixelsPerPatch.!

Item was added:
+ ----- Method: KedamaTurtlePlayer>>getXAndY (in category 'commands and slots') -----
+ getXAndY
+ 
+ 	^ x at y.
+ !

Item was changed:
  ----- Method: KedamaTurtleVectorPlayer2 class>>primGetDistanceToX:toY:xArray:yArray:resultInto: (in category 'as yet unclassified') -----
  primGetDistanceToX: pX toY: pY xArray: xArray yArray: yArray resultInto: result
  
+ 	| ppx ppy tempMin |
- 	| ppx ppy |
  	<primitive: 'vectorGetDistanceTo' module:'KedamaPlugin2'>
  	"^ KedamaPlugin doPrimitive: #vectorGetDistanceTo."
  
  	ppx := pX.
  	ppy := pY.
  	1 to: result size do: [:index |
  		pX isCollection ifTrue: [
+ 			tempMin := SmallInteger maxVal.
+ 			1 to: pX size do: [:index2 |
+ 				ppx := pX at: index2.
+ 				ppy := pY at: index2.
+ 				tempMin := tempMin min: ((ppx - (xArray at: index)) squared + (ppy - (yArray at: index)) squared) sqrt.
+ 			].
+ 			self flag: #todo. "should really also remember the other side index to re-use inside the script"
+ 			result at: index put: tempMin.
+ 		] ifFalse: [
+ 			result at: index put: ((ppx - (xArray at: index)) squared + (ppy - (yArray at: index)) squared) sqrt.
+ 		]
- 			ppx := pX at: index.
- 			ppy := pY at: index.
- 		].
- 		result at: index put: ((ppx - (xArray at: index)) squared + (ppy - (yArray at: index)) squared) sqrt.
- 
  	].
  	^ result.
  !

Item was changed:
  ----- Method: KedamaTurtleVectorPlayer2>>getDistanceTo: (in category 'player commands') -----
  getDistanceTo: players
  
  	| p xArray yArray result pX pY xy |
  	players isCollection ifFalse: [
  		p := players
  	].
  	xArray := arrays at: 2.
  	yArray := arrays at: 3.
  	result := KedamaFloatArray new: self size.
  	players isCollection ifTrue: [
  		pX := KedamaFloatArray new: players size.
  		pY := KedamaFloatArray new: players size.
  		1 to: players size do: [:i |
  			xy := (players at: i) getXAndY.
  			pX at: i put: xy x.
  			pY at: i put: xy y.
  		].
  	] ifFalse: [
+ 		pX := p turtles getX.
+ 		pY := p turtles getY.
- 		xy := p getXAndY.
- 		pX := xy x.
- 		pY := xy y.
  	].
  	^ KedamaTurtleVectorPlayer2 primGetDistanceToX: pX toY: pY xArray: xArray yArray: yArray resultInto: result.
  !

Item was added:
+ ----- Method: KedamaTurtleVectorPlayer2>>getXAndY (in category 'player commands') -----
+ getXAndY
+ 	| ys |
+ 	ys := self getY.
+ 	^ self getX asArray withIndexCollect: [:ea :idx | ea @ (ys at: idx)]
+ !

Item was changed:
  ----- Method: KedamaTurtleVectorPlayer2>>test:ifTrue:ifFalse: (in category 'command execution') -----
  test: cond ifTrue: trueBlock ifFalse: falseBlock
  
+ 	| origPredicate c actualCond condValue |
+ 
- 	| origPredicate c actualCond |
  	(cond == true or: [cond == false]) ifTrue: [
  		^ cond ifTrue: [trueBlock value: self] ifFalse: [falseBlock value: self].
  	].
  	actualCond := cond.
  	cond isBlock ifTrue: [
  		actualCond := ByteArray new: predicate size.
+ 		condValue := cond value. 
+ 		condValue isCollection 
+ 			ifTrue: [
+ 				actualCond := condValue.
+ 			] ifFalse: [
+ 				1 to: predicate size do: [:i | actualCond at: i put: (cond value ifTrue: [1] ifFalse: [0])]
+ 			]
- 		1 to: predicate size do: [:i | actualCond at: i put: (cond value ifTrue: [1] ifFalse: [0])]
  	].
  	origPredicate := predicate clone.
  	predicate bytesAnd: actualCond.
  	trueBlock value: self.
  
  	c := actualCond clone.
  	c not.
  	predicate replaceFrom: 1 to: (predicate size min: origPredicate size) with: origPredicate startingAt: 1.
  	predicate bytesAnd: c.
  	falseBlock value: self.
  	predicate replaceFrom: 1 to: (predicate size min: origPredicate size) with: origPredicate startingAt: 1.!

Item was changed:
  ----- Method: Object>>test:ifTrue:ifFalse: (in category '*Etoys-Squeakland-Tweak-Kedama') -----
  test: cond ifTrue: trueBlock ifFalse: falseBlock
  
+ 	cond value ifTrue: [trueBlock value: self] ifFalse: [falseBlock value: self].
- 	cond ifTrue: [trueBlock value: self] ifFalse: [falseBlock value: self].
  !

Item was added:
+ ----- Method: Player>>getXAndY (in category 'slot getters/setters') -----
+ getXAndY
+ 
+ 	^ self getX @ self getY
+ !

Item was changed:
  ----- Method: WordArray>>eToysEQ: (in category '*Etoys-Squeakland-array arithmetic') -----
  eToysEQ: other
  
  	| result |
+ 
  	result := ByteArray new: self size.
  	other isNumber ifTrue: [
  		^ self primEQScalar: self and: other into: result.
  	].
  	other isCollection ifTrue: [
  		^ self primEQArray: self and: other into: result.
  	].
+ 	other isColor ifTrue: [
+ 		^ self primEQScalar: self and: (other pixelValueForDepth: 32) into: result.
+ 	].
+ 
  	^ super = other.
  !



More information about the Squeak-dev mailing list