1. Make a class TransitionGame that has a template argument, T. Its only constructor receives a Map (elemToElem) and a function that takes a random generator and returns a T (genElem). The player will attempt to make a function from T to Optional (let's call this function "attemptFun") that is similar enough to elemToElem that checkGen accepts it. The function checkGen works in the following way: - first, it uses genElem to generate an element of type T - starting from this element, applies attemptFun to the element (we get a newElem, which can be empty) - if elemToElem contains a value associated with the element, but newElem is empty, or if newElem is present but elem is not present in elemToElem, return an optional filled with the element (this way we say that attemptFun is a failure at this element) - if elemToElem does not have this element, and also newElem is empty, return an empty Optional (this way we say accept attemptFun) - if elemToElem and genFun both say we can progress on to a next element, but these next elements are not equal, return an optional filled with the element - if we have already seen newElem, return an empty Optional - otherwise we move on to the new element, and continue on checking whether attemptFun and elemToElem match at all places 2. Make a function that runs a genetic algorithm. The algorithm first generates a population of n individuals using the function mkRndInd, which takes a random generator and returns a individual loaded with randomised data. The algorithm then takes passCnt passes of the following: - the fitness values of all of the individuals are evaluated using function getFitness - the individuals with the best m fitness values are kept, the others discarded - the population is filled up to n individuals again with random generation - all individuals with probability mutProb are mutated using function mutateInd (takes a random generator and an individual, returns the randomised individual) - (you can have crossover too if you know what that is) - then the next pass begins with the new population The data stored in the individuals is the type argument to the function; n, mkRndInd, passCnt, getFitness, m, mutProb (and the optional crossover function) are the function parameters. The function has to return the last population, sorted by fitness values in decreasing order. Try the genetic algorithm the following way. The individuals should be texts of random length (not too big, though), and the goal is to find a password. The fitness function gives 2 points if the text's length is the same as the password, and 1 more point for each correct letter. The random generator should fill the text with random characters, and the mutator should change a randomly chosen character into something different. 3. Implement an AVL tree data structure, or, if you are feeling adventurous, a red-black tree (see http://en.wikipedia.org/wiki/Red%E2%80%93black_tree or http://www.unf.edu/~wkloster/3540/wiki_book2.pdf, but don't look at the example codes) data structure. Use a template argument for the tree elements; note that is has to be comparable.