tim_m
i'm so nice
- Joined
- Feb 10, 2003
- Messages
- 5,539
i was going to look at the first challenge for reference but it seems to have been pruned or i just can't find it.....
anyway, here's the new challenge. it's pretty much based on this page
to adapt it to be more generalized, not mathmatica,
possible list in no particular order
on a larger scale, a pattern like the following might emerge after a lot of iterations but before all the white cells are gone
or
i already made a command line program to do this mainly so i understood the challenge before describing it to everybody and it also helped me illustrate it above. also, i'm working on making a java applet to better represent this (but this is my first real applet, i have something that looks good in the standalone applet viewer but it's messed up in a browser)
i'll be testing these out on my college's computer science department server so i should be able to accept anything in java, c, c++, ada, and possibly pascal [and perl and php], i may need help compiling ada and pascal programs. sorry, that's all that's installed on the server. if i end up comparing times, they'll all have to be run on the same computer (can't do it on mine because cygwin screwed up the gcc compiler on my computer)
i'm sure there will be changes made as necessary but for now, here we go. also, no specific deadline. as always, be sure to ask questions. i'll clarify as best i can. [i'll try to denote edits in brackets]
...sorry i couldn't post this sooner.
anyway, here's the new challenge. it's pretty much based on this page
also, all cells are white to start out (it says it somewhere on that page but it's kinda obscure)Simulate a simple model of aggregation on a 2D grid: start with a single black cell, and at each step fill in a random white neighbor of a randomly selected existing black cell.
Here's how it works. Have a 2D grid of black and white cells (1s and 0s). Start with a single black cell. At each step, select at random an existing black cell that has at least one white neighbor. Then select a neighboring white cell at random, and make it black. (By neighbor we mean a cell above, below, left or right--not diagonal.)
to adapt it to be more generalized, not mathmatica,
- you don't necessarily have to have a 2 dimensional array. whatever method you think will work. a 2d array may be the easiest to work with or not, just depends how you feel i suppose
- you need to be able to choose how many cells to create, like what size to make a 2d array
- you need to randomly pick a starting cell
- you need to be able to aggregate the cells untill they are all black
- it would be helpful to have an option to print a representation of the cells at each iteration
- it would be good to be able to choose to only do a certain number of iterations. then when you show the array, you can see the pattern of growth
possible list in no particular order
- possibly speed, but that might vary to much between programming languages.
- efficiency - not so much speed, but does the code do what it does in the best way
- definately style
Code:
0 1 2
. . . . . . . . . . . .
. + . . . + + . . + + .
. . . . . . . . . + . .
. . . . . . . . . . . .
3 4 5
. . . . . . . . . . . .
. + + . . + + . . + + +
. + . . + + . . + + . .
. + . . . + . . . + . .
6 7 8
. . . . . . . . . . . .
. + + + . + + + . + + +
+ + . . + + + . + + + .
+ + . . + + . . + + + .
And so on...
Code:
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . + + + + . .
. . . . . . . . + + + + + + .
. . . . . . . + + + + + + . .
. . . . . . . + + + + + + . +
. . . . + + + + + + + + + + +
. . . . + . + + + + + + + + +
. . . . . . + + + + + + + + .
. . . . . . + + + + + + + + +
. . . . . . + + + + + + + . .
. . . . . . . + . + + + + + .
. . . . . . . . . + + . . . .
Code:
. . . . . . . . . . . . . . .
. . . . . . . . + + + + . . .
. . . . . . . . + + + . . . .
. . . . . . + + + + + . . . .
. . . . + + + + + + + + + . .
. . . + + + + + + + + + + . .
. . . + + + + + + + + + + + .
. . . . + + + + + + + + + + .
. . . . . + + + + + + + + + .
. . . . . + + + + + + + + . .
. . . . . . . + + + + . . . .
. . . . . . . . + + + . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
i'll be testing these out on my college's computer science department server so i should be able to accept anything in java, c, c++, ada, and possibly pascal [and perl and php], i may need help compiling ada and pascal programs. sorry, that's all that's installed on the server. if i end up comparing times, they'll all have to be run on the same computer (can't do it on mine because cygwin screwed up the gcc compiler on my computer)
i'm sure there will be changes made as necessary but for now, here we go. also, no specific deadline. as always, be sure to ask questions. i'll clarify as best i can. [i'll try to denote edits in brackets]
...sorry i couldn't post this sooner.