development update #73
Hello everyone,
Build 46 should be uploaded some time today (Sunday the 31st Jan). We are just doing a final round of testing before releasing it to steam.
A lot has been written in the last weeks about what has gone into this update so rather than just repeat myself as I too often do It is far better to actually show some of what we have been working on.
Fry Predation:

Aggressive and semi-aggressive fish are always on the look out for a quick snack so keep that in mind when you have them in an aquarium with fry. Peaceful fish will only eat fry when they are really hungry.
General movement:

There have been a lot of tweaks made to how fish are animated. We have introduced more subtleties and fish are not always in a hurry to move about. The fish in the above gif is sort of taking it easy. It swims a bit the coasts for a second or two and then swims a bit more. It is using it's "arm" fins more than it's tail because it is not trying to go very fast. However if it wants to move much faster then it will use it's tail more.
Curves to control procedural animation:

This is controlled using animation curves that are used to drive the intensity of swim speed, arm movement speed and tail movement speed.
Detailed view of a curve:

At the low points the value is 0 and the high point value is 1. Think of it as "off" and "on". Each fish has an internal timer that reads the curve as time increases. Depending on the type of behaviour that the fish is currently executing it will choose a different curve. Essentially what this curve does is have a value of 0 for one to five seconds and have a value of 1 for one to five seconds. If we were to just use the values of 0 and 1 to drive the animation we would get a very jumpy animation so what we do is smooth the output values from the curve so the transition from 0 to 1 or 1 to 0 happens over the course of 0.3 seconds or so. All of these curves are generated randomly based on some rules. For instance the flock curve has smaller periods of it being 0 and longer periods of it being 1 otherwise there would be too many fish falling behind their group.
Navigation:

This system broke last week because the existing version of it that was written just did not work well with the new behaviour changes we have been making. Thankfully though it was somewhat quickly rewritten to work nicely and it works better than before using less complex code.
What you can see happening is our puffer moving towards a target which is being an obstructed. The pink line coming from the puffer indicates that it has detected an obstacle in it's way and it is close. It then shoots out some radar lines in multiple directions to see if it can find any non obstructed space to move into. These are the many blue lines that are pointed out from it. If it finds non obstructed space then it adds movement force into that direction. It is also still applying force to move towards the target but the correction forces nudge it just enough that it appears to move around the obstacle. As it moves around the obstacle you can see there is a little jolt in it's movement. This is because it is hitting the glass. We are sort of on the fence as to whether we should allow the fish to just bash into the glass. Certainly in my experience of keeping fish I have seen that happen so it is a somewhat realistic behaviour but in the game it feels a little too much like an imperfection that should be corrected.
Possible future for navigation:

At the beginning of the week I did a bit of research into alternative ways to do navigation. What you see in the above image is a way of finding the path (pink line) from point to point and avoiding obstacles using a fairly smart algorithm to find the shortest correct path. It is known as Astar or A* pathfinding. It is quite an old technique that has been used in countless games. Usually it is used for navigation on a 2D grid for characters moving across the floor.
The algorithm

This is an visualisation example found on Wikipedia. the code actually searches almost every possible path from start point to target point and then calculates the shortest path. If there are a lot of obstacles in the way then it results in much more calculations but a correct path is always assured as long as the target point is not stuck inside barriers without an entrance.
This is something that could be useful in the future but it requires a few changes to how we setup things in the game. It also means that fish have to request a path before moving towards the target. This means a lot of computation is done before the fish even begins swimming and if there are a lot of fish in an aquarium then that must be managed because we cannot calculate 500 paths on the same frame however it would be unlikely that they would all need a new path at the exact same time. But if a fish is swimming after another fish or chasing a piece of food is dropping down from the surface the path must be recalculated perhaps once every half a second because the target is moving. Also the player could be moving decorations around that obstruct an existing correct path so there must be mechanisms in place to check that a path needs to be recalculated. If the aquarium is quite large then there are move possible paths to explore and that will increase the time it takes to compute a path.
For now we much prefer the fish finding their way around the aquarium as they do now. It allows the fish the figure out where they are going as if they are thinking creatures and if they do get stuck that might be a good way of telling players that they have decorated their aquarium in such a way that fish find it hard to move around.
Next week we will take a break from doing some of this more complex work and concentrate on some quality of life changes in the game. There have been many very good suggestions made by players in the forums and in response to weekly update posts and it would be good to make some changes based on those before we move on.
We wish you all a good Sunday.
The Fishery Team
Build 46 should be uploaded some time today (Sunday the 31st Jan). We are just doing a final round of testing before releasing it to steam.
A lot has been written in the last weeks about what has gone into this update so rather than just repeat myself as I too often do It is far better to actually show some of what we have been working on.
Fry Predation:

