Java代写:CS150 Chutes and Ladders Continued

Introduction

继续上次代写的Chutes and Ladders,做一些功能性的扩展。

Your third project is to modify and extend your game from project 2.

Project Description

Changes to the existing game (Project 2):

  1. (NEW) There is now a Maze component (comes under Obstacle/Aid)
  2. (MODIFIED) The game ends when all tokens have completed the game.
  3. (MODIFIED) A JStack can only be used once per turn, i.e., if landing on a JStack leads to another JStack and results in an infinite loop of JStacks, the transition/translation will end when the token lands on a JStack for the second time.

Rules of the Game

The rules of the game are fairly straightforward and are:

  1. Each turn of the game consists of each player rolling the dice and moving one token the number of steps (from the dice) forward where possible.
  2. If the token lands on an aid or obstacle as the last step, then they will be affected by that aid or obstacle. Otherwise they are not affected by any aids or obstacles on the way.
  3. If the token lands on a treasure pot, the token will acquire a number of treasure pieces in that pot. The pot is non-renewable.
  4. The game ends when all tokens land on the last spot in the board exactly. If a player rolls a number that takes them beyond the board, they will not be able to move their token for that turn.
  5. The players (tokens) start at location (0, 0, 0) and there are no aids, obstacles or treasures at that location.
  6. There are no aids on the last row of the board.
  7. The score of each player is calculated with the following formula:
    (a) Finishing the game FIRST (i.e., arriving at the last spot on the board) is worth w points
    (b) Arriving at a level FIRST (i.e., first one to arrive at a level) is worth dw/2 points.
    (c) Each treasure piece is worth v points
    The winner is the player with the highest total number of points from all the tokens that they control.

Board Components

The following components (data structures) have been modified/added from Project 2:

  • (NEW) Maze - A Maze is a weighted directed graph leading from (one of several) starting points (nodes without incoming edges))towards one or more exits (nodes without outgoing edges). The weights of the edges range from 1 to the maximum value of the edge, i.e., the token moves through the graph using rolls of the dice by matching the value of the roll with the edge weight. At each exit point, there will be a treasure pot (infinite size) that rewards the token with a number of pieces equal to the total weight of the traversed path.

The program will be given a list of filenames as part of the command line input. Each file contains descriptions of a graph (MAZE). The file consists of multiple lines each with the following format:

<node name> - <node name> edge weight

Your program will read the information for each graph, build the corresponding graphs, identify the entry points (nodes with no incoming edges) and exit points (nodes with no outgoing edges). For each graph, it will place the incoming and exit points at random positions in the board subject to the existing constraints (e.g, only one treasure pot/hold on each tile, and no holds on the last row of the board).

Program Behavior

The program behaves as specified in the description for project 2.

Program Inputs

The following inputs will be through the args[] array in main() in the following order.

  • n - the maximum value returned by the dice (must be greater than 1)
  • k - the number of players (must be greater than 1)
  • j - the number of tokens per player (must be greater than 0)
  • the name of the config file
  • a list of file names (graph descriptions) with a space separating them. You can determine the number of items in the args[] array using args.length

The configuration file will specify the components in this incarnation of the program and will have the following content. Each line can be one of:

  • board x y z the length of each of the 3 dimensions of the board
  • values w v the values of finishing and the value of each treasure piece
  • treasurePotA [percentage frequency] [number to remove] [nuomber of removals]
  • treasurePotB [percentage frequency] [initial total]
  • Hold [percentage frequency] [min value of factor] [max value of factor]
  • PriorityHold [percentage frequency] [min value of factor] [max value of factor]
  • HoldQ [percentage frequency] [min value of factor] [max value of factor]
  • JStack [percentage frequency]

An example config file can be found on moodle.

Project Constraints

The following constraints apply to the project:

  1. The project is to be completed individually. The only person you can consult is the instructor.
  2. Each configuration of parameters should be run at least 5 times with different random seeds to obtain an “average” value.

Simplifications

You can simplify your project in one (or more) of the following ways:

  1. only implement some of the data structures, but you must have at least one HoldQ, JStack and Maze
  2. limit the size of the board to have a maximum of 24x24x3
  3. limit the maximum number of players to 3 but each player has to have at least two tokens,
  4. have 2 game playing strategies.

Report

Your simulation and report should try to answer questions (you should design your own questions) like the following:

  1. What game playing strategy works best? (You will need to develop some strategies - some of them can be quite “stupid”) Is there a different strategy for:
    (a) finishing first,
    (b) being the first team to finish,
    (c) amassing the maximum amount of pieces,
    (d) amassing the maximum amount of points,
  2. what are the effects of changing:
    (a) the frequencies of the various aids and obstacles
    (b) the minimum and maximum factors of the holds