void RandomiseThisInstruction(CellDNA thisInstruction)
 {
     thisInstruction.Hue        *= Randomise(thisInstruction);
     thisInstruction.Value      *= Randomise(thisInstruction);
     thisInstruction.Saturation *= Randomise(thisInstruction);
     thisInstruction.Size       *= Randomise(thisInstruction);
     thisInstruction.Angle      *= Randomise(thisInstruction);
 }
    float Randomise(CellDNA thisInstruction)
    {
        float rand = (float)GetRandomDouble(random, (1f - thisInstruction.Randomise), (1f + thisInstruction.Randomise));

        return(rand);

//		//return a random value as a percentage to multiply something by. IE 90% to 110%
//		Random.InitState((int)Time.timeSinceLevelLoad);
//		float rand = Random.Range(1f - thisInstruction.Randomise, 1f + thisInstruction.Randomise);
//		Debug.Log ("rand = " + rand);
//
    }
    public void PaintGameObject(GameObject thisSpawn, CellDNA thisInstruction)
    {
        thisSpawn.transform.localScale = new Vector3(thisInstruction.Size, thisInstruction.Size, thisInstruction.Size);

        if (thisSpawn.GetComponent <Renderer> () == true)
        {
            thisSpawnRenderer = thisSpawn.GetComponent <Renderer> ();
            newColour         = Color.HSVToRGB(thisInstruction.Hue, thisInstruction.Saturation, thisInstruction.Value);
            newColour         = new Color(newColour.r, newColour.g, newColour.b, thisInstruction.Alpha);
            thisSpawnRenderer.material.color = newColour;
        }
    }
    //iterate through all entities that have correct components
    void Iterate(int entityId, ECS_Entity thisEntity)
    {
        thisCycle = thisEntity.lSysFacComp.CycleStep;

        if (thisEntity.lSysFacComp.CycleStep >= thisEntity.lSysFacComp.MaxCycle)
        {
            thisEntity.lSysComp.NeedsDrawing = false;
            thisEntity.lSysFacComp.IsDrawing = false;
            return;
        }



        thisInstruction = InstantiateInstructionInList(thisEntity, thisEntity.lSysFacComp.InstructionList, thisCycle);


        RandomiseThisInstruction(thisInstruction);

        Debug.Log("thisCycle : " + thisCycle);
        Debug.Log("This String : " + thisEntity.lSysComp.DNA[thisEntity.lSysComp.DNA.Count - 1].ToString());

        //Debug.Log ("DNA Length : " + thisEntity.lSysComp.DNA.Length);
        switchString = thisEntity.lSysComp.DNA[thisEntity.lSysComp.DNA.Count - 1][thisCycle].ToString();

        switch (switchString)
        {
        case ">":
            thisInstruction.Angle += thisInstruction.AngleChange;
            break;

        case "<":
            thisInstruction.Angle -= thisInstruction.AngleChange;
            break;

        case "F":

            Vector2 debugpos = (AngleHelper.Vector2FromAngle(thisInstruction.Angle).normalized *thisInstruction.Length);
            //Debug.Log ("vector change: " + debugpos);
            thisInstruction.position += debugpos;
            break;

        case "+":
            thisInstruction.AngleChange += 5f;
            break;

        case "-":
            thisInstruction.AngleChange -= 5f;
            break;

        case "[":
            thisEntity.lSysFacComp.InstructionStack.Push(Instantiate(thisInstruction));
            break;

        case "]":
            thisEntity.lSysFacComp.InstructionList[thisCycle] = thisEntity.lSysFacComp.InstructionStack.Pop();
            break;

        case "O":
            thisInstruction.Size *= 1.2f;
            break;

        case "o":
            thisInstruction.Size *= 0.8f;
            break;



        case "A":

            if (thisEntity.lSysFacComp.FactoryPrefabs_A != null)
            {
                thisSpawn = (GameObject)Instantiate(thisEntity.lSysFacComp.FactoryPrefabs_A, new Vector3(thisInstruction.position.x, thisInstruction.position.y), Quaternion.identity, thisEntity.trans);
                thisEntity.lSysFacComp.Children.Add(thisSpawn);

                PaintGameObject(thisSpawn, thisInstruction);
            }

            break;

        case "B":

            if (thisEntity.lSysFacComp.FactoryPrefabs_B != null)
            {
                thisSpawn = (GameObject)Instantiate(thisEntity.lSysFacComp.FactoryPrefabs_B, new Vector3(thisInstruction.position.x, thisInstruction.position.y), Quaternion.identity, thisEntity.trans);
                thisEntity.lSysFacComp.Children.Add(thisSpawn);

                PaintGameObject(thisSpawn, thisInstruction);
            }
            break;

        case "C":

            if (thisEntity.lSysFacComp.FactoryPrefabs_A != null)
            {
                thisSpawn = (GameObject)Instantiate(thisEntity.lSysFacComp.FactoryPrefabs_A, new Vector3(thisInstruction.position.x, thisInstruction.position.y), Quaternion.identity, thisEntity.trans);
                thisEntity.lSysFacComp.Children.Add(thisSpawn);

                PaintGameObject(thisSpawn, thisInstruction);
            }
            break;



            break;
        }


        thisEntity.lSysFacComp.CycleStep += 1;
    }