/// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            spriteBatch.Draw(display, new Vector2(0, 0), Color.White);
            spriteBatch.DrawString(scoreFont, "Gen:" + GA.generation.ToString(), new Vector2(60, 15), Color.White);

            canvas.Draw(spriteBatch);

            if (currentState != appState.SELECT)
            {
                canvas.DrawOntoGrid(spriteBatch, GA.GetBest());
            }

            if (currentState == appState.SELECT)
            {
                spriteBatch.Draw(select, new Vector2(540, 130), Color.White);
                spriteBatch.DrawString(scoreFont, optionText[currentSelection], new Vector2(67, 517), Color.White);
            }
            else if (currentState == appState.DRAW)
            {
                spriteBatch.Draw(draw, new Vector2(540, 130), Color.White);
                spriteBatch.DrawString(scoreFont, optionText[currentSelection], new Vector2(67, 517), Color.White);
            }
            else if (currentState == appState.COMPLETE)
            {
                spriteBatch.Draw(complete, new Vector2(540, 130), Color.White);
                spriteBatch.DrawString(scoreFont, "Press Q to Quit or D to draw a new image", new Vector2(67, 517), Color.White);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            prevKS = currKS;
            currKS = Keyboard.GetState();

            switch (currentState)
            {
            case appState.SELECT:
                GA.generation = 0;
                if (currKS.IsKeyDown(Keys.Space))
                {
                    SelectOption(currentSelection);
                    if (currentSelection != 0)
                    {
                        GA.InitPopulation();
                        GA.SetTarget(ImageData.ScanImage(targetImage));
                        currentState = appState.DRAW;
                    }
                }
                else if (currKS.IsKeyDown(Keys.Down))
                {
                    if (prevKS.IsKeyUp(Keys.Down))
                    {
                        currentSelection++;
                        currentSelection = currentSelection % maxNumOptions;
                    }
                }
                else if (currKS.IsKeyDown(Keys.Up))
                {
                    if (prevKS.IsKeyUp(Keys.Up))
                    {
                        currentSelection--;
                        if (currentSelection < 0)
                        {
                            currentSelection = currentSelection + maxNumOptions;
                        }
                    }
                }
                break;

            case appState.DRAW:
                if (!GA.complete)
                {
                    GA.Update();
                }
                else
                {
                    currentState = appState.COMPLETE;
                }
                break;

            case appState.COMPLETE:
                if (currKS.IsKeyDown(Keys.Q))
                {
                    this.Exit();
                }
                else if (prevKS.IsKeyDown(Keys.D))
                {
                    currentState = appState.SELECT;
                }
                break;
            }

            base.Update(gameTime);
        }