Assignments Office Hours Hall of Fame Notes
Assignments Office Hours Hall of Fame Notes

Mechanized Mining

Assigned: 2019-10-02
Due Date: 2019-10-08 by 11:59PM U.S. Central Time

The Philippines has vast minerals that are still untapped. It has one of the world's largest deposits of gold, nickel, copper and chromite. Through responsible mining, we intend to generate more revenues from the extraction of these resources.

— Benigno Aquino III
The mining industry might make wealth and power for a few men and women, but the many would always be smashed and battered beneath its giant treads

— Katharine Susannah Prichard

It goes without saying, but your Crazy Eights game engine was a blockuster hit! People across the globe are uninstalling their triple-A titles just so they can focus on beating your killer strategies! Fiction Interactive has made a name for itself in countless online communities, all thanks to your help. And it seems they're not the only ones taking notice...

An announcement came from the CEO of Fiction Interactive today: the company has been acquired by tech behemoth Minisoft for $26.3 billion! After getting settled in to your new Portland office, you notice an email with your first week project specifications. Recently, Minisoft has been rampantly acquiring IP, and one of the games they picked up was the popular resource-gathering Java game Mine-opoly! Your new manager has personally asked you to improve their rather lackluster single player mode by beefing up its AI strategy.

This time, however, you're not alone! Fellow brilliant coworkers, also formerly from Fiction Interactive, have been given the same assignment, and they are hungry for victory! (Or maybe just hungry for pizza...) Show them what you can do, and we wish you the best of luck!

Goals

Assignment Spec

Getting Started

For this assignment, you will be creating at least one intelligent player strategy for a strategy game based on exhilarating concepts like mining and economics. This game is called Mine-opoly. Unlike previous assignments, we are giving you a significant amount of code. We have taken care of everything needed to run the game. This includes a game engine, graphics, and of course an interface for your strategy implementation. You are not allowed to modify this MinePlayerStrategy interface. You are however free to modify any other files including the game engine and graphics, but you do so at your own risk, and we will be using the original copy that we gave you to run the competition. You should create your Github repository from this link:

Click here to generate your repository

The Game

The game is a turn based mining competition played on an NxN square set of tiles which is considered the Game Board. There are 3 types of tiles on the board:

There are two players per game, a red player and a blue player. Both players start in the center of the board on their lower market tile. Each turn both players will receive information about the board state. This information contains where all the resources are, where your opponent is, prices for each resource, and other such information. Each turn both players will be required to return a TurnAction. This TurnAction is an enum value which indicates what your strategy wants your player to do for the current turn. TurnActions are one of the following:

As previously mentioned, market tiles are where you can sell your gathered gems for points. Stepping on one of these tiles will immediately sell every gem in your inventory at the current price for each type of gem. The price for each gem will then decrease depending on the amount of each type sold. Prices for gems will steadily increase over time again until reaching the max value for the gem type.

Finally, since players execute turns "at the same time", potential conflicts such as moving into the same tile will be handled by the concept of red turns and blue turns. On a red turn, the red player will have priority for these types of moves. On a blue turn, the blue player will have priority. Red turns and blue turns will alternate throughout the game. The first turn will be a red turn. So if two players are trying to move into the same tile, and it is currently a red turn, the red player has priority and will successfully move into that tile. The blue player will be blocked from moving and therefore do nothing.

The Interface

We have given you an interface that your player strategy should implement. You need to implement this interface without modifications, otherwise your strategy will not run in the provided game engine or the competition. This interface is called MinePlayerStrategy. It has the following methods:

  1. initialize() - This function will be called at the start of every round, passing in the size of the board, the maximum items that a player can carry in their inventory, the score to reach to win a single round, the starting tile location for the player, whether the player is a red player and a Random object for the player to use for generating random numbers if their strategy needs that.
  2. getTurnAction() - This function is the primary purpose of your strategy. It is called every turn to get the action your player should execute. A PlayerBoardView object is passed in which represents the state of the board, along with a boolean to say if the current turn is a red priority turn or not. This function returns a TurnAction for the action the player wants to execute. Returning null from this function will cause the player to do nothing.
  3. onReceiveItem() - This function is called whenever the player successfully executed a PICK_UP TurnAction on their last turn. The only parameter for this function is a reference to the InventoryItem picked up. This function is not called when the player inventory is full because the item is not picked up in that case.
  4. onSoldInventory() - This function is called whenever the player steps on a market tile of their color with at least one gem in their inventory. The only parameter for this function is an int for the total number of points received by selling everything in the inventory.
  5. getName() - This function is super simple, just return the name that you want to give your player on the GUI and in the competition. Can be as simple as a string constant like "ExampleName". Note that if you somehow manage to throw an exception in this function, your player's name will be the exception that you threw. That's super embarrassing for everyone involved.
  6. endRound() - This function is called at the end of every round. This passes in the number of points that your player scored and the number of points that the opposing player scored. You should also use this method to reset the state of your strategy class. Every semester we get complaints from people that their strategy acts buggy in the competition, and it turns out their strategy is still using variables set in the previous round.

