While you can now play your game, it still has a few rough edges. You'll now polish off a few of these. First, you want to create a random jumble of characters in the part of the grid that we're currently displaying with underscore characters. Next, you want to highlight each of the found words by uppercasing them.
- [Hakim] In this video, the last video of the course,…we're going to look at adding some final polish to our game.…So we're going to investigate…how Haskell handels random number generation,…in order to create a jumbled up grid of words for our game.…And we're going to look at highlighting…the words that we've found.…So let's open up our words.cabal file,…and add the random library.…Now, if we open up ghci,…we can have a look at System.Random,…and one of the exported functions,…is called randomRs,…and as you can see, this takes a tuple of a certain type A,…and returns a list of that type,…and also this mysterious G, which is a random gen-type.…
So another function is the new standard gen,…which returns a standard generator within the IO monad,…and ghci is running within that monad,…so you can see that if we call the function…we get a new seed of a random number.…And that's essentially…what the random number generator means.…And you can see that once we've extracted a number…from the IO monad using the left arrow operator,…
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Discovering Haskell with GHCI
- Haskell datatypes and functions
- Using higher order functions for data manipulation and code reuse
- Editing Haskell source code
- Creating a project with Stack
- Writing and conducting tests