Esempio n. 1
0
    static int Contains(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        List <TrialData> obj  = (List <TrialData>)LuaScriptMgr.GetNetObjectSelf(L, 1, "List<TrialData>");
        TrialData        arg0 = (TrialData)LuaScriptMgr.GetNetObject(L, 2, typeof(TrialData));
        bool             o    = obj.Contains(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Esempio n. 2
0
    static int set_Item(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        List <TrialData> obj = (List <TrialData>)LuaScriptMgr.GetNetObjectSelf(L, 1, "List<TrialData>");
        int       arg0       = (int)LuaScriptMgr.GetNumber(L, 2);
        TrialData arg1       = (TrialData)LuaScriptMgr.GetNetObject(L, 3, typeof(TrialData));

        obj[arg0] = arg1;
        return(0);
    }
Esempio n. 3
0
    static int GetTrialDataByIndex(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        TrialConfig obj  = (TrialConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "TrialConfig");
        uint        arg0 = (uint)LuaScriptMgr.GetNumber(L, 2);
        int         arg1 = (int)LuaScriptMgr.GetNumber(L, 3);
        TrialData   o    = obj.GetTrialDataByIndex(arg0, arg1);

        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
Esempio n. 4
0
 private static void SaveToRegistry(TrialData data, String regBranch, String regKey, String regParam, String keyFileName)
 {
     byte[] encryptedObject = ClmEncryptor.EncryptObject(keyFileName, data);
     using (var rk = Registry.CurrentUser.CreateSubKey(String.Format("{0}{1}{2}",
                                                                     regBranch,
                                                                     regBranch.EndsWith("\\", StringComparison.Ordinal) ? String.Empty : "\\",
                                                                     regKey)))
     {
         rk.SetValue(regParam, encryptedObject, RegistryValueKind.Binary);
     }
 }
Esempio n. 5
0
    private void storeTrial()
    {
        TrialVars trialVars = (TrialVars)ICurrentTrial.Current;

        trialData.amplitude         = trialVars.A;
        trialData.distractorDesnity = trialVars.D;
        trialData.effectiveWidth    = trialVars.W;

        blockData.trials.Add(trialData);
        trialData = new TrialData();
    }
Esempio n. 6
0
    public override void Write(object obj, ES2Writer writer)
    {
        TrialData data = (TrialData)obj;

        // Add your writer.Write calls here.
        writer.Write(0); // Version 1 is current version number
        // Make sure to edit Read() function to properly handle version control!
        // VERSION 0:
        writer.Write(data.fitnessComponentDataArray);
        writer.Write(data.totalSumOfWeights);
    }
Esempio n. 7
0
    // ********************************************************************** //

    public string TrialSetup()
    {
        // Start the trial with a clean-slate
        FLAG_trialError          = false;
        FLAG_trialTimeout        = false;
        FLAG_fullScreenModeError = false;
        starFound       = false;
        displayTimeLeft = false;
        scoreUpdated    = false;
        congratulated   = false;
        pauseClock      = false;
        trialScore      = 0;

        // Load in the trial data
        currentTrialData = dataController.GetCurrentTrialData();
        nextScene        = currentTrialData.mapName;

        // Location and orientation variables
        playerSpawnLocation    = currentTrialData.playerSpawnLocation;
        playerSpawnOrientation = currentTrialData.playerSpawnOrientation;
        star1SpawnLocation     = currentTrialData.star1Location;
        star2SpawnLocation     = currentTrialData.star2Location;
        doubleRewardTask       = currentTrialData.doubleRewardTask;
        presentPositions       = currentTrialData.presentPositions;

        // Timer variables
        maxMovementTime       = currentTrialData.maxMovementTime;
        preDisplayCueTime     = currentTrialData.preDisplayCueTime;
        displayCueTime        = currentTrialData.displayCueTime;
        goalHitPauseTime      = currentTrialData.goalHitPauseTime;
        finalGoalHitPauseTime = currentTrialData.finalGoalHitPauseTime;
        goCueDelay            = currentTrialData.goCueDelay;
        minDwellAtReward      = currentTrialData.minDwellAtReward;
        displayMessageTime    = currentTrialData.displayMessageTime;
        errorDwellTime        = currentTrialData.errorDwellTime;
        rewardType            = currentTrialData.rewardType;
        hallwayFreezeTime     = currentTrialData.hallwayFreezeTime;

        // Start the next scene/trial
        Debug.Log("Upcoming scene: " + nextScene);
        SceneManager.LoadScene(nextScene);

        string[] menuScenesArray = new string[] { "Exit", "RestBreak", "GetReady" };

        if (menuScenesArray.Contains(nextScene))
        {
            return(nextScene);   // we don't want to record data and do the FSM transitions during the exit and rest break scenes
        }
        else
        {
            return("StartTrial");
        }
    }
Esempio n. 8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, TrialData trialData)
        {
            string corsOrigin = "http://localhost:4200";

            //StripeConfiguration.SetApiKey(Configuration.GetSection("Stripe:SecretKey").Value);
            StripeConfiguration.ApiKey = Configuration.GetSection("Stripe:SecretKey").Value;
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler(BuilderExtensions =>
                {
                    BuilderExtensions.Run(async context =>
                    {
                        context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                        var error = context.Features.Get <IExceptionHandlerFeature>();
                        if (error != null)
                        {
                            context.Response.AddApplicationError(error.Error.Message, corsOrigin);
                            await context.Response.WriteAsync(error.Error.Message);
                        }
                    });
                });
                // app.UseHsts();
            }

            /* app.UseSpa(spa =>
             * {
             *  // To learn more about options for serving an Angular SPA from ASP.NET Core,
             *  // see https://go.microsoft.com/fwlink/?linkid=864501
             *
             *  spa.Options.SourcePath = "ZawajSPA";
             *
             *  if (env.IsDevelopment())
             *  {
             *      //spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
             *      spa.UseAngularCliServer(npmScript: "start");
             *  }
             * });  */

            trialData.TrialUsers();
            app.UseHttpsRedirection();
            app.UseCors(x => x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
            app.UseSignalR(options =>
            {
                options.MapHub <ChatHub>("/chatHub");
            });
            app.UseAuthentication();
            app.UseMvc();
        }
Esempio n. 9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TrialData trialData)
        {
            StripeConfiguration.SetApiKey(Configuration.GetSection("Stripe:SecretKey").Value);
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                //  app.UseHsts();

                // for any error handler
                app.UseExceptionHandler(BuilderExtensions =>
                {
                    BuilderExtensions.Run(async context =>
                    {
                        context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                        var error = context.Features.Get <IExceptionHandlerFeature>();
                        if (error != null)
                        {
                            context.Response.AddApplicationError(error.Error.Message);
                            await context.Response.WriteAsync(error.Error.Message);
                        }
                    });
                });
            }

            // app.UseMvc();
            // app.UseHttpsRedirection();

            trialData.TrialUsers();
            //app.UseCors(x =>x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials());
            app.UseCors();

            app.UseAuthentication();

            app.UseRouting();

            app.UseAuthorization();

            // in asp core 2.1  only
            //app.UseSignalR(routes => {  routes.MapHub<ChatHub>("/chat"); });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                // in asp core 3 above
                endpoints.MapHub <ChatHub>("/chat");
            });
        }
