美文网首页
讲解:OOG、Java、programmer、JavaDatab

讲解:OOG、Java、programmer、JavaDatab

作者: bingernai | 来源:发表于2020-01-10 12:52 被阅读0次

AtominationWelcome to Object-Oriented-Games (OOG)! As the new programmer here, you will be tasked with creating ademo for the game called Atomination. You will write a game called Atomination. You will be tasked withwriting this game using the Java programming, utilising everything you have learned over the semester.This game revolves around placing atoms on a grid-based game board. Each grid space has a limit of howmany atoms it can contain. Once the limit is reached, the atoms will expand to the adjacent grid spaces. Thissimple rule exhibits an interesting property where chains can be triggered by a single placement. This acts asa mechanism to capture other grid spaces from your opponents.The game will be accompanied by a number of utility functions for players to utilise such as saving the game,game statistics and loading games. You will also need to implement a set of commands that will allow theplayers to interact with the game.Implementation DetailsWrite a program in Java that implements the game atoms. The sample test cases on ed will only contain validinput command, it is up to you to handle any invalid input. Commands are case sensitive.Game rules and features:There is a game board that is n x m grid spacesThere are k players and each player takes a turn starting from player 1. there is a minimum of 2 playersand a maximum of 4 players per a gameInitially a grid space is unoccupied until a player places an atom in that grid spaceA player can place an atom on a grid space that they already own or is unoccupiedIf the grid space is a corner, then the limit is 2If the grid space is on a side then the limit is 3If the grid space is neither a corner or a side space then the limit is 4 (The pattern is the adjacentgrid spaces)Once a grid space has reached its limit ( number of atoms >= limit ), a single atom will expand out tothe adjacent grid spaces, capturing them if they are owned by an opponentAfter the first k moves (k being the number of players in the game), players can be removed from thegame if they no longer own any grid spacesPlayers can undo moves that they have performedThe maximum width of the board is 255, the minimum width is 2The maximum height of the board is 255, the minimum height is 2You may assume the maximum line length is 255There is an option to save the game and load it when the program has been reloadedThe player colour order is RGPB (Red, Green, Purple, Blue)The user interacts with a set of commands that are specified later in this documentSave file specificationThe file header contains: 1 byte for width 1 byte for height 1 byte for player After the header, the move datawill fill the rest of the file until the end of the file.Each move is encoded into 4 bytes, the first 2 bytes are used for coordinates, storing x and y respectivelywhile the remaining 2 bytes is empty padding, simply containing a value of 0.You have been provided a scaffold to help you get started with your application.Player.javaGrid.javaPart 1 - Game LogicHelpProvides a list of commands, elaborating on each functionality.public class Player {private int gridsOwned;}public class Grid {private Player owner;private int atomCount;}HELP displays this help messageQUIT quits the current gameDISPLAY draws the game board in terminalSTART starts the gamePLACE places an atom in a grid spaceUNDO undoes the last move madeSTAT displays game statisticsSAVE saves the state of the gameLOAD loads a save fileSTART The start command will accept 3 arguments, the first argument is the number of players and the last twoarguments outline the dimensions and of the game board.If any of the input is invalid (width or height or n) are negative digits or character values, the application mustrespond with:If the argument length is less than the required number (3) the program should respond with:The number of arguments is greater than the required number the program should respond with:The START command cannot be used after the START command has been successfully executed. If this case ispresented the program should respond with:When START command is successfully executed the program should respond with, the colours are assumedto be in this order: RGPB (Red, Green, Purple, Blue).STATDisplays the current state of the gameSTAT cannot be executed unless a game has been started, if it is executed in this state the program shouldrespond withWhen executed successfully the STAT command should display the current statistics related to the players.Invalid command argumentsMissing ArgumentToo Many ArgumentsInvalid CommandGame ReadyRed’s TurnGame Not In ProgressPlayer Red:Grid Count: 5Player Green:Grid Count: 2In the account where a player has given up or has been removed from the game the STAT command shouldshow. (In this example Player P gave up).When printing out the the players, it will be from first index to last. The player colours are in the order: RGPB(Red, Green, Purple, Blue).PLACEPlaces an atom at an x, y position on the game board that is associated with the player‘s turnIf the argument length does not equal two then the program should output Invalid CoordinatesIf the x value is less than 0 or greater than or equal to the width and/or If the y value is less than 0 or greaterthan or equal to the height then the program should output:If the grid space selected is not owned by the player or is not unoccupied:In the case that PLACE command has not be executed successfully, the program should be ready for anothercommand:On success, the program should respond with whose move is next:In relation to expansion (when the grid space has reached its limit), the expansions move clockwise startingwith the grid space that is y-1.After a PLACE command is entered and only one player is remaining after it successfully executes, theprogram should respond with and quit:Player RedGrid Count: 5Player Green:Grid Count: 3Player Purple:LostInvalid CoordinatesCannot Place Atom HerePLACE -1 -1Invalid CoordinatesPLACE 0 0Red’s TurnPLACE 2 1Red’s TurnDISPLAYDisplays the gameboard using + to denote the corner and two – to denote the colour and the number ofatoms located.Example OutputEmpty spaces denote unknown grid spaces while (R1) denote the owner and the number of atoms in that grid space.Once a player has made a move, it is up to the will of the next player to let the other player undo it. We are topretend that this game involves hotseating and therefore it is agreed upon the players if they are to allow anundo.In the case that we perform UNDO at start of the game, the program should output:QUITQuits the game, if the game has started it will quit the game early and not declare a winner.Save the current state of the game with a filename.You will need to adhere to the save file structure previous outliend. The file is saved as a binary file, whichcontains game information stored in header of the file and player moves afterwards.After the header has been read, the rest of the file can be assumed to contain only player move data, eachmove is encoded as a 32bit unsigned integer (4 bytes). Each 32bit integer can be extracted as x (1 byte), y (1byte) coordinates with the additional 2 bytes acting as 0 padding afterwards.When creating a save file, your program does not need to include any move that has been undone, only themoves that have result in the current state of the board.This command creates a file and saves the current game details and move set, if a file already exists with thisname the method should not attempt to save the file and output:On success, the program must outputLOADLoad command takes a filename as an argument, if that file does not exist the prograOOG留学生作业代做、代写Java编程设计作业、代做programmer作业、代写Java课程设计作业 代写Databam should remain in itsoriginal state and output.If a game has already started or load has been executed successfully, subsequently load commands shouldnot attempt to load a new game and instead the program should respond with:If the command is executed successfully the program should respond with:File Already ExistsGame SavedCannot Load SaveRestart Application To Load SaveGame LoadedPart 2 - TestYou will need to write your own test cases to ensure that your program covers as many cases as possible. Forthis assessment, you will need to create JUnit test cases for your application.Test cases must be written in a JUnit test case file named AtominationTest.java . You will need to have aseries of test cases that check each method and the game state. Try to develop test cases while working onPart 1. This will help with speeding up your development by maintaining a test suite of the requirements.Part 3 - GUIYour task is to prepare a demo for all the backers of the game Atomination. This part requires the following:Create a window of 640 by 384 (width, height)Render 10 x 6 grid with each grid being 64 x 64 (width, height)Detect a mouse click on a grid space and call the place method.Change the sprites of each grid to be based on the number of atoms exist in each gridYou have been provided a scaffold, library, documentation link and assets for constructing the GUI. Updatethe build.sh file to allow you to quickly build and test your program.The library Processing contains documentation that will help with implementing each segment.Create Window and Render Tiles (0.5 marks)Use tile.png for each tile to make a grid that players can select. The grid created must also reflect thenumber of grid spaces that exist in the game. The demo is just a singular configuration (10x6).Implement the following in the setup , settings and draw methods. Use the following methods associatedwith the AtominationGUI scaffold class.size(int width, int height), This will need to be used in the settings method.loadImage(String path)image(PImage image, int x, int y, int width, int height)User Interaction and play (1.5 marks)Mouse eventYou want people to play your game, this will require you implement the mouseClicked event in theAtominationGUI . Once a user has clicked on a tile, your program must respond by showing an atom placed inthat tile. Use the MouseEvent object to retrieve the current mouse coordinates on the screen.Since there are many tiles, your program must deduce what grid space it clicked.DrawingThe draw method within the AtominationGUI class is called 60 times a second (as specified by theframerate method, use this method to continue to render the sprites on screen. You may want to cleareverything before you paint the grid spaces and atoms on screen.Each grid space maintains information in relation to how many atoms and the owner of the grid, use thisinformation to select which sprite to draw. Use the following methods associated with the AtominationGUIscaffold class.loadImage(String path)image(PImage image, int x, int y, int width, int height)background(int rgba)Deviation from CLI Program (1 mark)We will be checking to see if program has deviated significantly from your command line version. Yourprogram should attempt to utilise majority of your existing code without modification.How this game works and examplesThe graphic designers have created a mock-up video, showing how the game will be played. You can accessthis video from the online discussion board (Ed).Included are a couple more GUI images of how a game will play out.Algorithms and FunctionsExpansion and placeWhen a grid space has reached capacity, it will expand to the adjacent grid spaces. This may create a chainreaction for other grid spaces that have reached their limit. The expand function is invoked once the numberof atoms has reached the limit a grid space can contain from the place function.2D AABB (Axis-Aligned Bounding Box)A simple collision/box intersection detection function allows your for program to detect when two rectangularshapes have intersected. This is a general algorithm that checks for an overlap between two shapes, returningtrue if an overlap has occurred. You will need to utilise this function for Part 3.Submission DetailsYou are required submit your assessment by Sunday Week 13 (11:59pm).Your code and tests must be submitted using Ed. You can upload your files in the assessment page of theappropriate assessment. You are encouraged to submit multiple time, but only your last submission will bemarked.The submission for PART 3 must uploaded and submitted with the rest of your code on ed. Update thebuild.sh file to assist with building your GUI program.expand(grid, x, y):if (y - 1) >= 0 && (y - 1) place(grid, x, y-1)if (x + 1) >= 0 && (x + 1) place(grid, x+1, y)if (y + 1) >= 0 && (y + 1) place(grid, x, y+1)if (x - 1) >= 0 && (x - 1) place(grid, x-1, y)aabbintersect(box1, box2):return (box1.x ((box1.x + box1.width) > box2.x) and(box1.y ((box1.y + box1.height) > box2.y)MarkingYour program will be marked automatically by Ed, Please ensure that you carefully follow the assignmentspecification. Your program must match the exact output in the examples and the test cases on Ed. Yourassessment is worth a total of 12 marks.6 marks for automatic marking, these test cases will be available on Ed and will test the correctness ofthe CLI program.3 marks for testing and manual marking, Your program will need to test the internal structure of yourcode and replicate some simple user input. Examples include, checking the grid array if certain gridspaces are occupied, checking grid space owners once an expansion has occurred.3 marks for graphical user interface, as part of manual marking, your application will be assessed inregards to how accurately you have represented the game in a visual form and how much you havemodified from the CLI variant.Warning: Any attempts to deceive or disrupt the marking system will result in an immediate zero for theentire assignment. Negative marks can be assigned if you do not properly follow the assignment specification,or your code is unnecessarily or deliberately obfuscated.Academic DeclarationBy submitting this assignment you declare the following:I declare that I have read and understood the University of Sydney Student Plagiarism: Coursework Policy andProcedure, and except where specifically acknowledged, the work contained in this assignment/project is my ownwork, and has not been copied from other sources or been previously submitted for award or assessment.I understand that failure to comply with the Student Plagiarism: Coursework Policy and Procedure can lead to severepenalties as outlined under Chapter 8 of the University of Sydney By-Law 1999 (as amended). These penalties maybe imposed in cases where any significant portion of my submitted work has been copied without properacknowledgement from other sources, including published works, the Internet, existing programs, the work of otherstudents, or work previously submitted for other awards or assessments.I realise that I may be asked to identify those portions of the work contributed by me and required to demonstratemy knowledge of the relevant material by answering oral questions or by undertaking supplementary work, eitherwritten or in the laboratory, in order to arrive at the final assessment mark.I acknowledge that the School of Computer Science, in assessing this assignment, may reproduce it entirely, mayprovide a copy to another member of faculty, and/or communicate a copy of this assignment to a plagiarismchecking service or in-house computer program, and that a copy of the assignment may be maintained by theservice or the School of Computer Science for the purpose of future plagiarism checking.转自:http://www.7daixie.com/2019052031703267.html

相关文章

网友评论

      本文标题:讲解:OOG、Java、programmer、JavaDatab

      本文链接:https://www.haomeiwen.com/subject/mpvpactx.html