예제 #1
0
    //Method used to generate the base events
    protected override void generateEvents()
    {
        int i=0;

        //Generate yellow dots
        for(i=0;i<30;i++){

            InhibitionEvent e=null;

            if(i<15) e = new InhibitionEvent('l', "yellow");
            else e = new InhibitionEvent('r', "yellow");

            events.Add(e);
        }

        //Generate purple dots
        for(i=0;i<30;i++){

            InhibitionEvent e=null;

            if(i<15) e = new InhibitionEvent('l', "purple");
            else e = new InhibitionEvent('r', "purple");

            events.Add(e);
        }
    }
예제 #2
0
    //Generate practice pitches
    protected override void generatePractice()
    {
        border.renderer.enabled = true;

        List <EventStats> newPractice = new List <EventStats>();

        InhibitionEvent eS;

        //Only 7 events for practice, 2 yellow 5 purple
        for (int j = 0; j < 7; j++)
        {
            string c = "purple";
            char   s = 'l';

            if (j < 2)
            {
                c = "yellow";
            }

            if (j % 2 == 0)
            {
                s = 'r';
            }

            eS = new InhibitionEvent(s, c);

            newPractice.Add(eS);
        }

        System.Random rand = new System.Random();

        //Just simply randomize the order
        for (int i = 0; i < newPractice.Count - 1; i++)
        {
            InhibitionEvent originalStats = (InhibitionEvent)newPractice[i];

            int spotToMove = rand.Next(i, newPractice.Count);

            newPractice[i] = newPractice[spotToMove];

            newPractice[spotToMove] = originalStats;
        }

        practice.AddRange(newPractice);
    }
예제 #3
0
    //Generate practice pitches
    protected override void generatePractice()
    {
        border.renderer.enabled = true;

        List<EventStats> newPractice = new List<EventStats>();

        InhibitionEvent eS;

        //Only 7 events for practice, 2 yellow 5 purple
        for(int j = 0;j<7;j++){

            string c= "purple";
            char s='l';

            if(j<2)	c = "yellow";

            if(j%2==0) s='r';

            eS = new InhibitionEvent(s,c);

            newPractice.Add(eS);
        }

        System.Random rand = new System.Random();

        //Just simply randomize the order
        for(int i=0; i<newPractice.Count-1;i++){
            InhibitionEvent originalStats = (InhibitionEvent)newPractice[i];

            int spotToMove = rand.Next(i,newPractice.Count);

            newPractice[i] = newPractice[spotToMove];

            newPractice[spotToMove] = originalStats;
        }

        practice.AddRange(newPractice);
    }
예제 #4
0
    //Method used to generate the base events
    protected override void generateEvents()
    {
        int i = 0;

        //Generate yellow dots
        for (i = 0; i < 30; i++)
        {
            InhibitionEvent e = null;

            if (i < 15)
            {
                e = new InhibitionEvent('l', "yellow");
            }
            else
            {
                e = new InhibitionEvent('r', "yellow");
            }

            events.Add(e);
        }

        //Generate purple dots
        for (i = 0; i < 30; i++)
        {
            InhibitionEvent e = null;

            if (i < 15)
            {
                e = new InhibitionEvent('l', "purple");
            }
            else
            {
                e = new InhibitionEvent('r', "purple");
            }

            events.Add(e);
        }
    }
예제 #5
0
    //Method used to read in all the trials of the game
    private List<EventStats> ReadInhibEvents(XmlNode eventsNode)
    {
        List<EventStats> inhibEvents = new List<EventStats>();

        //For all the trials
        for (int i=0; i<eventsNode.ChildNodes.Count; i++){

            char charVar='0';
            string color="";

            //Make sure were trying to deal with event
            if(eventsNode.ChildNodes[i].Name =="event"){
                foreach(XmlAttribute attri in eventsNode.ChildNodes[i].Attributes){
                    //Side
                    if(attri.Name.ToLower() == "side"){
                        if(char.TryParse(attri.Value.ToLower(),out charVar)){
                            if(charVar !='l'  && charVar !='r'){
                                NeuroLog.Error("Invalid value for 'side' at event #" + (i+1).ToString() + ". Needs to be either 'l' or 'r'.");
                                charVar = 'l';
                            }
                        }
                        else
                            NeuroLog.Error("Invalid value for 'side' at event #" + (i+1).ToString() + ". Needs to be a char.");
                    }
                    //Color
                    else if(attri.Name.ToLower() == "color"){
                        color = attri.Value.ToLower();
                        if(color!="yellow" && color!="purple"){
                            NeuroLog.Error("Invalid value for 'color' at event #" + (i+1).ToString() + ". Needs to be either 'yellow' or 'purple'.");
                            color = "yellow";
                        }
                    }
                    //Other attributes that don't have cases
                    else NeuroLog.Error("Unknown attribute '" + attri.Name + "' at event #" + (i+1).ToString() + ".");
                }

                InhibitionEvent iE = new InhibitionEvent(charVar,color);

                inhibEvents.Add(iE);
            }
        }
        return inhibEvents;
    }
예제 #6
0
    //Method used to randomize the order of the list of events
    protected override void randomizeEvents()
    {
        System.Random rand = new System.Random();

        //Apply a base randomization
        for (int i = 0; i < 59; i++)
        {
            InhibitionEvent originalStats = (InhibitionEvent)events[i];

            int spotToMove = rand.Next(i, 60);

            events[i] = events[spotToMove];

            events[spotToMove] = originalStats;
        }

        bool ok = true;
        bool eventGood;

        int cycleCount = 0;

        //Loop to make sure there are no strings of 4 similiar dot colors
        do
        {
            ok = true;

            for (int i = 3; i < 60; i++)
            {
                eventGood = true;

                if (((InhibitionEvent)events[i]).DotColor == ((InhibitionEvent)events[i - 1]).DotColor &&
                    ((InhibitionEvent)events[i]).DotColor == ((InhibitionEvent)events[i - 2]).DotColor &&
                    ((InhibitionEvent)events[i]).DotColor == ((InhibitionEvent)events[i - 3]).DotColor)
                {
                    eventGood = false;
                }

                //If there are three in a row, find another element that has a different color and swap the two
                if (!eventGood)
                {
                    ok = false;

                    int start = i + 1;
                    if (start >= 60)
                    {
                        start = 0;
                    }

                    for (int j = i + 1; j < 60; j++)
                    {
                        eventGood = true;
                        if (((InhibitionEvent)events[j]).DotColor == ((InhibitionEvent)events[i]).DotColor)
                        {
                            eventGood = false;
                        }

                        if (eventGood)
                        {
                            InhibitionEvent originalStats = (InhibitionEvent)events[i];

                            events[i] = events[j];

                            events[j] = originalStats;

                            break;
                        }
                        else if (j == 59)
                        {
                            j = 0;
                        }
                    }
                }
            }
            cycleCount++;
            //Attempt 5 loops to fix any bad instances, after 5th proceed anyway
            if (cycleCount > 5)
            {
                ok = true;
            }
        }while(!ok);
    }