Esempio n. 10
0
    void OutputInputData()
    {
        TrialData t;

        if (tm.GetCurrentTrial() <= 0)
        {
            t = new TrialData();
        }
        else
        {
            t = tm.GetTrial();
        }
        OutputData o = new OutputData(t.startTime, t.trialType, im.actionTime, im.currentAction, t.trialNumber, im.currentControl);

        om.SendData(o);
    }
Esempio n. 11
0
    void OutputNoInputData()
    {
        TrialData t;

        if (tm.GetCurrentTrial() <= 0)
        {
            t = new TrialData();
        }
        else
        {
            t = tm.GetTrial();
        }
        OutputData o = new OutputData(t.startTime, t.trialType, t.trialNumber);

        om.SendData(o);
    }
Esempio n. 12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TrialData trialData)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "PortfolioApp.API v1"));
            }
            else
            {
                app.UseExceptionHandler(BuilderExtensions =>
                {
                    BuilderExtensions.Run(async context => {
                        context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                        var error = context.Features.Get <IExceptionHandlerFeature>();
                        if (error != null)
                        {
                            context.Response.AddApplicationError(error.Error.Message);
                            await context.Response.WriteAsync(error.Error.Message);
                        }
                    });
                });
            }

            // //--> Ajouter UserTrialData
            // trialData.TrialUsers();
            // //--> Ajouter ProjectTrialData
            // trialData.TrialProjects();
            // //--> Ajouter SkillTrialData
            //  trialData.TrialSkills();


            //--> Permet d'avoir autorisation pour tous les site d'accédé a notre service web
            app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Esempio n. 13
