// ShowStimuli (MANDATORY) // Modify and display a stimulus based on trial parameters. // Use the dimension names defined in your config file as string // keys to access the float lists contained in the TrialConfig. // // IMPORTANT: Experiment will not continue running until EndShowStimuli is called. // // EXAMPLE: to read a dimension named "dim1", write: // // config["dim1"][0] // // The trailing [0] indexer is necessary because the // dict value is a list of floats. public override void ShowStimuli(TrialConfig config) { SetText("Now presenting stimulus."); audioSource.pitch = config["pitch"][0]; audioSource.Play(); StartCoroutine(EndShowStimuliAfterSeconds(1f)); }
IEnumerator RunExperiment() { while (!isDone) { SetText("Querying for next trial"); yield return(StartCoroutine(client.Ask())); Debug.Log(trialNum); config = client.GetConfig(); SetText("Now presenting stimulus."); yield return(StartCoroutine(PresentStimulus(config))); SetText("Was it visible? (Y/N)"); yield return(StartCoroutine(LogUserInput())); if (trialNum == (totalTrials - 1)) { SetText("Experiment complete"); isDone = true; break; } trialNum++; } yield return(0); }
public IEnumerator ComputeInverseFromModel() { QueryEnabled(false); float y = ySlider.GetValue(); TrialConfig constraints = new TrialConfig(); foreach (ModelSlider slider in xSliders) { if (slider.isLocked) { constraints.Add(slider.GetName(), new List <float>() { slider.GetValue() }); } } yield return(StartCoroutine(client.Query(QueryType.inverse, constraints: constraints, y: y, probability_space: probSpace))); QueryMessage m = client.GetQueryResponse(); foreach (ModelSlider slider in xSliders) { slider.SetValue(m.x[slider.GetName()][0]); } ySlider.SetValue(m.y); QueryEnabled(true); }
// Use this for initialization void Start() { #if UNITY_EDITOR StreamReader reader = new StreamReader(ConfigFile); String text = reader.ReadToEnd(); trialConfigs = JsonUtility.FromJson <TrialConfigs>(text); reader.Close(); if (shuffleTrials) { ShuffleArray <TrialConfig>(trialConfigs.configs); } #endif current = new TrialConfig(); current.name = "DebugTrial"; current.targetDistance = 0.2f; current.targetSize = 0.05f; current.zDistance = 2; current.feedbackConditions = new string[] { "Glow", "Cursor" }; current.selectionCondition = new string[] { "Dwell", "0.500" }; origCursorScale = cursor.transform.Find("CursorVisual").localScale; origZDistance = isoWheel.transform.position.z; fbCondManager = GetComponent <FeedbackConditionManager>(); selCondManager = GetComponent <SelectionConditionManager>(); trialConductor = GetComponent <TrialConductor>(); }
public IEnumerator SpawnSliders() { QueryEnabled(false); //Get the current config with n parameters yield return(StartCoroutine(client.Params())); //initParams = new TrialConfig(); //initParams.Add("Dimension 1", new List<float>() { 0.0f }); initParams = client.GetConfig(version: "0.0"); if (!initialized) { foreach (KeyValuePair <string, List <float> > entry in initParams) { string name = entry.Key; float min = entry.Value[0]; float max = entry.Value[1]; GameObject sliderObj = Instantiate(sliderPrefab, canvasGroup.transform.position, Quaternion.identity, canvasGroup.transform); sliderObj.transform.parent = xslidergroup.transform; ModelSlider slider = sliderObj.GetComponent <ModelSlider>(); slider.InitSlider(min, max, name, false); slider.SetQueryModel(this); xSliders.Add(slider); } } //Spawn final slider and query twice for its limits yield return(StartCoroutine(client.Query(QueryType.max))); QueryMessage m = client.GetQueryResponse(); maxY = m.y; yield return(StartCoroutine(client.Query(QueryType.min))); m = client.GetQueryResponse(); minY = m.y; string nameY = yAxisName; //Spawn + initialize slider, if necessary. GameObject ySliderObj; if (!initialized) { ySliderObj = Instantiate(sliderPrefab, canvasGroup.transform.position + new Vector3(-1.0f, 0.5f), Quaternion.identity, canvasGroup.transform); RectTransform rt = ySliderObj.GetComponent <RectTransform>(); rt.localScale *= 1.25f; rt.anchorMax = new Vector2(.9f, 0.55f); rt.anchorMin = new Vector2(.9f, 0.55f); rt.pivot = new Vector2(1f, 0.5f); ySlider = ySliderObj.GetComponent <ModelSlider>(); ySlider.SetQueryModel(this); ySlider.DisableLockToggle(); } //ySlider.InitSlider(0, 3.4567f, nameY, true); ySlider.InitSlider(minY, maxY, nameY, true); StartCoroutine(ComputeYFromModel()); initialized = true; }
//Display a stimulus, and complete when the stimulus is done private IEnumerator PresentStimulus(TrialConfig config) { GameObject circle = Instantiate(circlePrefab); FlashSprite fs = circle.GetComponent <FlashSprite>(); fs.SetGrayscaleColor(config["gsColor"][0]); yield return(new WaitForSeconds(fs.flashDuration)); }
//Display the stimulus; complete when the stimulus is done displaying private IEnumerator PresentStimulus(TrialConfig config) { GameObject circle = Instantiate(circlePrefab); FlashSprite fs = circle.GetComponent <FlashSprite>(); fs.alpha = config["alpha"][0]; yield return(new WaitForSeconds(fs.flashDuration)); }
static int ReadTrialData(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); TrialConfig obj = (TrialConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "TrialConfig"); obj.ReadTrialData(); return(0); }
static int Initialize(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); TrialConfig obj = (TrialConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "TrialConfig"); obj.Initialize(); return(0); }
// ShowStimuli (MANDATORY) // Display a stimulus, and finish when the stimulus is done. // Use the dimension names defined in your config file as string keys to access the float lists // contained in the TrialConfig. Experiment will not continue running until EndShowStimuli is called. public override void ShowStimuli(TrialConfig config) { SetText("Now presenting stimulus."); GameObject circle = Instantiate(circlePrefab); FlashSprite fs = circle.GetComponent <FlashSprite>(); fs.SetColor(config["R"][0], config["G"][0], config["B"][0], 1.0f); StartCoroutine(EndShowStimuliAfterSeconds(fs.flashDuration)); }
//Display a stimulus, and complete when the stimulus is done private IEnumerator PresentStimulus(TrialConfig config) { GameObject circle = Instantiate(circlePrefab); FlashSprite fs = circle.GetComponent <FlashSprite>(); Color c = Color.HSVToRGB(config["hue"][0], 1.0f, 0.15f); fs.SetColor(c.r, c.g, c.b, config["alpha"][0]); yield return(new WaitForSeconds(fs.flashDuration)); }
static int GetTotalScore(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); TrialConfig obj = (TrialConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "TrialConfig"); uint o = obj.GetTotalScore(); LuaScriptMgr.Push(L, o); return(1); }
// ShowStimuli (MANDATORY) // Display a stimulus, and finish when the stimulus is done. // Use the dimension names defined in your config file as string keys to access the float lists // contained in the TrialConfig. Experiment will not continue running until EndShowStimuli is called. public override void ShowStimuli(TrialConfig config) { GameObject circle = Instantiate(circlePrefab); FlashSprite fs = circle.GetComponent <FlashSprite>(); Color c = Color.HSVToRGB(config["hue"][0], config["saturation"][0], 0.2f); fs.SetColor(c.r, c.g, c.b, config["alpha"][0]); StartCoroutine(EndShowStimuliAfterSeconds(fs.flashDuration)); SetText("Now presenting stimulus."); }
static int GetTrialListByDay(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); TrialConfig obj = (TrialConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "TrialConfig"); uint arg0 = (uint)LuaScriptMgr.GetNumber(L, 2); List <TrialData> o = obj.GetTrialListByDay(arg0); LuaScriptMgr.PushObject(L, o); return(1); }
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); }
IEnumerator DisplayOptimal() { yield return(StartCoroutine(client.Query(QueryType.max))); QueryMessage m = client.GetQueryResponse(); TrialConfig maxLoc = m.x; GameObject circle = Instantiate(circlePrefab); FlashSprite fs = circle.GetComponent <FlashSprite>(); fs.SetColor(maxLoc["R"][0], maxLoc["G"][0], maxLoc["B"][0], 1.0f); fs.flashDuration = -1.0f; //never destroy }
IEnumerator DisplayOptimal() { yield return(StartCoroutine(client.Query(QueryType.inverse, y: 0.75f, probability_space: true))); QueryMessage m = client.GetQueryResponse(); TrialConfig maxLoc = m.x; GameObject circle = Instantiate(circlePrefab); FlashSprite fs = circle.GetComponent <FlashSprite>(); fs.alpha = maxLoc["alpha"][0]; fs.flashDuration = -1.0f; //never destroy }
// Start is called before the first frame update IEnumerator Start() { config = new TrialConfig(); string configPath = "Assets/StreamingAssets/configs/single_lse_1d.ini"; yield return(StartCoroutine(client.StartServer(configPath: configPath))); SetText("Welcome. Press Y to begin."); yield return(new WaitUntil(() => Input.GetKeyDown(KeyCode.Y))); yield return(StartCoroutine(RunExperiment())); }
private void Awake() { trialConfig = FindObjectOfType <ExperimentConfig>().GetCurrentConfig(); // DataCollectors dataCollectors = new List <IDataCollector>(); // order matters! dataCollectors.Add(FindObjectOfType <TrialStateTracker>()); dataCollectors.Add(FindObjectOfType <KeyboardPrompt>()); dataCollectors.Add(FindObjectOfType <TouchTracker>()); SetupFile(); }
IEnumerator DisplayOptimal() { yield return(StartCoroutine(client.Query(QueryType.inverse, y: 0.75f, probability_space: true))); QueryMessage m = client.GetQueryResponse(); TrialConfig maxLoc = m.x; GameObject circle = Instantiate(circlePrefab); FlashSprite fs = circle.GetComponent <FlashSprite>(); fs.SetGrayscaleColor(maxLoc["gsColor"][0], maxLoc["alpha"][0]); fs.flashDuration = -1.0f; //never destroy SetText("Experiment complete! Displaying 75% threshold color: "); }
IEnumerator RunExperiment() { while (!isDone) { Debug.Log("trial# " + trialNum + " strat " + currentStrat + " strat's trial# " + AEPsychStrats[currentStrat].currentTrial); SetText("Querying for next trial"); yield return(StartCoroutine(client.Ask())); config = client.GetConfig(); SetText("Now presenting stimulus."); yield return(StartCoroutine(PresentStimulus(config))); SetText("Was it visible? (Y/N)"); yield return(StartCoroutine(LogUserInput())); //check if strat or experiment is done if (AEPsychStrats[currentStrat].currentTrial == (totalTrials - 1)) { SetText("Strat is complete."); AEPsychStrats[currentStrat].isDone = true; if (checkFinished()) { SetText("Experiment complete"); isDone = true; break; } } AEPsychStrats[currentStrat].currentTrial++; trialNum++; //in this example, switch every 5 trials if (AEPsychStrats[currentStrat].currentTrial % 5 == 4) { currentStrat = (currentStrat + 1) % numStrats; while (AEPsychStrats[currentStrat].isDone) { currentStrat = (currentStrat + 1) % numStrats; } Debug.Log("switched to strat " + currentStrat); yield return(StartCoroutine(client.Resume(AEPsychStrats[currentStrat].stratId))); } } yield return(0); }
public static string trialConfigToString(TrialConfig config) { string output = config.name + " Runs: " + config.runs + " Feedback:"; foreach (string s in config.feedbackConditions) { output += " " + s + ","; } output += "\nSelection:"; foreach (string s in config.selectionCondition) { output += " " + s + ","; } return(output); }
// Start is called before the first frame update IEnumerator Start() { GameObject example = Instantiate(examplePrefab); example.SetActive(true); config = new TrialConfig(); string configPath = "Assets/StreamingAssets/configs/single_opt_3d.ini"; yield return(StartCoroutine(client.StartServer(configPath: configPath))); SetText("Welcome. Note the color above, which is indigo. Press Y to begin."); yield return(new WaitUntil(() => Input.GetKeyDown(KeyCode.Y))); //example.SetActive(false); yield return(StartCoroutine(RunExperiment())); }
static int _CreateTrialConfig(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 0) { TrialConfig obj = new TrialConfig(); LuaScriptMgr.PushObject(L, obj); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: TrialConfig.New"); } return(0); }
public void RpcSetTrial(TrialConfig config) { current = config; trialConductor.TrialName = config.name; trialConductor.tasks = config.runs; GravityCursor gc = cursor.GetComponent <GravityCursor>(); gc.DefaultCursorDistance = config.zDistance; cursor.transform.Find("CursorVisual").localScale = origCursorScale * (config.zDistance / origZDistance); isoWheel.transform.Translate(new Vector3(0, 0, config.zDistance - isoWheel.transform.position.z)); //set new z value IsoMorph morph = isoWheel.GetComponent <IsoMorph>(); morph.distance = config.targetDistance; morph.size = config.targetSize; List <string> fbConds = new List <string>(config.feedbackConditions); fbCondManager.glow = fbConds.Contains("Glow"); fbCondManager.gravity = fbConds.Contains("Gravity"); fbCondManager.cursor = fbConds.Contains("Cursor"); fbCondManager.sound = fbConds.Contains("Sound"); switch (config.selectionCondition[0]) { case "Dwell": float seconds = float.Parse(config.selectionCondition[1], System.Globalization.CultureInfo.InvariantCulture); selCondManager.setDwellSelection(seconds); break; case "Clicker": selCondManager.setClickerSelection(); break; case "AirTap": selCondManager.setAirTapSelection(); break; } fbCondManager.Apply(); //isoWheel.GetComponent<IsoAnalyser>().Analyze(); }
public IEnumerator ComputeYFromModel() { QueryEnabled(false); TrialConfig x = new TrialConfig(); foreach (ModelSlider slider in xSliders) { x.Add(slider.GetName(), new List <float>() { slider.GetValue() }); } yield return(StartCoroutine(client.Query(QueryType.prediction, x: x, probability_space: probSpace))); QueryMessage m = client.GetQueryResponse(); ySlider.SetValue(m.y); QueryEnabled(true); }
public void ShowQueryResults() { QueryEnabled(false); TrialConfig queryConfig = new TrialConfig(); List <float> values = GetSliderValues(); int idx = 0; foreach (KeyValuePair <string, List <float> > entry in initParams) { queryConfig[entry.Key] = new List <float>(); // Add value to 1st and 2nd index of List, in the case that the ShowStimuli // method of the experiment reads two values for each dimension queryConfig[entry.Key].Add(values[idx]); queryConfig[entry.Key].Add(values[idx]); idx++; } HideSliders(); experiment.ShowStimuli(queryConfig); }
// Start is called before the first frame update IEnumerator Start() { AEPsychStrats = new List <AEPsychStrategy>() { }; config = new TrialConfig(); string configPath = "Assets/StreamingAssets/configs/single_lse_2d.ini"; for (int i = 0; i < numStrats; i++) { AEPsychStrategy b = gameObject.AddComponent <AEPsychStrategy>() as AEPsychStrategy; AEPsychStrats.Add(b); yield return(StartCoroutine(b.InitStrat(client, configPath: configPath))); } //start with strat 0 yield return(StartCoroutine(client.Resume(AEPsychStrats[currentStrat].stratId))); SetText("Welcome. Press Y to begin."); yield return(new WaitUntil(() => Input.GetKeyDown(KeyCode.Y))); yield return(StartCoroutine(RunExperiment())); }
public void AddToBadTrials(TrialConfig trialConfig) { badTrials.Add(trialConfig); }
public void LoadConfig() { AnnouncementConfigData = new AnnouncementConfig(); BadgeAttrConfigData = new BadgeAttrConfig(); ConstStringConfigData = new ConstStringConfig(); CommonConfig = new CommonConfig(); AttrNameConfigData = new AttrNameConfig(); RoleBaseConfigData2 = new BaseDataConfig2(); AttrDataConfigData = new AttrDataConfig(); TeamLevelConfigData = new TeamLevelConfig(); RoleLevelConfigData = new RoleLevelConfig(); NPCConfigData = new NPCDataConfig(); SkillConfig = new SkillConfig(); GoodsConfigData = new GoodsConfig(); StoreGoodsConfigData = new StoreGoodsConfig(); BaseDataBuyConfigData = new BaseDataBuyConfig(); TaskConfigData = new TaskDataConfig(); AwardPackConfigData = new AwardPackDataConfig(); PractiseConfig = new PractiseConfig(); PracticePveConfig = new PracticePveConfig(); PractiseStepConfig = new PractiseStepConfig(); GameModeConfig = new GameModeConfig(); TrainingConfig = new TrainingConfig(); TattooConfig = new TattooConfig(); EquipmentConfigData = new EquipmentConfig(); TourConfig = new TourConfig(); GuideConfig = new GuideConfig(); FunctionConditionConfig = new FunctionConditionConfig(); RoleShapeConfig = new RoleShapeConfig(); FashionConfig = new FashionConfig(); FashionShopConfig = new FashionShopConfig(); VipPrivilegeConfig = new VipPrivilegeConfig(); pushConfig = new PushConfig(); presentHpConfigData = new PresentHpConfig(); LotteryConfig = new LotteryConfig(); starAttrConfig = new StarAttrConfig(); qualityAttrCorConfig = new QualityAttrCorConfig(); skillUpConfig = new SkillUpConfig(); RankConfig = new RankConfig(); signConfig = new SignConfig(); NewComerSignConfig = new NewComerSignConfig(); FightingCapacityConfig = new FightingCapacityConfig(); BodyInfoListConfig = new BodyInfoListConfig(); BadgeSlotsConfig = new BadgeSlotConfig(); GoodsComposeNewConfigData = new GoodsComposeNewConfig(); SceneConfig = new SceneConfig(); ReboundAttrConfigData = new ReboundAttrConfig(); CareerConfigData = new CareerConfig(); PotientialEffectConfig = new PotientialEffectConfig(); PVPPointConfig = new PVPPointConfig(); WinningStreakAwardConfig = new WinningStreakAwardConfig(); ArticleStrengthConfig = new ArticleStrengthConfig(); PhRegainConfig = new PhRegainConfig(); MatchAchievementConfig = new MatchAchievementConfig(); SpecialActionConfig = new SpecialActionConfig(); StealConfig = new StealConfig(); CurveRateConfig = new CurveRateConfig(); DunkRateConfig = new DunkRateConfig(); AIConfig = new AIConfig(); AttrReduceConfig = new AttrReduceConfig(); qualifyingConfig = new QualifyingConfig(); qualifyingNewConfig = new QualifyingNewConfig(); qualifyingNewerConfig = new QualifyingNewerConfig(); bullFightConfig = new BullFightConfig(); HedgingConfig = new HedgingConfig(); roleGiftConfig = new RoleGiftConfig(); DebugConfig = new DebugConfig(); shootGameConfig = new ShootGameConfig(); MapConfig = new MapConfig(); activityConfig = new ActivityConfig(); trialConfig = new TrialConfig(); gameMatchConfig = new GameMatchConfig(); shootSolutionManager = new ShootSolutionManager(); talentConfig = new TalentConfig(); ladderConfig = new LadderConfig(); matchSoundConfig = new MatchSoundConfig(); matchMsgConfig = new MatchMsgConfig(); MatchPointsConfig = new MatchPointsConfig(); AnimationSampleManager.Instance.LoadXml(); }