美文网首页
讲解:159.272、Programming Paradigms

讲解:159.272、Programming Paradigms

作者: yviv248 | 来源:发表于2020-01-10 09:13 被阅读0次

    Computational ThinkingPage 1 of 3159.272 Programming ParadigmsAssignment 2Playing a board game: ReversiPlaying board games interactively is a common computational activity. We can useabstraction to aide in the design of board games by separating the game logic from the actualuser interaction required to play the game. No matter the type of user interface provided toplay the game (text-based, desktop environment, web browser), the underlying logic remainsthe same.In this assignment, you will complete a Scala implementation of Reversi (also called Othello),a game for two players, played on a board divided into 64 squares, arranged in 8 rows and 8columns, with a set of 64 chips. Each chip has a dark and a light-colored side, with eachcolour belonging to one of the two players. The players place their chips on the board andflip the chips of their opponent, with the goal of having the most chips of their colour on theboard at the end of the game.A chip can only be placed into a square that is adjacent to a chip of the opponent and thatforms at least one straight line of attack (horizontal, vertical, diagonal). A line of attack isformed between two squares containing the players chips for which there are one or more ofthe opponents chips between the two. The opponents chips within the line of attack are thenflipped.Play alternates between the players until all the squares are filled or neither player can move.If one player cannot move but the opponent can, play continues with the opponent. Thewinner is the player with the most chips at the end of the game.See Maths is Fun to have a practice, or read the wikiHow entry.The Scala code for this assignment is contained in three files in the zip fileassignment2_2019.zip assignment2_2019.zipReversi.scala Reversi.scalaGameTree.scala GameTree.scalaMain.scala Main.scalaThe game logic is contained in the file Reversi.scala Reversi.scala.Your main task is to define the functions in Reversi.scala Reversi.scala using the provided datatypes.Computational ThinkingPage 2 of 3Instructions:1. 1. Create a new Scala project in Eclipse.2. Add the files Reversi.scala Reversi.scala, GameTree.scala GameTree.scala, Main.scala Main.scala to the srcfolder of the p159.272作业代做、代写Programming Paradigms作业、c/c++编程作业代做、Python,Javroject.3. Complete the functions in Reversi.scala Reversi.scala. Replace the with yourdefinitions.4. Main.scala Main.scala defines the main class of the application with the main method.Run and test your changes in the the main method defined in Main.scala Main.scala.The final function call in the main method starts the game. Right click and run themain class as a Scala application as you did at the tutorials.In lectures, we will explain the concepts behind the GameTree.scal GameTree.scala code. Youshould work through the code and make an effort to understand how these conceptshave been implemented. The most important concern is to ensure that your functionsdefined in Reversi.scal Reversi.scala return sensible values of the correct types, so that theother modules can sensibly use your completed code.Your second task considers the estimat estimate function in GameTree.scal GameTree.scala which takesa Player value and a Game value and returns an integer value, which rates theresult of placing the given piece on the current board, for that player.Your second task is to make this function smarter. The vanilla version returns a scorefor the given player and the given board, defined as the number of pieces currentlybelonging to the player. Can you make this function smarter? This function can bemodified to account for strategic concerns, e.g. corners are worth more than edges,which are worth more than other positions. The important point is that you can modifythis function without changing any of the other code, and end up with a smarterprogram. Think about what you would need to do to alter this program behavior usingother programming paradigms.When you have a finished version, submit your files Reversi.scal Reversi.scala andGameTree.scal GameTree.scala for marking. You will get (up to) 12 marks for a correct workingversion of Reversi.scala, modulated by the use of good functional programmingstyle, and (up to) 3 marks for an updated version of GameTree.scala, modulatedby the sophistication of your improvements .Submit your work on Stream by 8pm (Beijing time) Tuesday 4th June. The deadlineencroaches on the Study break but this is so that we don’t clash with other courseshaving deadlines early in Week 12.转自:http://www.7daixie.com/2019052357722298.html

    相关文章

      网友评论

          本文标题:讲解:159.272、Programming Paradigms

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