Aggressive and semi-aggressive fish are always on the look out for a quick snack so keep that in mind when you have them in an aquarium with fry. Peaceful fish will only eat fry when they are really hungry.
General movement:

There have been a lot of tweaks made to how fish are animated. We have introduced more subtleties and fish are not always in a hurry to move about. The fish in the above gif is sort of taking it easy. It swims a bit the coasts for a second or two and then swims a bit more. It is using it's "arm" fins more than it's tail because it is not trying to go very fast. However if it wants to move much faster then it will use it's tail more.
Curves to control procedural animation:

This is controlled using animation curves that are used to drive the intensity of swim speed, arm movement speed and tail movement speed.
Detailed view of a curve:

At the low points the value is 0 and the high point value is 1. Think of it as "off" and "on". Each fish has an internal timer that reads the curve as time increases. Depending on the type of behaviour that the fish is currently executing it will choose a different curve. Essentially what this curve does is have a value of 0 for one to five seconds and have a value of 1 for one to five seconds. If we were to just use the values of 0 and 1 to drive the animation we would get a very jumpy animation so what we do is smooth the output values from the curve so the transition from 0 to 1 or 1 to 0 happens over the course of 0.3 seconds or so. All of these curves are generated randomly based on some rules. For instance the flock curve has smaller periods of it being 0 and longer periods of it being 1 otherwise there would be too many fish falling behind their group.
Navigation:

This system broke last week because the existing version of it that was written just did not work well with the new behaviour changes we have been making. Thankfully though it was somewhat quickly rewritten to work nicely and it works better than before using less complex code.
What you can see happening is our puffer moving towards a target which is being an obstructed. The pink line coming from the puffer indicates that it has detected an obstacle in it's way and it is close. It then shoots out some radar lines in multiple directions to see if it can find any non obstructed space to move into. These are the many blue lines that are pointed out from it. If it finds non obstructed space then it adds movement force into that direction. It is also still applying force to move towards the target but the correction forces nudge it just enough that it appears to move around the obstacle. As it moves around the obstacle you can see there is a little jolt in it's movement. This is because it is hitting the glass. We are sort of on the fence as to whether we should allow the fish to just bash into the glass. Certainly in my experience of keeping fish I have seen that happen so it is a somewhat realistic behaviour but in the game it feels a little too much like an imperfection that should be corrected.
Possible future for navigation:

At the beginning of the week I did a bit of research into alternative ways to do navigation. What you see in the above image is a way of finding the path (pink line) from point to point and avoiding obstacles using a fairly smart algorithm to find the shortest correct path. It is known as Astar or A* pathfinding. It is quite an old technique that has been used in countless games. Usually it is used for navigation on a 2D grid for characters moving across the floor.
The algorithm

This is an visualisation example found on Wikipedia. the code actually searches almost every possible path from start point to target point and then calculates the shortest path. If there are a lot of obstacles in the way then it results in much more calculations but a correct path is always assured as long as the target point is not stuck inside barriers without an entrance.
This is something that could be useful in the future but it requires a few changes to how we setup things in the game. It also means that fish have to request a path before moving towards the target. This means a lot of computation is done before the fish even begins swimming and if there are a lot of fish in an aquarium then that must be managed because we cannot calculate 500 paths on the same frame however it would be unlikely that they would all need a new path at the exact same time. But if a fish is swimming after another fish or chasing a piece of food is dropping down from the surface the path must be recalculated perhaps once every half a second because the target is moving. Also the player could be moving decorations around that obstruct an existing correct path so there must be mechanisms in place to check that a path needs to be recalculated. If the aquarium is quite large then there are move possible paths to explore and that will increase the time it takes to compute a path.
For now we much prefer the fish finding their way around the aquarium as they do now. It allows the fish the figure out where they are going as if they are thinking creatures and if they do get stuck that might be a good way of telling players that they have decorated their aquarium in such a way that fish find it hard to move around.
Next week we will take a break from doing some of this more complex work and concentrate on some quality of life changes in the game. There have been many very good suggestions made by players in the forums and in response to weekly update posts and it would be good to make some changes based on those before we move on.
We wish you all a good Sunday.
The Fishery Team