yarcat / chemistry-lines

Chemistry Lines (game)
1 stars 0 forks source link

Runes have to appear on the game field with different probabilities. #5

Closed soulne4ny closed 12 years ago

soulne4ny commented 12 years ago

Store element key (string) with its weight. Currently integer weights are enough.

soulne4ny commented 12 years ago

Added WeightedArray. Yaroslav found more elegant solution that uses TreeMap -- http://stackoverflow.com/questions/6409652/random-weighted-selection-java-framework. However, efficiency is the same.

soulne4ny commented 12 years ago

On each step random elements appear in different amount. It's a bug.

Add remove(value) method and switch to RandomCell to the same algorithm. Switch to TreeMap implemention because of it.

soulne4ny commented 12 years ago

To add remove is bad idea, because remove(value) will take O(n). TreeMap won't help to make it faster.

soulne4ny commented 12 years ago

Implemented WeightedArrayOfStrings with tests.