Write player classes that have certain behaviour

Assignment Help JAVA Programming
Reference no: EM131159893

Capture the Flag Project

Capture the Flag

In this project you will implement the game Capture the Flag. If you are unfamiliar with the game, you can read about it here:

There are many variants of the game (as you can see from the wiki document). For our game, the rules will be defined below in this project document.

1: The Basic Game Rules

Capture the flag is a game played by two teams, which we'll refer to as team 1 (Blue team) and team 2 (Red team), on a playing field which is divided into two territories.
Each team in the game has
- a "territory" on the playing field (side 1 or side 2),
- a "base" that is located somewhere in their territory,
- a "jail" that is located somewhere in their territory,
- six or more players, and
- a "flag" (that is initially located at their base).
The object of each team is to capture the opposing team's flag and bring it back to their base. The first team to do this wins the game.
There are several notions of being "caught" in the game that depend on where a player is and if they have the flag or not. Being caught essentially means an opposing player is "close enough" to them to catch them.
- When a player is in the other team's territory and they are caught by an opposing player they are taken to the other team's jail. If that player is also holding the other team's flag then the player is taken to jail and the flag is dropped where it is.
- When a player has the other team's flag and is in their own territory (trying to bring the flag to their base) and they are caught by an opposing player the flag is returned to the other team's base and the player resumes its actions. The player is not sent to jail.
- When a player is in their own territory and is not holding the other team's flag they cannot be caught.
When a player is caught and sent to jail they will remain in jail until another player on their team, who is not in or being taken to jail, "frees" them. A player frees a teammate by being "close enough" to them.

2: Classes in the Game

There are several classes involved in the game. Some are provided and should not be changed (alter at your own risk!), some are provided and need to be completed, and some you will need to create.

The "things" in the game all extend an abstract Entity class.

967_Fig.png

Entity: This abstract class provides the base for "things" in the game such as players, flags, jails and bases.

Player: A direct child of Entity, this abstract class contains the basic framework for all players in the game.

DummyPlayer: A provided concrete player that doesn't do much. It is used to get the game up and running as a starting point.

Your own Players: You will implement several different kinds of Players that behave dif- ferently in the game.

Flag: A direct child of Entity, this is for the two flags in the game. They will not do much in a basic game (just keep a location).

Jail: A direct child of Entity, this is for the two jails in the game. They will not do much in the basic game (just keep a location).

Base: A direct child of Entity, this for the two the bases in the game. They will not do much in the basic game (just keep a location).

Team: You will create a Team class that holds a team of players.

Field: This class provides the base for the playing field and for overseeing the actual game.

View, SpriteStore, Sprite: These classes provide graphics for the game. You do not need to modify these.

CaptureTheFlag: This is the game itself. It drives the game (with a main method).

EntityOutOfBoundsException: This is an exception that will be thrown whenever a player leaves the field.

In Assignment 5, you are asked to write some player classes that have certain behaviour. These classes will lead you along to implementing the players you will need for the project.

3: The Players
In a game of capture the flag each team will have six or more players. You will implement five different behaviours for them. In particular, you will need to implement the following.
- Players that try to capture the opponents flag and bring it back to their home (to win)
- Players that try to catch opponents (so that they go to jail)
- Players that try to free their teammates from jail
- Players that are defenders of their base (trying to catch opposing players)
- Players that try to defend against (catch) flag carriers
All the players must stay in the playing field at all times. You will throw an EntityOutOfBoundsException object when a player leaves the field.

4: The Team Class
Write a Team class that has a constructor

public Team(Field theField, int numberOfPlayers)

You can add other constructors if you wish. The purpose of the Team class is, as the name suggests, to represent teams in your game. The intention is that your CaptureTheFlag game will have code similar to

Team reds = New Team(field, 24); Team blues = New Team(field, 24);


which creates, initializes and registers all players that will be playing in the game. This will replace the for loop that creates players in the main method of the provided CaptureThe- Flag.java file.
You'll have to make some decisions about what to do with Team. In a basic implemen- tation, it should be able to create different teams for the game. You may add any new constructors and methods as needed.
An important component of the project is that you must present your code to be evaluated while it is running. In order to do this, you need to run the game with different scenarios so that different (needed) behaviour of your players is observable. In order to do this, your Team class should be able to create the following teams:
- A full team with at least one of each of the required types of players (from above). This will be used for playing the game.
- A team with any number of different players. For example, you should be able to easily create a team with a single player that tries to capture the other team's flag. Such a team is useful so that we can easily test each different kind of player.
If your project team has not completed all the different players, just include all of those that you finished. If you do not finish the Team class, be sure that your submission allows for easy demonstration of each different player that is completed.
For full marks for the Team class, you will need to have methods that allow for reading a
team from a text file. The file should include all player information and also team stats like how many games they have played and how many wins/losses. After a game is completed, you should update (rewrite) the team file with the updated stats.

5: The Field Class
Finish the incomplete methods in the Feild class so that your players can play the game. In particular, you should write code for or modify the existing code in
- winGame
- freeTeammate
- pickUpFlag
- catchOpponent This code is not robust but works.
There are several (empty) methods in the Player class that you can implement to help you with your implementation of the Field methods. (The methods should provide some functionality to allow a player to know, for example, if it has the flag or if it has been caught. Add any other methods, like isInJail or hasFlag, as you need.)

