# What data structure to use to implement ocean currents and trade-winds

I'm creating an RPG/simulation game which is similar to the Uncharted Waters Series. The game allows the player to control a fleet to explore and navigate the world on the world map. My Game stores the world map as a tiled map into a 2158 * 1080 2D array.

The problem I'm facing is I want to simulate the ocean currents and trade winds on the world map so when the player is sailing on the map, the speed of the fleet will be affected by the current and the wind. It does not have to be a really accurate simulation because this is not a high-detailed simulation game but it should resonably simulate the ocean currents and the wind.

Requirements:

• Need to come up with a data structre to represent the ocean currents
• For each point (x,y) on the map, the data structure should provide a fast way to look up what is the strengh and direction of the current at that particular point
• The current can have 8 directions (N W S E NW NE SW SE).
• The strengh of the current is represented as an Int
• Same requirements for trade wind so I think the solution should be the same

My thoughts:

I'm thinking about dividing the world into several regions and each region can be subdivided into smaller regions like a quad tree. For look up I can do a contains(x,y) and find out which region the point is in and then for sub-regions to the same thing until it arrives a leave of the tree which stores the strengh and direction of the current.

Is that a reasonable solution or there are better ways to do this? What are the gotchas for implementing it?

What I would do is copy Minecraft's habit of adding metadata. Basically, metadata is a method of adding additional data to your tiles (or blocks, continuing the Minecraft explanation) which confers non-essential information (essential information being things like tile type and location). What this would mean is that in the XML file where I presume you are storing your tile data, you would also store the direction (1-8) of your wind and current, and its strength, or possibly aggregate both for a lower memory footprint. You would then load this information at runtime and store it in a 2D array akin to your tile map. As a C++ struct this translates to:

struct MovementMetadata
{
int oceanCurrentStrength;