0
    public IEnumerator EnqueueCurrentTrial()
    {
        yield return(new WaitForSeconds(3));

        if (_currentTrialData != null)
        {
            _storedTrialData.Enqueue(_currentTrialData);
            _currentTrialData = null;
            Debug.Log("Saved current Trial Data");
        }

        //Debug.Log("NOT saved current Trial Data");
        if (IsThereUnsavedData())
        {
            StartCoroutine(TryToSaveToGoogleSheets());
        }
    }
Esempio n. 14
0
    static int _CreateTrialData(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            TrialData obj = new TrialData();
            LuaScriptMgr.PushObject(L, obj);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: TrialData.New");
        }

        return(0);
    }
Esempio n. 15
0
    void wrongAnswer()
    {
        TrialData storage = new TrialData();

        SpeedUp.Play();
        totalTime = totalTime + timer.ElapsedMilliseconds;
        storage.srt_input_pressed = keyPressed;
        storage.correct_input     = answer;
        storage.was_input_correct = false;
        storage.rt    = timer.ElapsedMilliseconds;
        storage.block = level;
        storage.srt_sequence_index = currentSequence;
        storage.srt_trial_index    = totalTrials;
        storage.experiment         = cfig.Experiment;
        Upload(JsonUtility.ToJson(storage));
        loading = false;
    }
Esempio n. 16
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, TrialData trialData)
        {
            StripeConfiguration.SetApiKey(Configuration.GetSection("Stripe:SecretKey").Value);
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler(BuilderExtensions => {
                    BuilderExtensions.Run(async context =>
                    {
                        context.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                        var error = context.Features.Get <IExceptionHandlerFeature>();
                        if (error != null)
                        {
                            context.Response.AddApplicationError(error.Error.Message);
                            await context.Response.WriteAsync(error.Error.Message);
                        }
                    });
                });
                //app.UseHsts();
            }

            trialData.TrialUsers();
            app.UseHttpsRedirection();

            app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials());
            app.UseSignalR(routes => {
                routes.MapHub <ChatHub>("/chat");
            });
            app.UseAuthentication();
            app.Use(async(context, next) =>
            {
                await next();
                if (context.Response.StatusCode == 404)
                {
                    context.Request.Path = "/index.html";
                    await next();
                }
            });
            app.UseDefaultFiles();
            app.UseStaticFiles();
            app.UseMvc();
        }
Esempio n. 17
0
    public override void Read(ES2Reader reader, object c)
    {
        TrialData data = (TrialData)c;
        // Add your reader.Read calls here to read the data into the object.
        // Read the version number.
        int fileVersion = reader.Read <int>();

        // VERSION 0:
        if (fileVersion >= 0)
        {
            data.fitnessComponentDataArray = reader.ReadArray <FitnessComponentData>();
            data.totalSumOfWeights         = reader.Read <float>();
            if (fileVersion >= 1)
            {
                // new attributes
            }
        }
    }
Esempio n. 18
0
    private IEnumerator TryToSaveToGoogleSheets()
    {
        TrialData earliestData = _storedTrialData.Peek();

        if (earliestData == null || earliestData.all_time == 0)
        {
            yield return(new WaitForSeconds(0));

            _storedTrialData.Dequeue();
            if (IsThereUnsavedData())
            {
                StartCoroutine(TryToSaveToGoogleSheets());
            }
            Debug.Log("Null in earliestdata");
        }
        else
        {
            Debug.Log($"alltime: {earliestData.all_time} Sent_text {earliestData.sent_text}");
            using (UnityWebRequest www = UnityWebRequest.Post(TrialData.GetFormURI(), earliestData.GetFormFields()))
            {
                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.LogError(www.error);
                    SaveEverythingToLocalStorage();
                }
                else
                {
                    // Yepp, we will do this one by one
                    _storedTrialData.Dequeue();
                    if (IsThereUnsavedData())
                    {
                        StartCoroutine(TryToSaveToGoogleSheets());
                    }
                    else
                    {
                        ClearLocalStorage();
                    }
                }
            }
        }
    }
