[SOLVED] game math scala Computational Thinking

$25

File Name: game_math_scala_Computational_Thinking.zip
File Size: 357.96 KB

5/5 - (1 vote)

Computational Thinking
159.272 Programming Paradigms
Assignment 2
Playing a board game: Reversi
Playing board games interactively is a common computational activity. We can use abstraction to aide in the design of board games by separating the game logic from the actual user interaction required to play the game. No matter the type of user interface provided to play the game (text-based, desktop environment, web browser), the underlying logic remains the 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 8 columns, with a set of 64 chips. Each chip has a dark and a light-colored side, with each colour belonging to one of the two players. The players place their chips on the board and flip the chips of their opponent, with the goal of having the most chips of their colour on the board 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 that forms at least one straight line of attack (horizontal, vertical, diagonal). A line of attack is formed between two squares containing the players chips for which there are one or more of the opponents chips between the two. The opponents chips within the line of attack are then flipped.
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. The winner 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 file
assignment2_2019.zip
Reversi.scala GameTree.scala Main.scala
The game logic is contained in the file Reversi.scala.
Your main task is to define the functions in Reversi.scala using the provided data types.
Page 1 of 3

Computational Thinking
Instructions:
1.
1. Create a new Scala project in Eclipse.
2. Add the files Reversi.scala, GameTree.scala, Main.scala to the src
folder of the project.
3. Complete the functions in Reversi.scala. Replace the ??? with your
definitions.
4. 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. The final function call in the main method starts the game. Right click and run the main class as a Scala application as you did at the tutorials.
In lectures, we will explain the concepts behind the GameTree.scala code. You should work through the code and make an effort to understand how these concepts have been implemented. The most important concern is to ensure that your functions defined in Reversi.scala return sensible values of the correct types, so that the other modules can sensibly use your completed code.
Your second task considers the estimate function in GameTree.scala which takes a Player value and a Game value and returns an integer value, which rates the result 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 score for the given player and the given board, defined as the number of pieces currently belonging to the player. Can you make this function smarter? This function can be modified 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 modify this function without changing any of the other code, and end up with a smarter program. Think about what you would need to do to alter this program behavior using other programming paradigms.
When you have a finished version, submit your files Reversi.scala and GameTree.scala for marking. You will get (up to) 12 marks for a correct working version of Reversi.scala, modulated by the use of good functional programming style, and (up to) 3 marks for an updated version of GameTree.scala, modulated by the sophistication of your improvements .
Submit your work on Stream by 8pm (Beijing time) Tuesday 4th June. The deadline encroaches on the Study break but this is so that we dont clash with other courses having deadlines early in Week 12.
Page 2 of 3

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] game math scala Computational Thinking
$25