Find Jobs
Hire Freelancers

Card Guess - Haskell - open to bidding

$30-250 USD

Terminado
Publicado hace más de 9 años

$30-250 USD

Pagado a la entrega
You will write Haskell code to implement the guesser part of the game. This will require you to write a function to return your initial guess, and another to use the feedback from the previous guess to determine the next guess. The latter function will be called repeatedly until it produces the correct guess. You will find it useful to keep information between guesses; since Haskell is a purely functional language, you cannot use a global or static variable to store this. Therefore, your initial guess function must return this game state information, and your next guess function must take the game state as input and return the updated game state as output. You may put any information you like in the game state, but you must define a type GameState to hold this information. I will supply a Card module providing the Card, Rank, and Suit types and their constructors. This implementation has a few enhancements from the types presented in lectures. First, all three types are in the Eq class. All are also in the Bounded and Enum class, which means, for example, that [minBound..maxBound]::[Card] is the list of all cards in order, from 2♣to A♠, and similarly [minBound..maxBound]::[Rank] is the list of ranks from 2 to Ace, and similarly for Suit. This also means that, for example, succ (Card Club R5) == (Card Club R6) and succ (Card Heart Ace) == (Card Spade R2). Read the documentation for Bounded and Enum classes for more things you can do with them. The Rank and Suit types are also in the Ord class, so for example Ace > King and Heart < Spade. For convenience, all three types are also in the Show class so that ranks and suits are shown as a single character (10 is shown as T), and cards as two characters: rank followed by suit. All three are also in the Read class, which means that, for example, (read "[2C,AH]")::[Card] returns the list [Card Club R2, Card Heart Ace] (which would be printed as [2C,AH]). You must define following two functions, as well as the GameState type: initialGuess :: Int → ([Card],GameState) takes the number of cards in the answer as input and returns a pair of an initial guess, which should be a list of the specified number of cards, and a game state. The number of cards specified will be 2 for most of the test, and 3 or 4 for the remaining tests, as explained below. nextGuess :: ([Card],GameState) → (Int,Int,Int,Int,Int) → ([Card],GameState) takes as input a pair of the previous guess and game state, and the feedback to this guess as a quintuple of counts of correct cards, low ranks, correct ranks, high ranks, and correct suits, and returns a pair of the next guess and new game state. You must call your (main) source file [login to view URL] or [login to view URL], and it must contain the module declaration: module Cardguess (initialGuess, nextGuess, GameState) where You may divide your code into as many files as you like, as long as your main file (and the files it imports) imports all the others. But do not feel you need to divide your program into many files if it is reasonably small. I will also provide a test driver program called [login to view URL] to allow you to conveniently test your Cardguess implementation. You can specify the cards of the answer on the command line, and the program will print out each guess and the corresponding feedback and report the number of guesses needed to find the answer. The [login to view URL] is substantially similar to the test driver I will use for testing your code. You can compile and link your code for testing using the command: ghc -O2 --make Cardguesstest I will use a similar command to compile your code in preparation for testing.
ID del proyecto: 6405728

Información sobre el proyecto

2 propuestas
Proyecto remoto
Activo hace 10 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
Adjudicado a:
Avatar del usuario
Can do it within a day or two, so text me . : )
$155 USD en 1 día
5,0 (5 comentarios)
3,5
3,5
2 freelancers están ofertando un promedio de $203 USD por este trabajo
Avatar del usuario
Hi! I am professional C/C++/C#/Java programmer. I can do this project with highest quality! Best Regards, szymszteinsl
$250 USD en 3 días
5,0 (5 comentarios)
3,8
3,8

Sobre este cliente

Bandera de AUSTRALIA
melbourne, Australia
4,9
2
Forma de pago verificada
Miembro desde sept 3, 2014

Verificación del cliente

Otros trabajos de este cliente

a java socket file programme
$30-250 USD
¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.