Esempio n. 19
0
    void endCorrectAnswer()
    {
        time.Stop();
        if (time.ElapsedMilliseconds < 19)
        {
            levelText.text  = "Level 2 Unlocked";
            progress.level2 = true;
            nextLevel.gameObject.SetActive(true);
        }

        TrialData storage = new TrialData();

        levelText.text            = "You took too long Try Again";
        storage.srt_input_pressed = keyPressed;
        storage.correct_input     = answer;
        storage.was_input_correct = true;
        storage.rt    = timer.ElapsedMilliseconds;
        storage.block = level;
        storage.srt_sequence_index = currentSequence;
        currentSequence            = 1;
        storage.srt_trial_index    = totalTrials;
        //Upload(JsonUtility.ToJson(storage));
        totalTrials = totalTrials + 1;
        level++;
        running = false;
        SpeedUp.Play();
        totalTime = totalTime + timer.ElapsedMilliseconds;
        UnityEngine.Debug.Log(timer.ElapsedMilliseconds);
        responseTime.text = "You completed the attempt in " + time.ElapsedMilliseconds / 1000f + " seconds";
        if ((time.ElapsedMilliseconds < bestScore) || (bestScore == 0))
        {
            bestScore          = time.ElapsedMilliseconds;
            bestScoreText.text = "Best Score: " + bestScore / 1000f;
        }
        UnityEngine.Debug.Log(responseTime.text);
        if (level > cfig.Attempts)
        {
            levelText.text = "All Attempts Completed";
        }
    }
Esempio n. 20
0
    static int set_showProgress(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        TrialData obj = (TrialData)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name showProgress");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index showProgress on a nil value");
            }
        }

        obj.showProgress = (short)LuaScriptMgr.GetNumber(L, 3);
        return(0);
    }
Esempio n. 21
0
 void wrongAnswer()
 {
     lives = lives - 1;
     if (lives == 0)
     {
         time.Stop();
         end            = true;
         running        = false;
         carSpeed       = 0;
         levelText.text = "Level Failed";
         endPanel.SetActive(true);
         TrialData storage = new TrialData();
         totalTime = totalTime + timer.ElapsedMilliseconds;
         storage.srt_input_pressed = keyPressed;
         storage.correct_input     = answer;
         storage.was_input_correct = false;
         storage.rt    = timer.ElapsedMilliseconds;
         storage.block = level;
         storage.srt_sequence_index = currentSequence;
         storage.srt_trial_index    = totalTrials;
         //Upload(JsonUtility.ToJson(storage));
         loading = false;
     }
     else
     {
         TrialData storage = new TrialData();
         SpeedUp.Play();
         totalTime = totalTime + timer.ElapsedMilliseconds;
         storage.srt_input_pressed = keyPressed;
         storage.correct_input     = answer;
         storage.was_input_correct = false;
         storage.rt    = timer.ElapsedMilliseconds;
         storage.block = level;
         storage.srt_sequence_index = currentSequence;
         storage.srt_trial_index    = totalTrials;
         //Upload(JsonUtility.ToJson(storage));
         loading = false;
     }
 }
Esempio n. 22
0
    static int BinarySearch(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2)
        {
            List <TrialData> obj  = (List <TrialData>)LuaScriptMgr.GetNetObjectSelf(L, 1, "List<TrialData>");
            TrialData        arg0 = (TrialData)LuaScriptMgr.GetNetObject(L, 2, typeof(TrialData));
            int o = obj.BinarySearch(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 3)
        {
            List <TrialData>      obj  = (List <TrialData>)LuaScriptMgr.GetNetObjectSelf(L, 1, "List<TrialData>");
            TrialData             arg0 = (TrialData)LuaScriptMgr.GetNetObject(L, 2, typeof(TrialData));
            IComparer <TrialData> arg1 = (IComparer <TrialData>)LuaScriptMgr.GetNetObject(L, 3, typeof(IComparer <TrialData>));
            int o = obj.BinarySearch(arg0, arg1);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 5)
        {
            List <TrialData> obj       = (List <TrialData>)LuaScriptMgr.GetNetObjectSelf(L, 1, "List<TrialData>");
            int                   arg0 = (int)LuaScriptMgr.GetNumber(L, 2);
            int                   arg1 = (int)LuaScriptMgr.GetNumber(L, 3);
            TrialData             arg2 = (TrialData)LuaScriptMgr.GetNetObject(L, 4, typeof(TrialData));
            IComparer <TrialData> arg3 = (IComparer <TrialData>)LuaScriptMgr.GetNetObject(L, 5, typeof(IComparer <TrialData>));
            int                   o    = obj.BinarySearch(arg0, arg1, arg2, arg3);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: List<TrialData>.BinarySearch");
        }

        return(0);
    }
