Info Lectures Assignments Staff Office Hours Hall of Fame Notes
Info Lectures Assignments Staff Office Hours Hall of Fame Notes

Mechanized Mining 2.0

Assigned: 2020-02-26
Due Date: 2020-03-03 by 11:59PM U.S. Central Time

Goals

Assignment Spec

Gradescope

You will need to submit your GitHub repository to Gradescope after completing this assignment.

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.

Get your copy of the assignment here: https://classroom.github.com/a/dou85zBp

The rubric can be found here.

Why the 2.0? This is a new and improved version of last semester's game.

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 4 types of tiles on the board:

There are two players per game, one with a red robot and one with a blue robot. 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 maximum charge that your robot will start with the score to reach to win a single round, an initial view of the GameBoard, the starting tile location for the player, whether the player is a red player, and finally 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. The parameters are a PlayerBoardView object which represents the state of the board, an Economy object with resource price information, the current charge your robot has, and 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.

Assignment Requirements

To fully complete this assignment, you must write at least one MinePlayerStrategy in the mineopoly_two.strategy package 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.

In addition to those requirements on the strategy:

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. If you write a separate strategy for the competition, it will not be graded as part of this assignment.

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 make 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 swap strategy behaviors on the fly?

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.

This assignment 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.

Tips

The Competition (you don't need to read this before completing the assignment)

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_two.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, March 3rd. Indeed, this is on the due date, but we won't be closing the competition until the following Tuesday, March 10th. 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.