Trade routes join the two sides of a trade contract; the delivering player's resource piece and the receiving Kingdom fort. They illustrate the path over which the contracted goods are delivered.
Once a trade contract has been initiated the delivering player must maintain it over a number of game weeks. One way in which trade contracts can be interrupted and broken is by pirate ships sitting along the trade route and seizing the goods in transit.
The development of trade routes required:
- An approach to determining the most appropriate harbour space next to the resource piece and next to the fort at the start and end points of the trade route.
- Methods to find the most direct trade route between two points, avoiding islands, and recording this as an array of tile coordinates.
- A method to add an SVG path in team colours based on the array of tile coordinates.
Phase 2 of Archipelago development (Resources, Goods, Building, and Trade Contracts) is now well underway.
For a full view of the current state of the game development see my github-hosted page.
https://miniature-tiger.github.io/archipelago/
Please note that the game is not yet complete - you can see current progress and test functionality but you will have to wait a little longer to play!
Background details of the project can be found at the end of this contribution post.
New Features covered by this Contribution
Addition of trade routes
A trade route illustrates the path taken by a ship delivering goods and as such must start and end in the sea. The first challenge was to convert the resource piece and Kingdom fort coordinates into those of adjoining sea tiles. A method was created to rank the adjoining tiles in order of appropriateness based on the direction of the trade route and then to move through the preference list checking that they met the other required criteria (i.e. that they were sea tiles).
The next challenge was to find the most direct trade route between two points, avoiding islands, and recording this as an array of tile coordinates. The approach applied builds paths by looping through increasingly large sets of tiles, adding to the recorded path for each tile reached only if the cost of the path is lower than the cost of any other path reaching the same tile.
The costs of movement for the above were derived by considering the overall direction of travel of the trade path and assigning lower cost to a move in that direction, with increasingly higher costs for moves which diverge from that direction.
For the graphics a new SVG layer was added to hold the trade routes. Trade routes sit above the map board but under any passing ships.
The initialisation of each trade contract results in a trade route being added to the layer. The trade routes are SVG paths built from an array of coordinates. The start and end points are marked by circles.
Finally the trade route creation was added to the logic of the game flow, following after the completion of a trade contract.
Some trade paths are illustrated below. A large example view of the map is included at the top of this contribution.
The code changes for this update can be found here:
https://github.com/miniature-tiger/archipelago/pull/45/files
The board.js changes are the graphical implementation of the SVG paths.
The contracts.js changes (which appear to be too large for the comparison) are the methods for determining the trade path coordinates.
That is all for this update. If you have any queries please drop them in the comments or contact me on discord.
Details of the Archipelago Project
What is the Project About?
Archipelago is a new project that I have been working on. The aim is to develop a seafaring and trading turn-based strategy game. Players will guide their ships around the islands, searching for goods to aid construction of ships and their bases, trading with the Kingdom settlements and avoiding hazards like pirates and whirlpools.
Technology Stack
The project is a browser based game:
- Mechanics: Javascript
- Visuals: HTML and CSS initially but now moved across to Canvas and SVG.
Roadmap
Phase 1 - the first main goal of getting ships on the board and moving at different speeds under the influence of the compass is complete.
The graphics overhaul is also now complete.
Work is now ongoing on Phase 2 which is resource discovery, goods production, building and the trade contracts that underlie the game.
Work has also begun on adding pirates and conflicts.
Phase 1 - Board and ship movement: COMPLETE!!!
- Board set up - COMPLETE
- Basic ship creation: functionality and graphics - COMPLETE
- Manual ship movement and board updating - COMPLETE
- Basic compass creation: functionality and graphics - COMPLETE
- Turn based activity of ship movement - COMPLETE
- Logic of length of longer moves around obstacles - COMPLETE
- Chaining together transitions to allow graphics of longer moves - COMPLETE
- Separation of board layers (Canvas base layer, Canvas activation layer overlay, SVG piece overlays) - COMPLETE
Phase 2 - Resources, Goods, Building and Trade Contracts
Resources
- Add Resource tiles (forest, ironworks, flax, gold etc) - in progress: forest, ironworks, quarry, plantation added
- Discovery of resource tiles - COMPLETE
- Claiming of resource tiles - COMPLETE
- Dashboard of player pieces - COMPLETE
Goods
- Creation of new goods each turn - COMPLETE
- Loading, unloading and transportation of goods - COMPLETE
- Dashboard of goods pieces - COMPLETE
- Goods icons
- Variable quantity of goods to be loaded / unloaded
Contracts for delivery:
- Semi-random (equitable) generation of trade delivery contracts - COMPLETE
- Creation of trade settlements - COMPLETE
- Dashboard for contracts - COMPLETE
- Mechanics for contract sign-up - COMPLETE
- Mechanics for contract delivery - COMPLETE
- Island naming: for describing location of trading settlements - COMPLETE
- Graphics of trade routes - COMPLETE
Building (On hold - decide if necessary once contracts implemented)
- Recipes, time to implement, graphics etc
Scoring:
- Work out scoring mechanism (linked to contracts)
- Add score dashboard
Phase 3 - Conflicts
Pirates
- Add pirate ships - COMPLETE
- Automate pirate ship movements (basic movement with wind and search for cargo ships) - COMPLETE
- Telescope range of 4 tiles for stronger search for ships
- Consider separate cargo and war ships for teams
Forts
- Add fort icons - COMPLETE
- Create safe harbour from pirate ships
Conflicts
- Develop conflict method between ships
- Stealing of cargo
- Limping back to port
Phase 4 - Central trading centre
- Develop central market allowing players without resources to trade and fulfill contracts
Phase 5 - Rules, roll-out, documentation, testing etc
- TBDeveloped
Contact / Contribute
You can get in touch with me on discord if you would like to contribute.
You can find the current state of the game here:
https://miniature-tiger.github.io/archipelago/
The repository for the project is here:
https://github.com/miniature-tiger/archipelago
Have fun!
Posted on Utopian.io - Rewarding Open Source Contributors