Esempio n. 23
0
    static int set_award_id(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        TrialData obj = (TrialData)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name award_id");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index award_id on a nil value");
            }
        }

        obj.award_id = (uint)LuaScriptMgr.GetNumber(L, 3);
        return(0);
    }
Esempio n. 24
0
    static int set_title(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        TrialData obj = (TrialData)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name title");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index title on a nil value");
            }
        }

        obj.title = LuaScriptMgr.GetString(L, 3);
        return(0);
    }
Esempio n. 25
0
    static int set_link(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        TrialData obj = (TrialData)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name link");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index link on a nil value");
            }
        }

        obj.link = (List <uint>)LuaScriptMgr.GetNetObject(L, 3, typeof(List <uint>));
        return(0);
    }
Esempio n. 26
0
    static int get_id(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        TrialData obj = (TrialData)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name id");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index id on a nil value");
            }
        }

        LuaScriptMgr.Push(L, obj.id);
        return(1);
    }
Esempio n. 27
0
    void endCorrectAnswer()
    {
        time.Stop();
        if ((time.ElapsedMilliseconds) / 1000 < 21)
        {
            levelText.text  = "Level 2 Unlocked";
            progress.level2 = true;
            nextLevel.gameObject.SetActive(true);
        }
        else
        {
            levelText.text = "You must Complete the level in under 21 seconds. Try again!";
        }
        TrialData storage = new TrialData();

        storage.srt_input_pressed = keyPressed;
        storage.correct_input     = answer;
        storage.was_input_correct = true;
        storage.rt    = timer.ElapsedMilliseconds;
        storage.block = progress.attempts;
        storage.srt_sequence_index = currentSequence;
        currentSequence            = 1;
        storage.srt_trial_index    = totalTrials;
        Upload(JsonUtility.ToJson(storage));
        totalTrials = totalTrials + 1;
        running     = false;
        SpeedUp.Play();
        totalTime = totalTime + timer.ElapsedMilliseconds;
        UnityEngine.Debug.Log(timer.ElapsedMilliseconds);
        responseTime.text = "You completed the attempt in " + time.ElapsedMilliseconds / 1000f + " seconds";

        /*if ((time.ElapsedMilliseconds < bestScore) || (bestScore == 0))
         * {
         *  bestScore = time.ElapsedMilliseconds;
         *  bestScoreText.text = "Best Score: " + bestScore / 1000f;
         * }*/
        UnityEngine.Debug.Log(responseTime.text);
    }
Esempio n. 28
0
    static int LastIndexOf(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2)
        {
            List <TrialData> obj  = (List <TrialData>)LuaScriptMgr.GetNetObjectSelf(L, 1, "List<TrialData>");
            TrialData        arg0 = (TrialData)LuaScriptMgr.GetNetObject(L, 2, typeof(TrialData));
            int o = obj.LastIndexOf(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 3)
        {
            List <TrialData> obj  = (List <TrialData>)LuaScriptMgr.GetNetObjectSelf(L, 1, "List<TrialData>");
            TrialData        arg0 = (TrialData)LuaScriptMgr.GetNetObject(L, 2, typeof(TrialData));
            int arg1 = (int)LuaScriptMgr.GetNumber(L, 3);
            int o    = obj.LastIndexOf(arg0, arg1);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 4)
        {
            List <TrialData> obj  = (List <TrialData>)LuaScriptMgr.GetNetObjectSelf(L, 1, "List<TrialData>");
            TrialData        arg0 = (TrialData)LuaScriptMgr.GetNetObject(L, 2, typeof(TrialData));
            int arg1 = (int)LuaScriptMgr.GetNumber(L, 3);
            int arg2 = (int)LuaScriptMgr.GetNumber(L, 4);
            int o    = obj.LastIndexOf(arg0, arg1, arg2);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: List<TrialData>.LastIndexOf");
        }

        return(0);
    }
Esempio n. 29
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, TrialData trialData)
 {
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     else
     {
         app.UseExceptionHandler(BuilderExtensions =>
         {
             BuilderExtensions.Run(async context =>
             {
                 context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                 var error = context.Features.Get <IExceptionHandlerFeature>();
                 if (error != null)
                 {
                     context.Response.addApplicationError(error.Error.Message);
                     await context.Response.WriteAsync(error.Error.Message);
                 }
             });
         });
         // app.UseHsts();
     }
     trialData.TrialSuppliers();
     app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials());
     app.UseDefaultFiles();
     app.UseAuthentication();
     app.Use(async(context, next) => {
         await next();
         if (context.Response.StatusCode == 404)
         {
             context.Request.Path = "/index.html";
             await next();
         }
     });
     app.UseStaticFiles();
     app.UseMvc();
 }