6: Extending the Game
The project is worth 10% of your final grade. You can receive bonus marks by extending the game beyond what is asked for here.
Extensions include, but are not limited to

- Add other Entity classes to the game; rocks, trees and other obstacles. Do not allow the players to walk through the obstacles.
- Adding new players with logic for players that go beyond the basic behaviour described here. For example, a player that tries to capture the flag will not go directly to the flag but might try and go around and behind it to avoid being caught.
- Having a player change teams after they have been caught twice.
- Limiting the "vision" of the players. For example, each player might only be able to see things in a given radius around them. A hunter player would be needed to find the flag.
- Allow some players to run fast for a while, but then get tired and move slower than normal.
- Have messages displayed on the bottom message window of the View that gives a play- by-play of the game. (That is, it displays messages when things happen in the game. For example, "Cat from team ravens picked up the flag", "Dog from team geegees went out of bound", "Akhil from team geegees was caught and sent to jail by Stanley".)
- Make the message (above) scroll across the message window.
- Anything that you think would be cool to add to the game.

Note: You do not need to "complete" the basic game to add extras. You can still receive extra marks as long as the extra thing you are adding works and we can be visually confirm them in your presentation. Marks will be based on the difficulty of the extra added.

7: Evaluation

Your grade for the project will come from three different components
- The quality of the code presented.
- Your answers to questions during the demonstration.
- Peer evaluation.

If everyone in the team contributed, roughly, the same to the project then your grade will be the project demo mark.

Verified Expert

The assignment was to extend the player class of 'The Capture Flag game' and develop 5 sub classes. Stopping class stops the players going out of the boundary. Seeker class seeks the flag of the opponent. Random Walker walks around randomly but voices back once it reaches boundary. Chaser class chases the opponent and follows it once it reaches arms length. Catcher class catches all opponent team members.

Reference no: EM131159893

Questions Cloud

Economics play a role in decisions of the organization : The research paper should be around information on a company. The research on the company must: Include a brief summary of the organization. Explain how the of transportation economics play a role in decisions of the organization.
Discuss in detail how to calculate net present value : Discuss in detail how to calculate net present value. In addition, explain why profitability, as a result of a purchase, must equal or exceed the cost of capital or purchase to be deemed worthy.
Determine the distribution of shearing stresses : The cantilever beam shown consists of a Z shape of 1/4-in. thickness. For the given loading, determine the distribution of the shearing stresses along line A9B9 in the upper horizontal leg of the Z shape.
Department of health and the federal government : You have been employed as an economist to advise the Department of Health and the Federal Government about the following issue. The minister has argued that raising the tax on alcohol is the most effective way to reduce alcohol abuse in our societ..
Write player classes that have certain behaviour : Write player classes that have certain behaviour. These classes will lead you along to implementing the players you will need for the project.
Effect of an increase in government purchases : The economic effect of an increase in government purchases is likely to depend on how the purchases are financed. Explain how an increase in G is increases output and employment if financed by a lump-sum tax (or debt), but is likely to decrease ou..
Compute the weighted average cost of capital : Compute the weighted average cost of capital. Which project(s) should be accepted? Compute the yield to maturity on the old issue and use this as the yield for the new issue.
Economist in the study of welfare economics : Give a reason why it is important as an economist in the study of welfare economics to analyse the degree to which individuals or firms, or any economic agent, responds to incentives.
What is protectionism and trade protectionism : What is protectionism? Explain what trade protectionism is, example: health and safety regulation. What are the argument favor of trade protectionism and what are some opposite or drawback of this.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Explain how a borderlayout manages its display area

Write a Java statement to make the window associated with the object from question 1 visible. Explain how a BorderLayout manages its display area. Explain how a FlowLayout manages its display area

  Design a war game that you can play against the computer

Create a Card class to store a single playing card.  Create a class called DeckOfCards that stores 52 objects of the card class.  Create appropriate constructors and methods for each class that allow for the following requirements.

  Unique index integer fields

Unique index integer fields Use at least 5 other fields of various, including at least one of each of String, int and double types. assume that the String's have no spaces within them

  Create a controller class that implements an fcfs schedule

Create a controller class that implements an FCFS schedule and instantiates 5 objects of each class and runs each object - write to the system out a number of times.

  Prepare an overloaded constructor

Prepare an overloaded constructor that provides values for each field. Also provide get methods for each field. Save the file as Patient.java.

  Describe the swing applet life cycle

Describe the swing applet life cycle. Create a swing applet that displays the date and time in a JTextField with the JLabel "Today is" when the user clicks a JButton

  Write a program that ask the user to enter a usemame

Write a program usennuftevalidator.java that ask the user to enter a usemame and checks whether the usemame meets the following criteria

  Nearest tenth of a percent

What interest rate is required to the nearest tenth of a percent, for an investment to triple in 20 years if the interest is compounded continuously?

  Pros and cons for each type of form validation

Use Google or any search engine to research the differences between client-side form validation, Describe five pros and five cons for each type of form validation

  What is server-side and client-side scripting?

1. What is Server-side and Client-side scripting? Explain the differences between server-side and client - side scripting languages. Please provide 3 advantages and disadvantages of each. Please provide applicable references in APA style

  Part a -code comprehensionusing the uncommented sample code

part a -code comprehensionusing the uncommented sample code has been provided in moodleanswer the following questions1.

  Application using arrays to manage personal financial record

design a Java application using arrays to manage personal financial records which include expenditures and incomes.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd