FCDB #1 : The world map
Gameplay mechanics

In factory games like Factorio and Shapez, efficient space management is a critical aspect of gameplay. Despite the unlimited space, players often face challenges in fitting their expanding production setups due to lack of planning. In FactoryCapi, we take this concept a step further by imposing strong space limitations. There are several reasons for this, but the main one is to spicy your planning up !

Constraining available land for building wide production trees can frustrate advanced players. Therefore, it's imperative to provide a mechanism for growth.

Enter the world map. Each player starts with a parcel of land containing basic resources. However, as players inevitably seek to expand their production capabilities, they have the option to purchase additional lands on the world map. Each land offers different types of resources, depending on its biome. Some lands have rare resources, while others offer more space. Like other in-game items, lands can be put up for sale, providing players with opportunities to increase their wealth. Given the limited supply of lands, they hold significant value.Unclaimed lands are automatically put up for sale, with their prices determined by the value of their resources.

The world map scales indefinitely, every time a new player sign up, a specific map for new player is generated, containing basic resources and enough space to start building a simple factory. Then 3 others map are generated somewhere else, with random resources. These lands are for sale instantly for everyone.

In FactoryCapi, transactions between players are live events. This dynamic aspect adds depth to the gameplay, as it introduces the time into player interactions. When players engage in transactions with one another, they should expect a certain delay as the transaction takes time to complete, reflecting the realistic nature of economic exchanges.

Moreover, the actual distance between lands on the world map plays a significant role in gameplay. Purchasing land from a player across the map differs from buying land from a neighboring player. Even though the world map looks like our real planet, it is actually not a globe. Borders are not wrapped !

To facilitate transportation of items across the world map, players have access to three types of vehicles: land-based, naval, and aerial. Each vehicle type offers distinct advantages and limitations. Aerial vehicles, for instance, are fast but have limited carrying capacity. They can traverse all types of terrain on the world map. On the other hand, naval vehicles are slow-moving but can transport large quantities of items, restricted to traveling over oceans and rivers. Land-based vehicles strike a balance between speed and capacity but are confined to ground transportation.

Vehicles are not only functional items but also customizable. Players can produce, sell, and show off, forming the core aspect of FactoryCapi's gameplay experience.

Nerd zone

I inspired myself with the excellent and famous redblobgame blog for the world map generation. Initially generated using a Voronoi diagram, the world map's key distinction lies in the distribution of tile centers, ensuring a consistent tile size. This approach allows for an enormous number of tiles while facilitating quick index computation.

The world contains a vast amount of data necessary for computing travel paths via the A* algorithm. However, this data is mostly static, with changes occurring only periodically, such as with each new season. It is thus efficient for players to fetch the world map data just once. The world map data should hold all the necessary information for computing A* travel paths and should not require any computation during the loading process. Although this might increase the size of the world map file, it remains highly compressible. Prioritizing the player computational resources (= preserving battery) over a small increase in RAM usage is better in my opinion.

The raw data of world map is around 12MB. When we apply compression to the file, the final size is about 2MB.

It's important to note that A* path computation should not be done server-side. Instead, this task is performed on user's device. However, to minimize the computational load on client devices, particularly in scenarios where many vehicles are involved, the server can play a role. When a player creates a new vehicle, the computed A* path is transmitted to and stored on the server. Other players can access and utilize this pre-computed path, eliminating the need for redundant computations.