Esempio n. 30
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseReactDevelopmentServer(npmScript: "start");
                }
            });
            TrialData.EnsureBlogsAndPosts(app, Configuration);
            TrialData.EnsureUsers(app);
        }
	public override object Read(ES2Reader reader)
	{
		TrialData data = new TrialData();
		Read(reader, data);
		return data;
	}
Esempio n. 32
0
    //
    public void InitializeNewGenerationDataArrays(int generationIndex)
    {
        // For This Player:
        if(generationIndex >= generationDataList.Count) { // if new generation needs to be created
            //Debug.Log ("InitializeNewGenerationDataArrays" + generationIndex.ToString());

            int numAgents = playerRef.masterPopulation.populationMaxSize;
            GenerationData newGenerationData = new GenerationData(numAgents); // Now I have a generationData wrapper and an array of AgentData's

            //     Get number of Trials
            int numActiveTrials = 0;
            for(int i = 0; i < playerRef.masterTrialsList.Count; i++) { // First loop needed just to Count
                if(playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) {  // if active trial
                    numActiveTrials++;
                }
            }
            //Debug.Log ("NumActiveTrials= " + numActiveTrials.ToString() + ", NumAgents= " + numAgents.ToString());
            // Loop over all agents?
            for(int j = 0; j < numAgents; j++) {
                AgentData newAgentData = new AgentData(numActiveTrials);

                // Fill the AgentData's TrialsList:
                int curTrialIndex = 0;
                int totalNumComponents = 0;
                for(int i = 0; i < playerRef.masterTrialsList.Count; i++) {
                    if(playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) {  // if active trial
                        //     For each Trial, Get number of FitnessComponents & GameRounds
                        int numGameRounds = playerRef.masterTrialsList[i].numberOfPlays;
                        int totalFitnessComponents = playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count +
                                                        playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count;
                        int numActiveFitnessComponents = 0;
                        // Brain Components:
                        for(int b = 0; b < playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count; b++) {
                            if(playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList[b].on) {
                                numActiveFitnessComponents++;
                                totalNumComponents++;
                            }
                        }
                        // Game Components:
                        for(int g = 0; g < playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; g++) {
                            if(playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList[g].on) {
                                numActiveFitnessComponents++;
                                totalNumComponents++;
                            }
                        }

                        int curFitnessComponentIndex = 0;
                        TrialData newTrialData = new TrialData(numActiveFitnessComponents);
                        for(int b = 0; b < playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count; b++) {
                            if(playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList[b].on) {
                                newTrialData.fitnessComponentDataArray[curFitnessComponentIndex] = new FitnessComponentData(numGameRounds);
                                curFitnessComponentIndex++;
                            }
                        }
                        for(int g = 0; g < playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; g++) {
                            if(playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList[g].on) {
                                newTrialData.fitnessComponentDataArray[curFitnessComponentIndex] = new FitnessComponentData(numGameRounds);
                                curFitnessComponentIndex++;
                            }
                        }
                        newAgentData.trialDataArray[curTrialIndex] = newTrialData; // Set AgentData for this agent.
                        //Debug.Log ("curTrialIndex= " + curTrialIndex.ToString() + ", numGameRounds= " + numGameRounds.ToString() + ", numFitnessComponents= " + totalFitnessComponents.ToString() + ", numActiveFitnessComponents= " + numActiveFitnessComponents.ToString());
                        curTrialIndex++; // before or after?

                    }
                }
                newGenerationData.agentDataArray[j] = newAgentData; // actually assign the new AgentData instance to generationData
                newGenerationData.totalNumFitnessComponents = totalNumComponents;
            }
            //
            generationDataList.Add (newGenerationData); // Add the newly created generation data to the master list
        }
    }
