



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CSCE 1040 Due: Various Times Throughout the Semester Let the Tank War Begin! Throughout the semester, we will be working on a derivative of a tank class, and any related classes needed to implement this class. Ultimately, this class will be used in conjunction with existing game engine code to allow a single elimination tournament of tank warfare. Each game will consist of 10 games of your player class against your opponents’ player class. The winning player will advance to the next round and earn a higher maximum possible point value for the assignment. The overall winner will receive a guaranteed homework average of
} where r and c are the row and column to which you would like to fire. There is a board object that displays the world, keeps track of the score, etc. You are not passed a copy of the game board when your do_your_thing() method is called, however, you are passed many pieces of information via the sensors class. class sensors { // class for info passed to each player on their turn int turn; // turn number location me; // locations for the relevant game elements location opp; location mybase; location oppbase; boolean opp_pillage; // flags for if certain events are occurring boolean on_mine; // true if am I standing on a mine boolean just_hit; // true if I was hit by a tank shell status look[9]; // contains lookaround info 1 square in each direction int myammo; // my remaining ammo int mymines; // my remaining mines int myscore; // my score int oppscore; // my opponents score } int turn – the turn number starts with 1 at the beginning of each game. You can retain the information you have about how your opponent plays between games, and use this to determine when a new game has started. Turn is 1,2… so it is your turn count, not the overall game turn count (each player takes a turn in sequence). If turn==1, a new game has started with new player locations and base locations, but you can maintain your information on your opponent’s behavior from the previous games. You can get smarter each game. Try to learn if your opponent always runs for your base and then finds an obstacle and fires. location me – your location on the board location opp – your opponent’s location location mybase – where your base is located location oppbase – your opponent’s base boolean opp_pillage – true if your opponent is sitting in your base earning points (pillaging) boolean on_mine – true if you are on a mine boolean just_hit – true if you were hit by a shell last time. This is not the same as determining if your opponent fired last turn – it just tells you if you were hit. status look[9] – an array of the squares around you. This is only for determining if there are obstacles or powerups 1 square around you. It does not return base or other player location information, as this information is provided in the sensors class. look contains an array of 9 status elements corresponding to the status of the 9 squares surrounding a given player. Each number represents the index in the array returned 012 345 player is at location 4 678 If an obstacle is directly north of you, look[1] == obs. This can also reveal pu_ammo, pu_mines, or pu_points (the various power-ups). These are displayed as ‘b’ for bullets, ‘m’
Scoring The point values are in Setups.java. No points are ever subtracted, but your actions may increase the score of the other player. Stepping on a mine or moving over an obstacle will increase your opponent’s score, although on an obstacle, you are significantly harder to successfully fire upon. Hitting your opponent with your gun, finding the point power-up, or sitting on their base (pillaging) will increase your score. The game is over when the first player reaches a predefined max score. Getting Started and Modifying the existing classes Your class must derive from the base class tank. Your class is_a tank. Do not modify the tank class. The tank class includes sample methods that the sample players (garlick and player) use. These methods are naïve, however, as go_to_opp_base moves in a predictable line, and fire_at_opp fires at where the opponent is, and not where you think they will be. Feel free to override these methods with more sophisticated versoins in your class. You will also probably want to maintain some state information in your class about you and your opponent. Your constructor should set your name data member to your first and last name. Your class name will be the same as your last name, in all lower case. The existing classes can be found at http://www.cs.unt.edu/~garlick 2 player classes (player and garlick) have been included to see how it works, or to play against your class when it is created. You can also play your class against itself to modify your strategy. Rules and Disqualification No one will forfeit unless you do not return a move at all, but there are many ways to do the equivalent of setting your move to sit, and just sitting there is generally a bad idea when someone is pointing a 120mm gun at you: Attempting to move on top of your opponent will not work (sorry, no ramming). Moving out of bounds does not work – you will just sit at the edge. Dropping a mine when you have no mines left. Firing when you are out of ammo Returning the “fire” action but not filling in the aim class Trying to drop a mine directly on top of a base Dropping a mine on top of another mine (you will lose a mine for doing this) Please also no printing to the screen from your final turn-in, so as not to disturb the display of the game. Do not instantiate objects of other people in the class, or rely on any modifications to given code, including the tank class.
General strategies Use the constants defined in setups. Use num_mines instead of 5. ANY OF THE CONSTANTS MAY CHANGE SLIGHTLY FOR THE FINAL BATTLE. This includes the size of the game board. I will not change ammo to 10,000, because that would modify your strategy in general, but your code should be robust for changes. Hard coding numbers instead of the constants in the setups class is dangerous. As always, please do your own coding on this, but feel free to challenge your classmates to a test match. Any duplicate or near duplicate submissions with current or former students will forfeit the tournament and you will split whatever measly points you earned with your co- conspirator. You should test your class to make sure everything is working. I would also recommend trial runs of your class playing against itself, or someone else in the class in order to fine tune your strategy. Notes When turning in your homework (to be assigned throughout the semester) Please attach your_last_name.java in an e-mail to [email protected] with the subject line: CSCE 1040 Homework xxx – your last name. Replace the xxx’s with the assignment number and your last name with your last name. So my turnin for HW4 would have the subject: CSCE 1040 Homework 4 - garlick