Individual Assignment: Text Analytics
In this assignment, you will be required to write Haskell functions that simplify playing of the variation of UNO.
1.1 Data File Specification
An example of properly formatted file is shown in Figure 1.
The first part (onePlayerOneMove in the file csce322h0mework03part01.hs) will take in thre (3) arguments (a discard pile, a deck, and a hand) and return the state of the game (hand/deck/discard) that is the result of the player in possession of the hand playing a card. The precedence for playing a card is as follows:
If playing a Wild (or Wild Draw 4), the next player needs to know which color to play next. If the hand still contains non-Wild cards, play the card c,- (where c is the color of the left-most non-Wild card remaining in the hand). If the hand only contains Wild cards play r,-. If the hand has been emptied (and, therefore, the game won), play -,-.
In the event that you need to extend a Wild Draw 4 or Draw 2 and cannot, you must draw all of the cards (possibly) built-up from other players extending Wild Draw 4s or Draw 2s. If a Draw 4 was played, it would be directly behind a r,-, g,-, b,-, or y,-. Once you draw the number of cards required (or the size of the deck, whichever is smaller), place a copy of the a r,-, g,-, b,-, or y,- from the front of the discard pile on the front of the discard pile. This will let future players know that they must continue with a card of that color.
The second part (onePlayerManyMoves in the file csce322h0mework03part02.hs) will take in three
(3) arguments (a discard pile, a deck, and a hand), and returns the hand/deck/discard that is the result of the player in possession of the hand playing as many cards in a row as they can before emptying their hand or being unable to continue playing cards. The same rules for precedence of moves as onePlayerOneMove applies.
The third part (manyPlayersOneMove in the file csce322h0mework03part03.hs) will take in three
(3) arguments (a discard pile, a deck, and a list of hands) and return the game (hands/deck/discard) that is the result of n turns being taken for a game with n players. The same rules for precedence apply, but skip and reverse cards will have these effects: if Player p plays a reverse on turn t, Player p − 1 will take turn t + 1 (or Player n will take turn t + 1 if Player 1 played the reverse)
assuming the turns are proceeding in ascending order. If turns are proceeding in descending order Player p + 1 will take turn t + 1 (or Player 1 will take turn t + 1 if Player n played the reverse). If Player p plays a skip on turn t, Player p + 2 will take turn t + 1 (or Player 1 will take turn t + 1 if Player n − 1 played the skip, or Player 2 will take turn t + 1 if Player n played the skip) if turns are proceeding in ascending order. If turns are proceeding in descending order, Player p − 2 will take turn t + 1 (or Player n − 1 will take turn t + 1 if Player 1 played the skip, or Player n will take turn t + 1 if Player 2 played the skip).
The fourth part (manyPlayersManyMoves in the file csce322h0mework03part04.hs) will take in three (3) arguments (a discard pile, a deck, and hands) and return the game (hands/deck/discard) that is the result of a game being played to its conclusion. Instead of n players combining to take n turns, turns will be taken following the rules of manyPlayersOneMove until a player empties their hand or the player whose turn it is cannot continue the game (either by playing a card or drawing a card from the deck).
Your files should follow the naming convention of
csce322h0mework03part01.hs, csce322h0mework03part02.hs, csce322h0mework03part03.hs, and csce322h0mework03part04.hs.
6.1 Helpers.hs
A file named Helpers.hs has been provided with the functionality to read the .uno files into matrices. If a modified Helpers.hs file is not included with your submission, the default will be used in its place.
Submissions will be tested with ghc. cse.unl.edu is currently running version 8.0.2 of ghc.
Learn Haskell Fast and Hard
Learn You a Haskell for Great Good! Red Bean Software
Functional Programming Fundamentals The Haskell Cheatsheet
版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。