Code Review:
This piece of code is particularly useful for 3D simulations. The code establishes gravity for any object in the “sky box”. In the simulation when rain or snow is generated randomly throughout the year, it gets a random z value and is scattered (“Random,6 + 5” or 5 to 10). All rain particles and snow particles are given a “Gravity” trait of 1, and for each tick when above z > 0 the gravity of the particles increases by one and they fall based on their gravity. Once they reach a z value = 0 they are deleted. Because of the z value set for spawning the gravity is locked in at +1 rather than +.5 or +2 etc… to keep the rain/snow from smacking into the ground instantly or from falling too slowly (another set of rain/snow could spawn while the rest is still falling, creating unneeded assets to clog up the system).
When simulated, the rain/snow would spawn at random intervals and the particles would drop to the ground. However, only a couple of the particles were actually deleting themselves when they hit the ground and others were sticking to the ground.
So what is the issue? Turns out because the rain/snow was spawning between z values of 5 to 10 and falling at a rate of 1 then 2 then 3 then 4 etc…, if a particle spawned at 9 it would end at z = -1 while a particle of 10 would end at z = 0. So only the particles at z of 10 would delete while the particles at z of 9 would get lodged into the ground and stick out since gravity only effected them at z > 0. So, the fix was pretty simple: change “If, my [z] = 0” to “If, my [z] <= 0, delete” this way no matter where they end after gravity stops effecting them they get deleted.
So what else could be changed to make it better or what could this be implemented into? 1) The gravity could be “more” realistic. The spawn z value could be set higher (lets say 100) and gravity would act on the particles as normal, however, in this case gravity would stop increasing once it caps out at 9~10. This could be done by creating another logic command: “If, my [gravity] <= 10”. This is only useful for a more realistic simulation. 2) This code could also be useful for other agents, for example, if the fish or whales jump out of the water, gravity could act on them as well (this would just be some extra flare for the simulation).
Weekly Check-In:
Last week I wanted to restructure some of my code into procedure blocks but because there wasn’t enough general repetition (code was too situational and not worth the effort) that idea was canned. I also wanted to stamp out different ocean zones/set up recognition zones and set up a pressure/temperature system.
I did get the different zone layers set-up and got the agent’s recognition of the zones to work somewhat (the whales/fish respond to the different color terrains and reverse their heading when encountered, however, I am thinking I want to slow the whales down on the coastal regions and slow the fish down on the deep ocean regions instead). I tried to slow the whales down on the coastal tiles, however, it did not work. Normally their speed is set to 4.5 and when they hit the coastal tiles they were supposed to slow down to 1 or 2. Oddly enough, when I tested speeding them up on the coastal tiles to 20 they did have an increase in speed (I think I might have a solution to this but have not tested it yet as of writing). Additionally I did get a basic pressure system for low and high pressure when it rains/snows. I set it up so humans spawn for fishing when pressure is 1 (low pressure) and gave them a chance parameter for catching fish, they are more likely to catch fish when pressure is low (1) rather than high (0). This is roughly true in reality as fishing is better when pressure is about to drop or when pressure has stabilized.
This week I have three main goals:
1) I want to experiment a bit more with the pressure system, right now it is a basic on/off switch essentially. I want to see if I can get a more complex system in place.
2) I never got the chance to set-up a temperature system to go with the seasons/weather. Temperature is going to be important later on when I develop the migration and spawning of the fish. Right now I have an idea on what to do using world traits, but, with traits the temperature would be +1 or +2 or -1 or -2 at a tick or event. I’m curious if its possible to make a more dynamic temperature system that fluctuates like the real world.
3) The last thing I want to work with is fixing the terrain recognition for my agents.
If I finish the above three. I want to introduce a new parasite agent to the environment. Their main goal will be to leech off of the Chinook. The idea is that the parasites will bind to the Chinook and kill them, eventually it will be worked into the migration of Chinook for spawning and if the Chinook is infected they won’t breed and will die.
February 25, 2017 at 5:20 pm
re: code review
well done – it’s a common mistake that can be really hard to find
but there’s a bigger question – why bother having it rain if the rain just deletes itself? Is it just for show? If it really needs to be there, then have it accumulate and have other agents use it. If not, I’d suggest taking it out.