Archipelago - Computer Opponents - Contract Delivery Decisions

in #utopian-io6 years ago (edited)

Back by popular demand!

Introduction

It's three months since I last made a contribution to Archipelago. I've had some distractions from a couple of other projects but I'll also to admit to getting a little stuck on the computer player automation and decision-making. With the developments in this contribution I think I'm now over that hurdle. Maybe I'll even have a one player version out in time for Christmas!

If you haven't come across Archipelago before, it's a seafaring and trading turn-based strategy game that I'm developing as an open-source project. Players guide their ships around the islands, searching for goods, building ships, trading with the Kingdom settlements and avoiding being chased down by pirates. I've got most of the game mechanics in place and I'm now working on the automation of computer opponents for the one player version.

In previous developments I had given computer opponents the ability to choose between different island search moves, that is, which island to visit and search for resources, or whether to travel and pick up resources found but unclaimed by another player. The avoidance of pirates was also built into this system.

In this contribution I move on to contract delivery decision-making and team-based strategies.


ArchiScreen.png

Repository

The repository for Archipelago can be found here. Background details of the project and the road-map can be found in the read-me file.
https://github.com/miniature-tiger/archipelago

For a full view of the current state of the game see my github-hosted page. 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!
https://miniature-tiger.github.io/archipelago/


New Features covered by this Contribution

Contract statistics and ranking of contract moves

Fulfilling contracts for goods issued by the four Kingdom islands is the key method for winning the game. A player must collect goods produced by their resource piece ("resource collection") and deliver an initial amount to the Kingdom island that issued the contract ("resource delivery"). Points are awarded for the length of the trade route and being the first player to contract with an island.

The automated decision making process that I previously developed for island search moves is based upon a probabilty-weighted rating system for each potential move choice, with the score from each outcome multiplied by the probabilty of that outcome arising. The amount of moves that an outcome requires is then used to produce a rating-per-move which allows each different move to be ranked.

The avoidance of pirates was built in to this system by deductions from the ratings based on the probabilty of being caught and defeated in a sea battle and the number of moves required to repair the ship.

This new feature collates statistics on all fulfillable contracts for a player and scores each potential "resource collection" move based on points available from the contract delivery and the number of moves required to complete the delivery. The aim is to have comparable scores to those from island search moves to allow the automation to choose between different move types.

This is most easily explained by an example:

contractrankings.png

The above screenshot shows the unsorted points-per-move scores for all possible contract-related "resource collection" moves for a single ship on a player turn.

topthreecontracts.png

The top three moves that target different resources are then fed into the overall decision making process. More on this below.

Team-based decision-making

At this point I have a method for ranking "island search" moves and a method for ranking "contract resource collection" moves for each ship. The main stumbling block was how to use these rankings to determine which moves an automated player should make, making sure that each of the (possible) three ships pursue different actions and don't all head for the best target.

The solution was to implement a decision-making routine at the start of the turn which took the top three moves of each type for each ship prior to any moves being made. The team-based decision making then chooses three moves, one for each ship, ensuring no overlap between move targets. This allows a team-based strategy to be applied to moves.

There are various methods to implement this strategy, for example maximising the overall score rating across the team or ensuring the best overall move is prioritised. In the first implementation I have used the latter approach. However I plan to use various implementations to give the computer players different strategies and personalities.

This process is repeated after each ship is moved within a turn to incoporate any new information revealed by that move. The prior moves are fixed within the decision making choices to ensure later moves do not repeat earlier moves.

As a simple example here's what the decision making array looks like for a single ship decision between an island (resource) search and resource collection moves, followed by the final decision:

catamarandecision.png

finaldecision.png

Resource collection

The final new feature was ensuring that goods are loaded by the computer player on arrival at the resource tile. The amount of goods loaded is sufficient to meet the contract initial delivery requirements.

These screenshots show a ship arriving at a clay resource and the three pottery goods loaded for delivery to the Kingdom island.

ArrivalClay.png

Loadedgoods.png

That completes the first part of automated decision-making for contracts. The second part will add "resource delivery" moves into the overall strategy, i.e. taking the loaded goods to the Kingdom island.

Pull request / commits

The code changes for the new features can be found here:
https://github.com/miniature-tiger/archipelago/pull/98


Proof of Work Carried Out

This is the full url to my github account:
https://github.com/miniature-tiger


Contact / Contribute

That is all for this update. If you have any queries please drop them in the comments or contact me on discord.

Have fun!

Sort:  

Thank you for your contribution. Once again the post is of very high quality where you have written everything about the feature very nicely. Its good to see that you have started working on the project again, and would love to see more and more contributions on it. I can see you are using both var and let, though there is no harm, but you can keep them consistent.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


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

Thanks @codingdefined.

There will definitely be some more contributions. I plan to have a good run with it between now and the end of the year, hopefully getting the one player version into a good state for playing!

Thank you for your review, @codingdefined! Keep up the good work!

Very cool to see Archipelago is back after its 3 month hiatus!

Thanks Amos! I shall be making some more progress on it over the next couple of months.

Congratulations @miniature-tiger! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 8000 upvotes. Your next target is to reach 9000 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

The Meet the Steemians Contest is over - Results are coming soon ...

Support SteemitBoard's project! Vote for its witness and get one more award!

Hi @miniature-tiger!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @miniature-tiger!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.029
BTC 63439.39
ETH 2545.40
USDT 1.00
SBD 2.66