Esempio n. 33
0
	public SessionData(string path) {


		string[] lines;
		// Read summary text
		try {
			lines = File.ReadAllLines(path + "/summary.tsv");
		}
		catch(FileNotFoundException) {
			Debug.Log("File " + path + " not found...");
			return;
		}

		// Parse lines
		// Starts at i = 1 because i = 0 is the header
		for (int i = 1; i < lines.Length; i++) {
			TrialData td = new TrialData(lines[i], path);
			if (td.initialized) {
				trials.Add(td);
			}
		}

		for (int i = 0; i < trials.Count; i++) {
			tDist += trials[i].distToTarg;
			hDist += trials[i].lastHoopDistance;

			oTime += trials[i].timeToGrab;
			hTime += (trials[i].lastHoopAttempt - trials[i].timeToGrab);
			tTime += (trials[i].timeToTarg - trials[i].lastHoopAttempt);

			framesRed += trials[i].red;

			fDivergence += trials[i].fAngle;
			uDivergence += trials[i].uAngle;
		}

		tDist /= trials.Count;
		hDist /= trials.Count;
		oTime /= trials.Count;
		hTime /= trials.Count;
		tTime /= trials.Count;
		framesRed /= trials.Count;
		fDivergence /= trials.Count;
		uDivergence /= trials.Count;

		initialized = true;

	}
	// 

	public void InitializeNewGenerationDataArrays(int generationIndex) {
        if (recordScoresTrialDataArray == null) { // if first time:
            // USE THIS STUFF TO STORE GLOBAL RECORD SCORES PER-FITNESSCOMPONENT!!!
            // This will then be used to help score each generation in the future
            // I'm just re-using the data classes here but this might need a more custom solution later.
            // as with the rest of this system, it can't handle drastic changes to number/type of Trials, or adding/deleting fitness components.
            // Eventually I'll have to build a very flexible system that can handle gen0 being totally different from currentGen....
            recordScoresTrialDataArray = new List<TrialData>();
            int numActiveTrials = 0;
            for (int i = 0; i < playerRef.masterTrialsList.Count; i++) { // First loop needed just to Count
                if (playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) {  // if active trial
                    numActiveTrials++;
                }
            }
            // Loop through all Trials:
            for (int trialIndex = 0; trialIndex < numActiveTrials; trialIndex++) {
                // Get numFitnessComponents:
                int numFitnessComponents = playerRef.masterTrialsList[trialIndex].fitnessManager.masterFitnessCompList.Count;
                TrialData newTrialData = new TrialData(numFitnessComponents);

                for (int fitCompIndex = 0; fitCompIndex < numFitnessComponents; fitCompIndex++) {
                    FitnessComponentData newFitnessComponentData = new FitnessComponentData();
                    newTrialData.fitnessComponentDataArray[fitCompIndex] = newFitnessComponentData;
                }
                recordScoresTrialDataArray.Add(newTrialData);
            }
        }

		// For This Player:
		if(generationIndex >= generationDataList.Count) { // if new generation needs to be created

            // !!!!!!!@!@!#$!@$#!$!@@@@@@@@@@@@@@@@@@@@@@@!@$#!#############!!!!!!!!!!!!!!!!!!!!!!^^^^^^^^^^^^^$%&###############%***********************$$$$$$$$##########
            // Calculate total TrialWeights and totalFitnessComponentWeights per Trial for later use somewhere in this function!!!!
            int numAgents = playerRef.masterPopulation.populationMaxSize;
            //     Get number of Trials:
            int numActiveTrials = 0;
			for(int i = 0; i < playerRef.masterTrialsList.Count; i++) { // First loop needed just to Count
				if(playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) {  // if active trial
					numActiveTrials++;
				}
			}
            GenerationData newGenerationData = new GenerationData(numActiveTrials);
            
            // Loop through all Trials:
            for(int trialIndex = 0; trialIndex < numActiveTrials; trialIndex++) {
                // Get numFitnessComponents:
                int numFitnessComponents = playerRef.masterTrialsList[trialIndex].fitnessManager.masterFitnessCompList.Count;
                TrialData newTrialData = new TrialData(numFitnessComponents);
                
                for(int fitCompIndex = 0; fitCompIndex < numFitnessComponents; fitCompIndex++) {
                    FitnessComponentData newFitnessComponentData = new FitnessComponentData(numAgents);

                    for(int a = 0; a < numAgents; a++) {
                        AgentData newAgentData = new AgentData();

                        newFitnessComponentData.agentDataArray[a] = newAgentData;
                    }
                    newTrialData.totalSumOfWeights += playerRef.masterTrialsList[trialIndex].fitnessManager.masterFitnessCompList[fitCompIndex].weight;
                    newTrialData.fitnessComponentDataArray[fitCompIndex] = newFitnessComponentData;
                }
                newGenerationData.totalSumOfWeights += playerRef.masterTrialsList[trialIndex].weight;
                newGenerationData.trialDataArray[trialIndex] = newTrialData; // actually assign the new AgentData instance to generationData
                newGenerationData.totalNumFitnessComponents = numFitnessComponents;
            }

            // AvgGenome:
            // Calculate Generation average genome:  // BROKEN BECAUSE USING NEW GENOMES!!!
            /*Genome avgGenome = new Genome();
            avgGenome.genomeBiases = new float[playerRef.masterPopulation.masterAgentArray[0].genome.genomeBiases.Length];
            avgGenome.genomeWeights = new float[playerRef.masterPopulation.masterAgentArray[0].genome.genomeWeights.Length];
            avgGenome.ZeroGenome(); // set all values to 0f;
            for (int i = 0; i < numAgents; i++) {
                // iterate through Bias Arrays and add each agent's bias value to the avg
                for (int b = 0; b < avgGenome.genomeBiases.Length; b++) {
                    avgGenome.genomeBiases[b] += playerRef.masterPopulation.masterAgentArray[i].genome.genomeBiases[b] / (float)numAgents;
                }
                // iterate through Weight Arrays and add each agent's weight value to the avg
                for (int w = 0; w < avgGenome.genomeWeights.Length; w++) {
                    avgGenome.genomeWeights[w] += playerRef.masterPopulation.masterAgentArray[i].genome.genomeWeights[w] / (float)numAgents;
                }
            }
            // Save the genome values to this generation Data:
            newGenerationData.genAvgGenome = avgGenome;*/
            //newGenerationData.genAvgGenome.genomeBiases = avgGenome.genomeBiases;
            //newGenerationData.genAvgGenome.genomeWeights = avgGenome.genomeWeights;

            generationDataList.Add(newGenerationData); // Add the newly created generation data to the master list



            // OLD BELOW v v v v v v v v v v v v
            // Loop over all agents
            /*int numAgents = playerRef.masterPopulation.populationMaxSize;
            for (int j = 0; j < numAgents; j++) {
				AgentData newAgentData = new AgentData(numActiveTrials);

				// Fill the AgentData's TrialsList:		
				int curTrialIndex = 0;
				int totalNumComponents = 0;
				for(int i = 0; i < playerRef.masterTrialsList.Count; i++) {
					if(playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) {  // if active trial
						//     For each Trial, Get number of FitnessComponents & GameRounds
						int numGameRounds = playerRef.masterTrialsList[i].numberOfPlays;
						int totalFitnessComponents = playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count + 
														playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count;
						int numActiveFitnessComponents = 0;
						// Brain Components:
						for(int b = 0; b < playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count; b++) {
							if(playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList[b].on) {
								numActiveFitnessComponents++;
								totalNumComponents++;
							}
						}
						// Game Components:
						for(int g = 0; g < playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; g++) {
							if(playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList[g].on) {
								numActiveFitnessComponents++;
								totalNumComponents++;
							}
						}
						
						int curFitnessComponentIndex = 0;
						TrialData newTrialData = new TrialData(numActiveFitnessComponents);
						for(int b = 0; b < playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count; b++) {
							if(playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList[b].on) {
								newTrialData.fitnessComponentDataArray[curFitnessComponentIndex] = new FitnessComponentData(numGameRounds);
								curFitnessComponentIndex++;
							}
						}
						for(int g = 0; g < playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; g++) {
							if(playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList[g].on) {
								newTrialData.fitnessComponentDataArray[curFitnessComponentIndex] = new FitnessComponentData(numGameRounds);
								curFitnessComponentIndex++;
							}
						}
						newAgentData.trialDataArray[curTrialIndex] = newTrialData; // Set AgentData for this agent.
						//Debug.Log ("curTrialIndex= " + curTrialIndex.ToString() + ", numGameRounds= " + numGameRounds.ToString() + ", numFitnessComponents= " + totalFitnessComponents.ToString() + ", numActiveFitnessComponents= " + numActiveFitnessComponents.ToString());
						curTrialIndex++; // before or after?
							
					}
				}
				newGenerationData.agentDataArray[j] = newAgentData; // actually assign the new AgentData instance to generationData
				newGenerationData.totalNumFitnessComponents = totalNumComponents;
			}	
			//
			generationDataList.Add (newGenerationData); // Add the newly created generation data to the master list
            */
		}               
	}