The Competition

Participation in the competition is completely optional. Your grade is not impacted in any way by your decision not to participate or your placement in the competition. However, we make no guarantees about the impact of these things on your sense of self-worth. The top 8 strategies will be immortalized in a Hall of Fame on the website. The losing strategies... will not be. The top 8 will also be invited to a pizza party hosted by Professor Woodley. Everyone else will just get to hear about it. The choice is up to you!

How to submit code

Push code to your master branch. This is the branch we will pull from when we run the competition.

In order for us to run your player strategy in the tournament, you must put a single class that implements the MinePlayerStrategy in the competition package. You may also put any other classes you need in that package. This package is package mineopoly.competition;

How to make sure your code compiles in the competition

Do not include any subpackages in the competition package. These will not get compiled or run. Do not reference any classes that you personally created which are outside the competition package.

How to ensure your code is valid

Put only one player strategy in the competition package, otherwise we will not know which strategy to run. There should only be one class in the competition package that implements MinePlayerStrategy

Competition Runs

We will be auto-running the competition starting this Tuesday, October 8th. Indeed, this is on the due date, but we won't be closing the competition until the following Tuesday, October 15th. Note that you will still have an assignment due that week, and it will be our first C++ assignment. However, the workload should be smaller, so you can spend some time tweaking your strategy if you'd like.

Assignment Requirements

To fully complete this assignment, you must write at least one MinePlayerStrategy that meets the following requirements:

The provided implementation of RandomStrategy cannot pick up gems, so it cannot score any points. It will therefore only make things easier for you to score more points.

You are entirely allowed to write more than one strategy. In fact it probably makes sense to have a strategy that maximizes your points against a RandomStrategy for the assignment, and then another strategy that does more complicated actions against a smarter human-programmed opponent for the competition.

Part of this assignment is becoming familiar with an unfamiliar codebase. IntelliJ has built-in tools to allow you to more easily explore code

By all means feel free to ask questions on Piazza or in office hours if you get stuck, but you have all the code running the game in front of you. If you look around enough, you can probably find the answer to any question you may have, and develop a useful skill in the process.

Consider exploring around before you ever attempt to write a strategy. Are there some parts that seem more important than others (like the main method in MineopolyMain, or runGameLoop() in GameEngine)? Are there some parts that seem irrelevant to your needs (like anything dealing with the graphics or the paint() methods)?

When you do feel like you are ready to write a strategy, are there certain helper methods it would makese sense to have? If you do decide to write a more complex strategy for the competition, are there some design choices you could make to implement complicated conditional behavior more easily? Can an interface or abstract base class you write help you do that?

Other things we will take into consideration:

Test suites for this assignment are expected to be a bit slim, since of course you are only writing a strategy, and all of the game engine functionality has been done for you. That being said, if you write helper methods that you reuse ( which is a good idea in general), you should be testing them.

Try to make commits at regular intervals. You want to leave a clear trail of discrete pieces of progress that you've made as you work. Commits are cheap! Make lots of them. Once again, try to involve testing in your code development process; you don't have to write all of your tests before the code, but you should try to develop your code alongside your tests and vice versa.

Use your best judgement to write the cleanest code you can; make sure you can justify any design decisions you make in code review.

This is a test of your problem-solving skills: if you don't know how to do something (for example, writing an abstract class,) you should try your favorite search engine. (Make sure you follow our policy on citing online code.) If you're still stuck, consider Piazza and office hours.