程序代写代做 graph Java javaFx AI game 1006 EXAM ASSIGNMENT (Assignment 4)

1006 EXAM ASSIGNMENT (Assignment 4)
This assignment in in place of an course final exam. It is intended to be done individually and without getting help other than to ask the professor or TA’s questions via the culearn forum during the assignment coding time.
Here are some important rules that need to be followed when doing this assignment.
1) The assignment must be completed by you alone without help from others. You may ask questions on the culearn forum where everyone can see them as well as the answers. No private questions by email will be answered. You may google the topics and borrow bits of code from online but not entire solutions.
2) Your answer code must be submitted by the due time to culearn and when graded the assignments will be run through anti-plagiarism software/servers to detect submissions that are too similar (in which case both will get a mark of 0).
3) The assignment uses concepts from the course including things demonstrated in tutorials and assignments. There are no new concepts just a new application being built. There is only one requirement that pertains to tutorial 10, all other concepts are from previous work.
4) Try to satisfy as many of the requirements as you can. The grading will be like that used for the assignments using the requirements marking scheme below. Some of the requirements ask for specific classes or methods and what they should do. You are free to add whatever other classes or methods you want.
IMPORTANT: (These instructions are the same as was for your course assignments). To do this must first have set up your machine by installing java JDK 13.x.x, IntelliJ IDE and run through the “Setting Up Intelij for JavaFX” in the 00 Hello World section of the course notes as was done for tutorial 03. These notes explain how to obtain and install the JavaFX components you will need to compile the demo code.

Marking: This assignment is based on 14 design requirements numbered R1.1…R5.3 for a total of 28 marks.
Marks are awarded, or deducted, based on requirements as follows:
Req Type
Assignment Grading
R0.x
Critical Submission and Intent Requirements. Assignment gets 0 if any critical submission
requirement (shown in red) is not met.
R0.x
Good Practice Requirements. You lose 2 marks for each good practice 
requirement (shown in amber) not met.
Rx.x
Design Requirements. You earn 2 marks for each design requirement (green) satisfied and well implemented; 1 mark if it’s partly met or met but not well implemented; and 0 if it’s not met or attempted.

Submission and Good Programming Practice Requirements
The following requirements pertain to all your assignments regardless of what your application is supposed to do (i.e. regardless of the design requirements). These requirements are to ensure that your code is usable, readable, and maintainable.
R0.0 UNIQUENESS REQUIREMENT. The solution and code you submit MUST be unique. That is, it cannot be a copy of, or be too similar to, someone else’s code, or other code found elsewhere. You are, however, free to use any code posted on our course website as part of our assignment solution or code from your own course assignments. [Assignment mark =0 if this requirement is not met.]
R0.1 CODE SUBMISSION ORGANIZATION AND COMPILATION: You should submit all the code files and data files that make up your Intelij java project. The TA’s will open your project with Intelij, build the project and then run the application from your class whose name contains the substring “Main”.
IMPORTANT: The assignment mark is 0 if your code does not compile and launch.

[Assignment mark =0 if this requirement is not met.]
 
R0.2 README FILE: Your submission MUST include a README.txt file telling the TA how to launch and run your app. The TA should not have to look into your code to figure out how to start up your app. Your README.txt MUST contain the following:
• Your name, student number and email address.
• Version: The java JDK version you were compiling your code with.
• Setup Instructions: Are there any setup instructions like making sure a data file is located in a special place. Typically this section might just say “None”.
• Launch and Testing: Tell us which class in your app has your main() function in it. You should only have one main() function in your application. If there are specific tests you want the TA to perform tell us what the steps are you want them to perform.
• Issues: List any issues that you want the marker to be aware of. In particular, tell us what requirements you did not implement or that you know are not working correctly in the submitted code. Here you are giving us your own assessment of your app.
 
R0.3 INTENT REQUIREMENT. Your solution must be in the spirit of the intent of the assignment. For example, if you hard-code answers rather than writing code that solves the intended problems you would be violating the assignment intent.
 
R0.4 VARIABLE AND FUNCTION NAMES: All of your variables, classes and methods should have meaningful names that reflect their purpose. Don’t follow the convention common in math courses where they say things like: “let x be the number of customers and let y be the number of products…”. Instead call your variables numberOfCustomers or numberOfProducts. Your program should not have any variables called “x” unless there is a good reason for them to be called “x”. (One exception: It’s OK to call simple for-loop counters i,j and k etc. when the context is clear and VERY localized.)
Remember: any fool can write code that a computer will understand; the goal is to write code that we can understand. [Minus 2 marks from assignment if this requirement is not met.]
R0.5 COMMENTS: Comments in your code must coincide with what the code actually does. It is a common bug to modify, or cut-and-paste code, and forget to modify the comments and so you end up with comments that say one thing and code that actually does another. Don’t over-comment your code – instead choose good variable names and function names that make the code “self commenting”. Don’t be reluctant to create local variables so that the variable name provides more clarity -there is no prize for having the fewest lines of code. [Minus 2 marks from assignment if this requirement is not met.]
R0.6 CITATION REQUIREMENT: If you use code from other sources you should cite the source in comments that appear with the code. If the source is an internet website then put the URL in the comments. You may use bits of code from outside sources but this may not form the complete solution you are handing in.You DON’T have to cite demo code we provide on the course web site or with tutorials and assignments, however that code should not be used for things you post publicly (like on GitHub). [Minus 2 marks from assignment if this requirement is not met.]
VERY IMPORTANT: Any sample code fragments provided may have bugs (although none are put there intentionally). You must be prepared to find errors in the requirements and sample code. Please report errors so they can be fixed and an assignment revision posted.
 

