posted Dec 2, 2019, 10:32 AM by JonAlf Dyrland-Weaver
[
updated Dec 2, 2019, 12:44 PM
]
This program will be similar to Friday's "tapestry" assignment. You will also want to change the size of the world to accommodate more (but smaller) patches. - Pick 2 colors you like, call one of those colors "on" and the other "off".
- Give patches a property, we will use it later on to keep track of how many neighbors are "on".
- Create a setup procedure that:
- Clears everything
- Sets all patches to the "off" state.
- Puts patch 0 0 in the "on" state.
- Create a setup_random that:
- Clears everything.
- Gives each patch a 7% chance of being in the "on" state, otherwise they should be "off"
- Create a go0 procedure that does the following:
- Every patch should keep track of the number of neighbors that are "on" in the property declared in step 2.
- After every patch has completed step 1:
- If a patch is "off" and the number of "on" neighbors is 1 the patch should turn "on".
- If a patch is "on", and the number of "on" neighbors is not 1, it should turn "off".
- This should not include patches that have been turned on just before.
- Create a go1 procedure that does the following:
- Every patch should keep track of the number of neighbors that are "on" in the property declared in step 2.
- After every patch has completed step 1:
- If a patch is "off" and the number of "on" neighbors is in the range [5, 8], the patch should turn "on".
- If a patch is "on", and the number of "on" neighbors is not in the range [4, 8], the patch should turn "off"
- Like go0, this should not include patches that have just turned "on".
- Create a go2 procedure that does the following:
- Every patch should keep track of the number of neighbors that are "on" in the property declared in step 2.
- After every patch has completed step 1:
- If a patch is "off" and the number of "on" neighbors is 3, the patch should turn "on".
- If a patch is "on", and the number of "on" neighbors is not 2 or 3, the patch should turn "off"
- Like go0, this should not include patches that have just turned "on".
- Hopefully you are noticing a pattern to the code you are writing. Create your own version, try out different values of the amount of "on" neighbors that triggers a switch. Maybe even look at values that are not in the same range.
submit this as on_off |
|