Trade Routes - Archipelago

in #utopian-io6 years ago (edited)

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.



Screen Shot 2018-04-29 at 14.39.30.png

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.



Screen Shot 2018-04-29 at 17.47.13.png

Two trade routes for Blue Team for the delivery of wood and stone

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

Sort:  

Hey @miniature-tiger

We're already looking forward to your next contribution!

Decentralised Rewards

Share your expertise and knowledge by rating contributions made by others on Utopian.io to help us reward the best contributions together.

Utopian Witness!

Vote for Utopian Witness! We are made of developers, system administrators, entrepreneurs, artists, content creators, thinkers. We embrace every nationality, mindset and belief.

Want to chat? Join us on Discord https://discord.me/utopian-io

Thank you for the contribution. It has been reviewed.

  • Good job on the PR and commit messages.
  • You can link more than one PR to a post if required.

Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.

[utopian-moderator]

Thanks @helo!

Yes, normally I add 3 PR to each post (I think that's the maximum) and have three sections and try to talk about different things, but this update took me forever to get right. The logic is really fiddly.

So, a bug? If I start a game, and then I change the size/shape of the board, (and supposedly start a new game) the initial movements from the previous game remain on the board AND new pieces are added.

Also, is there an instruction manual anywhere?

Ha! It's a feature! No, ok, it's a bug. Someone pointed it out last week as well. It's one of the last areas that I need to update in moving from the old graphics to the new graphics. But I have lots of ideas for settings and I'm hoping to do several at once. I'll get there!

There will be a big introduction and instructions and rules section coming, once I nail down what all the rules are. I may add something temporary for visitors in the meantime. Watch this space!

I'm very excited to play it. I love strategy games, and I love being able to play them even when no one is home to play them with me.

The game is magnificent. I'll try to join. But I do not understand everything.

Congratulations @miniature-tiger! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.

To support your work, I also upvoted your post!
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Are you for exchanging follows? I see that you stated in busy.org article that you will follow back. ;) (I need followers to gain those upvotes from busy bot haha) ✌🌞 P.S. already followed you. ;)

great job really informative post!!

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.032
BTC 60166.58
ETH 2964.21
USDT 1.00
SBD 3.79