Design Requirements
 

The assignment is to built a Tic-Tac-Toe game (aka X’s and O’s) in which the player, who is “X”, plays against the application, which is “O”. The game should be built using the basic window-with-canvas code used for the various tutorials and course assignments. The user plays by dragging “X” tokens onto the Tic-Tac-Toe board area after which the application will automatically play by moving an “O” onto the board area. When a game is over the app should show who won, if any. If necessary review how Tic-Tac-Toe works by searching online. Here are the detailed requirements.
Note there is no need to use recursion in this assignment unless you want to.
 
Board Requirements
R1.1 Their should be a class called TicTacToeMain that contains the launch point (the public static void main(String[] args) method). There should be a class TicTacToeGame that implements a drawInArea() method to draw the game board and is also reponsible for representing the state of the game and deciding if moves are legal or not etc.
R1.2 The game should have a Tic-Tac-Toe board drawn using 4 lines. The intersection of the four lines should form the 9 playing squares. The Window’s title should be “Tic-Tac-Toe”. The board area should be near the center of the window with enough space around where the unplayed CX and O tokens can be located.
R1.3 The game should have a “Reset” menu and menu item that will reset the game and clear the game board by positioning all the “X” and “O” tokens somewhere not on the board area (maybe off to the side or something like that).
 
X,O Token Requirements
R2.1 The game should have shapes, or characters, to represent the X’s or the O’s that will be dragged, or moved, onto the game board squares. These should be represented using a superclass Token with two subclasses PlayerToken and OpponentToken. Any variables the refer to tokens should be of type Token (e.g. Token x_token1 = new PlayerToken()) . Similarly and containers of tokens should contain items of type Token (e.g. Arraylist tokens ) All three classes should implement a drawWith() method that should be called when the token is to be drawn. The superclass Token’s drawWith() method should be just an empty method or an abstract method if you want. So the code structure for the tokens should be (you can add variables and more methods if you want):
public class Token {
public void drawWith(GraphicsContext thePen){
//empty code
}
}

public class PlayerToken extends Token {
public void drawWith(GraphicsContext thePen){
//code for drawing “X” tokens
}
}

public class OpponentToken extends Token {
public void drawWith(GraphicsContext thePen){
//code for drawing “O” tokens
}
}
R2.2 When the application starts, or is reset, the “X” and “O” characters or shapes should be displayed on the canvas along the sides or top and bottom but not be in the board area. There should be 5 X’s and 4 O’s. (X alway plays first.)
 
Player “X” Moves
R3.1 The user, or player, moves by dragging an “X” with their mouse onto the game board area. The player should not be able to move an “O”.
R3.2 If the player moves an “X” to an illegal position (e.g. an occupied square) the move should be rejected and the “X” token should return to its original position expecting the player to move again. (This return to original position could be instantaneous or animated it’s up to you.)
R3.3 When the player moves an “X” they should be able to use any of the unplayed “X” tokens. That is, it should not be necessary to play the X tokens in a particular order.
R3.4 Once an “X” is moved onto the board in a legal position and released the player should not be able to move that token again.
 
Application “O” Moves
After each player, or “X”, legal move the application should make a counter move using one of the “O” tokens. Here are the specific requirements.
R4.1 When a player has made a legal move the game should make a counter move and move one of the “O” characters on an empty board square. The “O” moves must be legal and should not, for example, result in an “O” being played on an already occupied square.
R4.2 The “O” move should be animated. That is, the “O” token should slide from its off-board postion to the game board position in the same way as tree nodes slid into position in the tree-based recursion tutorials in the course.
 
Game Logic
You should put the game logic in the TicTacToeGame class. This logic should decide when moves are legal and when a game as been won or ended in a tie.
R5.1 If the player or the application wins then the application should show that by highlighting the winning row of “X’s” or “O’s” or drawing a line through those tokens (choice is yours). For example, draw those “X’s” or “O’s” in a highlighted colour.
R5.2 When the application makes an “O” move the move should be defensive. That is, it should not just be random but it should try to keep the player “X” from winning.
R5.3 The application’s defensive moves should be effective. That is, it should NOT be possible to beat the application, rather it should always make a defending move so that either the game ends in a tie or “O” wins. Note it’s expected that you should be able to do this with a half dozen or so well chosen if-statements. We are not expecting any involved AI (artifical intelligence) nor is any necessary to do this. There is discussion on the internet about fancy and involved ways to do this but none of that is necessary particulary since we are not looking for a winning strategy for “O” only trying to prevent “X” from winning.
 
Good Luck.