美文网首页
讲解:COMP 2011、C++、Gomoku game、C++

讲解:COMP 2011、C++、Gomoku game、C++

作者: lanyuwa | 来源:发表于2020-01-11 21:52 被阅读0次

    COMP 2011 Programming with C++Assignment 3 Lets play Gomoku!IntroductionIn this assignment you will write a Gomoku game, which is also called Five in a Row, for 2 players. Gomoku actually hasmany variations, and we are only going to implement a simplified version of it. Essentially, it is a Tic-Tac-Toe but a playercan only win with 5 (instead of 3) connected pieces.Here is the background story:Since the board is 2D, it is natural to use a 2D array to represent the board. A simple and easy approach would be to use astatic 2D array for that. However, to make your game flexible and efficient with memory usage at the same time, a dynamic2D array seems to be a better choice. As you think about it more, it doesnt feel good. You realize, as you have almostfinished taking COMP2011, you are almost an expert in (basic) C++, you despise such an easy solution.Therefore, as you want to show off what you have learned (or just to have a good practice on a challenging topic, or just toget your knowledge in this particular topic assessed), you have decided to write this game with linked lists.We value academic integrity very highly. Please read the Honor Code section on our course webpage to make sure youunderstand what is considered as plagiarism and what the penalties are. The following are some of the highlights:Do NOT try your luck - we use some sophisticated plagiarism detection software to find cheaters. It is much betterthan most students think. It has been proven times and times again tricks dont work. We also review codes for potentialcases manually.The penalty (for BOTH the copier and the copiee) is not just getting a zero in your assignment - it is much more thanthat. It is simply not worth to cheat at all. You would hurt your friend and yourself by doing that. It is obvious that a realfriend wont ask you to get involved in a plagiarism act in any way due to the consequences. Read the Honor Codeagain before you even try to think about cheating.Serious offenders will fail the course immediately and there may be additional disciplinary actions from the departmentand university.OverviewYour solution to this assignment must be based on the given skeleton code provided in the Download section.Your task is to complete the gomoku_to_submit.cpp, and thats the only file you need to submit to Canvas.The header file has the detailed requirements. The description below is only a supplement and aims to help you understandthe assignment. You need to read both the source/header files and the webpage description carefully to get the wholepicture.Read the FAQ page for some common clarifications. You should check that a day before the deadline to make sure you dontmiss any clarification, even if you have already submitted your work then.Submission details are in the Submission and Deadline section.DescriptionPlease read the skeleton code alongside with the following description. You may also play with the demo provided in thedownload section to try the examples.The board size is customizable as you can see in the main(). The following assumes a 6x5 board, i.e., height is 6 and widthis 5.Each row is a linked list of Cells. For the definition of the Cell structure, please see gomoku.h.Therefore, in our example, we will have 6 linked lists, and their heads will be pointed by cellRowHeads[0], cellRowHeads[1],..., cellRowHeads[5].cellRowHeads[0] is the head Cell of the linked list for the first row (row 1), and that Cell itself is at the first column (column 1)of that row.The next pointer of cellRowHeads[0] points to the second Cell in the same row, and hence that cell is at the second column(column 2) of the first row (row 1). And so on.Similarly, cellRowHeads[5] is the head Cell of the linked list for the last row (row 6), and it is at the first column (column 1).It follows, then, there would be 5 Cells in each of the 6 linked lists as the board width is 5 and the height is 6. In total, thereare exactly 30 Cells. There are no dummy/placeholder Cell objects.If the given drawBoard function is called, the following should be printed, at the start of the game. You may read the code ofthe given drawBoard to help yourself understand the linked list structure and how you may use it.The numbers at the top and left are just labels for columns and rows, respectively.The dot . denotes an empty space at which either of the 2 players can place their moves.Lets say, player 1 chooses (row 2, column 3), then the board becomes:�The X represents player 1.And if player 2, which is represented by O, chooses (2, 2), then the board becomes:�The game goes on, with each player takes turns to place his/her move, the board becomes:�As it is player 1s turn, he/she decides to win the game with a move at (6, 3).�Player 1 has won vertically !!!As a result, the game finishes with a congratulation message.It is also possible to win a game horizontally:Player 1 has won horizontally !!!Or diagonally (both ways should be checked in checkDiagonal, as shown below):Player 2 has won diagonally !!!�Player 2 has won diagonally !!!In some rare occasions, it is also possible for a player to win in several ways at the same time:Player 1 has won vertically diagonally !!!You may check the main() to see how both checkings are applied.When the board is full without any player winning the game first, the game is considered as a draw game:DownloadSkeleton code: skeleton.zipDemo: pa3demo.exe *Create a standard Eclipse C++ project (MinGW gcc compiler on Windows) and add all files from the zip package to it.It is required that your program can be compiled and run successfully in the pre-installed Eclipse environment onour lab machines. If you use other IDE/compiler/OS to work out your solution, you should test your program in theaforementioned official environment before submission. Since this is already your third assignment, we will be strict with therules.Using our Windows Eclipse zipped package downloaded from the Using Eclipse at home (Windows) section here on astandard Windows machine (e.g., HKUST virtual barn) is also good enough to verify that your program can be compiled byus. The Desktop on a virtual barn machine has limited space, so you may use C:\temp there to unzip the Eclipse package.Dont leave your source code there as you logout.* The demo program is compiled for Windows. Mac/Linux/Android/whatever OS users may use any of the many WindowsPCs on campus or remotely via virtual barn (usable on a Mac/Android) to run the demo if you want.Sample OutputYour finished program should produce the exact same output as follows. Please note that sample output, naturally, does notshow all possible cases. It is part of the assessment for you to design your own test cases to test your program. Be remindedto remove any debugging message that you might have added before submitting your code.Also, after testing, make sure your submitted code can compile with the unmodified main.cpp and header file. Put indummy/empty implementation whenever needed.Lets play Gomoku! :)Please enter the size of the board.�Player X, your turn! Whats your move?Enter row and column. [1-6] [1-5]�Player O, your turn! Whats your move?Enter row and column. [1-6] [1-5]�Player X, your turn! Whats your move?Enter row and column. [1-6] [1-5]�Player O, your turn! Whats your move?Enter row and column. [1-6] [1-5]�Player X, your turn! Whats your move?Enter row and column. [1-6] [1-5]Player O, your turn! Whats your move?Enter row and column. [1-6] [1-5]�Player X, your turn! Whats your move?Enter row and column. [1-6] [1-5]�Player O, your turn! Whats your move?Enter row and column. [1-6] [1-5]�Player X, your turn! Whats y代做COMP 2011作业、代写C++语言作业、代做Gomoku game作业、代写C++程序作业 代做R语言编程|代做our move?Enter row and column. [1-6] [1-5]�Player 1 has won horizontally !!!Program should terminate without any memory leak.You may also play with the demo program in the download section.BonusFor this last assignment, to make sure the bonus works are evaluated consistently, we will have only 1 TA to manuallyassess your bonus work. To enable that, we will only award bonus points to worthy bonus works that meet a certainminimum requirement.On the other hand, while bonus work assessment is by nature subjective, if you meet the minimum requirement, you areguaranteed to have at least 1 bonus point. We want to motivate and reward the hard-workers in a more well-defined way.Your bonus work must be in either one of the two categories:Non-trivial game features. Your code for those features must be of at least 200 meaningful lines of C++ code statementsof your own. Empty lines, comments, and redundant/irrelevant statements are excluded. Dont intentionally lengthenyour implementation - we may shorten it for you whenever possible as we verify the line count ourselves.GUI interface (not just colored consoles). For example, use a GUI C++ framework such as QT or wxWidgets. It isdefinitely not easy, but that means 2 points are likely to be awarded for your hard work.We have deliberately made it challenging as we dont want students to think the bonus part is easy points and feelcompelled to do or else they are missing out.With all this said, note that bonus part is optional, but please feel free to take up the challenge if you are motivated to learnextra stuff and have the resources.Copying some ready-to-use feature (e.g. certain public AI code) from the internet is not allowed. In fact, it can be consideredas plagiarism. Therefore, instead of bonus, the offenders may receive penalty. Be creative to create your own features, anddont just copy.Submission and DeadlineDeadline: 23:59:00 on May 11, 2019Canvas SubmissionYou should submit only the gomoku_to_submit.cpp through the Canvas Assignment 3 Submission Page.Make sure your source file can be successfully compiled. It is required that your program can be compiled and runsuccessfully in the pre-installed Eclipse environment on our lab machines. If we cannot even compile your source files,your work will not be graded. Therefore, you should at least put in dummy implementations to the parts that you cannot finishso that there will be no compilation error.Make sure you actually upload the correct version of your source files - we only grade what you upload. Somestudents in the past submitted an empty file or a wrong file or an exe file which is worth zero mark. So you must downloadand double-check the file you have submitted. You can find the download link on the right-hand side of the same Canvasassignment page after your submission.You may submit your file multiple times, but only the latest version will be graded.Submit early to avoid any last-minute problem. Only canvas submissions will be accepted.Bonus submissionYou still need to submit the regular version, and then submit an additional bonus version. Follow the same procedureas the submission for the regular submission on Canvas except that you should submit a single zip file named pa3-bonus.zip to Bonus - Assignment 3 instead HERE. The single zip file should contain the following.1. All the source files needed to compile your work.2. A text file named README.txt or a PDF file README.pdf which should tell us:How to compile and run your program?For non-GUI bonus, how many c++ meaningful statements/lines you have written for the bonus? See the bonussection for more information.What are the new functionalities that you have implemented? Be clear and sell them to us.What are some sample input/output that your bonus program can produce, to show off its features?Anything else? Help us evaluate your work favorably.3. If you did the GUI bonus, you need to also provide screenshots or videos. you can put all screenshots in theREADME.pdf document. You can also provide the screenshots in a common image file format such as jpg, gif, or png.Alternatively, Videos that can be played on a lab machine, and online videos (just give us a link), are also accepted.Note:1. We may invite selected students to demo the PA3 bonus work.2. Wrong submission or missing information will disqualify your work from being assessed.Late submission policyThere will be a penalty of -1 point (out of a maximum 100 points) for every minute you are late. For instance, since thedeadline of the assignment is 23:59:00 on May 11th, if you submit your solution at 1:00:00 on May 12th, there will be apenalty of -61 points for your assignment. However, the lowest grade you may get from an assignment is zero: any negativescore after the deduction due to late penalty (and any other penalties) will be reset to zero.FAQFrequently Asked QuestionsQ: My code doesnt work / there is an error, here is the code, can you help me fix it?A: As the assignment is a major course assessment, to be fair, you are supposed to work on it on your own and we shouldnot finish the tasks for you. We might provide some very general hints to you, but we shall not fix the problem or debug foryou.Q: Can I add extra helper functions?A: You may do so in the file that you are allowed to modify and submit.Q: Can I include additional libraries?A: No. Everything you need is already included - there is no need for you to add any include statement (under our officialenvironment).Q: Can I create global variables?A: No, as already instructed in a source file comment.Q: Can I declare/define arrays for the bonus part?A: For bonus submission, yes you can. For your regular submission of PA3, you still need to follow the no-new-array-allowedrule for functions other than createBoard.Q: Can I use the cellRowHeads as a 2D array, or any 2D array?A: No, as announced in the email. array[i][j] (for whatever array, i, and j are) shouldnt appear in your code.Q: How about using cellRowHeads with syntax like (cellRowHeads + (i*width + j))?A: No, as you are using cellRowHeads like a 2D array in this way. A linked list would never support such operation since thememory allocated for the linked list elements are not guaranteed to be consecutive like an array. Again, you need to usecellRowHeads like a linked list. To reiterate what has been announced in the email, If you need to access a Cell on theboard, you need to use cellRowHeads[i] as the head Cell node of the linked list, and iterate through that linked list (by thenext pointers) to locate the Cell. You may see how it is done in the given drawBoard function..Q: The program crashes with a message terminate called recursively after I input the width and height when I run it onEclipse, any tips?A: It is likely because of a wrong implementation of your createBoard. The drawBoard function will crash if it is fed with awrongly initialized cellHeadRows. A few tips: 1. For a board of size height*width, you need to have exactly height*width newCell. Do you have that many cell objects created? Count it carefully. (not just array of pointers new Cell*[N], but dynamicCell objects new Cell) 2. Are the Cells linked by the next pointers correctly? 3. Is the next pointer of the last cell in every rowpointing to nullptr? Again, we wont check or debug your code for you, but hopefully these general tips help.MenuIntroductionOverviewDescriptionDownloadSample OutputBonusSubmission & DeadlineFAQPage maintained byWallace MakEmail: wallacem@cse.ust.hkLast Modified: 05/11/2019 02:55:01HomepageCourse HomepageMaintained by COMP 2011 Teaching Team ? 2018 HKUST Computer Science and Engineering转自:http://www.7daixie.com/2019051347626434.html

    相关文章

      网友评论

          本文标题:讲解:COMP 2011、C++、Gomoku game、C++

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