private Bitmap LoadImage(Stimulus stimul) { String filename = stimul.Filename; Bitmap bmp = new Bitmap(filename); return(bmp); }
public override void Stimulate(Stimulus stimulus) { if (stimulus.Id == AttackStimulus.ID) { reactToAttack((AttackStimulus)stimulus); } }
void LoadStimuli() { stimuli.Clear(); int[] amplitudeValues = { 0, (int)Settings.Values.amplitude_1, (int)Settings.Values.amplitude_2, (int)Settings.Values.amplitude_3, (int)Settings.Values.amplitude_4 }; int[] waveLengthValues = { (int)Settings.Values.waveLength_1, (int)Settings.Values.waveLength_2, (int)Settings.Values.waveLength_3, (int)Settings.Values.waveLength_4, (int)Settings.Values.waveLength_5 }; int count = 0; for (int i = 0; i <= Settings.Values.repeat; i++) { for (int j = 0; j < waveLengthValues.Count(); j++) { for (int k = 0; k < amplitudeValues.Count(); k++) { Stimulus stimulus = new Stimulus(count, i, waveLengthValues[j], amplitudeValues[k]); stimuli.Add(stimulus); count++; } } } var shuffle = (from stimulus in stimuli orderby Guid.NewGuid() select stimulus); stimuli = shuffle.ToList(); Stimulus[] dbg = shuffle.ToArray(); currentStimulusIndex = 0; }
void OnCollisionEnter(Collision col) { // Debug.Log(" Arrow "+this.gameObject+" hit " + col.collider.gameObject.name + "Relative velocity was " + col.relativeVelocity + ", magnitude " + col.relativeVelocity.magnitude+" at time "+Time.time); if (col.relativeVelocity.magnitude > velocityThresholdForStim) { Stimulus stim = new Stimulus(StimType.Arrow, col.relativeVelocity.magnitude); Player player = null; if ((col.collider.transform.parent != null) && (col.collider.transform.parent.gameObject != null)) { player = col.collider.transform.parent.gameObject.GetComponent <Player>(); // TODO - assumes the parent of the collider contains the Player component } if (player != null) { player.Stimulate(stim, col.contacts[0].point, col.contacts[0].normal); } StimReactor reactor = null; if ((col.collider.transform.parent != null) && (col.collider.transform.parent.gameObject != null)) { reactor = col.collider.transform.parent.gameObject.GetComponent <StimReactor>(); // TODO - assumes the parent of the collider contains the StimReactor component } if (reactor != null) { reactor.Stimulate(stim); } } }
void Start() { stimulus = GetComponent <Stimulus>(); isProjectile = false; isOrbiting = false; isThrowable = true; //playersWithTelekinesis = FindObjectsOfType<TelekinesisPower>(); //foreach (TelekinesisPower power in playersWithTelekinesis) //{ // Collider test_collider = power.gameObject.GetComponent<Collider>(); // if (test_collider != null) // { // telekinesisPlayerColliders.Add(test_collider); // } //} orbitRotationSpeed = random.Next(2, 5); baseRotationOrbitSpeed = orbitRotationSpeed; orbitTranslationSpeed = orbitRotationSpeed * 5; baseTranslationOrbitSpeed = orbitTranslationSpeed; orbitHeight = orbitRotationSpeed + random.Next(-2, 2); //+ 2f; baseOrbitHeight = orbitHeight; collide = GetComponent <Collider>(); rb = GetComponent <Rigidbody>(); rb.useGravity = true; }
// destroy self and spawn pfx and sfx objects that will stick around to do fx stuff after i'm gone private void BreakSelf(Stimulus breakStim) { Debug.Log(gameObject + ", breaking self!"); if (breakSFX != null) { GameObject sfx = (GameObject)Instantiate(breakSFX.gameObject, transform.position, transform.rotation) as GameObject; Destroy(sfx, 30f); RandomizedSFX rsfx = sfx.GetComponent <RandomizedSFX>(); rsfx.PlaySFX(); } if (breakPFX != null) { GameObject pfx = (GameObject)Instantiate(breakPFX, transform.position, transform.rotation) as GameObject; Destroy(pfx, 60f); } VRInteractable interactable = this.gameObject.GetComponent <VRInteractable>(); if (interactable != null) { interactable.GetDropped(false); } Destroy(this.gameObject); }
void Log(LogLib.Logger <int> logger, Stimulus stimulus, int value) { logger.NewEntry(); logger.Log("rep", stimulus.repeatId.ToString()); logger.Log("ecc", stimulus.visionArea.ToString()); logger.Log("tech", stimulus.techID.ToString()); logger.Log(value); }
void Log(LogLib.Logger <int> logger, Stimulus stimulus, int value) { logger.NewEntry(); logger.Log("rep", stimulus.repeatId.ToString()); logger.Log("amp", stimulus.amplitude.ToString()); logger.Log("wav", stimulus.waveLength.ToString()); logger.Log(value); }
IEnumerator runExperiment() { //Start the experiment after 3 seconds string experimentOutput = ""; for (int i = 0; i < 3; i++) { experimentText.text = "The experiment will start in " + (3 - i) + " seconds"; yield return(new WaitForSeconds(1f)); } //Wait 1 more second before starting the experiment experimentImage.gameObject.SetActive(true); experimentText.text = ""; yield return(new WaitForSeconds(1f)); //Foreach trial for (int i = 0; i < numberOfTrials; i++) { //Present user with stimulus experimentImage.gameObject.SetActive(false); Stimulus stimulus = (Stimulus)Random.Range(0, 2); experimentText.text = stimulus.ToString(); yield return(new WaitForSeconds(instructionTime)); //Generate the dots and present them to the user experimentText.text = ""; int numberOfDots = Random.Range(minNumberOfDots, maxNumberOfDots + 1); List <GameObject> allDots = new List <GameObject>(); for (int j = 0; j < numberOfDots; j++) { GameObject newDot = Instantiate(dot); allDots.Add(newDot); } yield return(new WaitForSeconds(dotTime)); //Measure the state of the user bool successfulInput = (Input.GetKey(KeyCode.UpArrow) && stimulus == Stimulus.Focus) || (Input.GetKey(KeyCode.UpArrow) == false && stimulus == Stimulus.Relax); experimentOutput += " " + stimulus.ToString() + ":" + successfulInput.ToString() + " "; //Present the user with focus square and delete the dots for (int j = 0; j < numberOfDots; j++) { Destroy(allDots[j]); } allDots.Clear(); experimentImage.gameObject.SetActive(true); yield return(new WaitForSeconds(restTime)); } //The experiment has now finished experimentImage.gameObject.SetActive(false); experimentText.text = experimentOutput + "\n" + "Press <SPACE> to Start Experiment"; experimentRunning = false; }
public void Update() { if (Time.time >= m_NextJingleTime) { Match.instance.SendStim( Stimulus.CreateStimulus((int)EStimulusType.StarJingle, ESensorType.Hearing, Position, this, IsSuperStar ? 1f : 0.5f)); m_NextJingleTime = Time.time + 1f; } }
public override void StimulusReceived(Stimulus stim, BlackboardMemory sensorMemory) { Tank t = (Tank)Agent; Vector3 toTarget = stim.EmitterPos - t.Position; if (toTarget.sqrMagnitude > m_HearingRadius * m_HearingRadius) { return; } //star jingle if (stim.StimulusType == (int)EStimulusType.StarJingle) { bool needUpdateCachedStar = false; int cachedStarKey = (int)EBBKey.CaredStar; Star star = (Star)stim.TargetObject; int cachedStarID = sensorMemory.GetValue <int>(cachedStarKey, -1); if (cachedStarID < 0) { needUpdateCachedStar = true; } else { Star cachedStar = Match.instance.GetStarByID(cachedStarID); if (cachedStar == null) //no star found, use current { needUpdateCachedStar = true; } else { //check if need update cached star if ((cachedStar.Position - t.Position).sqrMagnitude > toTarget.sqrMagnitude) { needUpdateCachedStar = true; } } } if (needUpdateCachedStar) { //update target to nearer one sensorMemory.SetValue(cachedStarKey, star.ID); sensorMemory.SetValue((int)EBBKey.TargetStarPos, star.Position); } } else if (stim.StimulusType == (int)EStimulusType.StarTaken) { //if hears star taken, remove it from memory int cachedStarKey = (int)EBBKey.CaredStar; Star star = (Star)stim.TargetObject; int cachedStarID = sensorMemory.GetValue <int>(cachedStarKey, -1); if (star.ID == cachedStarID) { sensorMemory.DelValue(cachedStarKey); sensorMemory.DelValue((int)EBBKey.TargetStarPos); } } }
public override void Act(params object[] args) { if (this.Life.Energy < this.EnergyCost.Value) { this.Life.Stimulate(this.Life.EnergyLowStimulus); return; } this.Life.Energy -= this.EnergyCost; Stimulus stimulus = null; long param = 0; if (args.Length > 0) { foreach (var obj in args) { if (obj is Stimulus) { stimulus = obj as Stimulus; } if (obj is double || obj is long || obj is int) { param += Convert.ToInt64(obj); } } } if (stimulus == null || args.Length <= 0) { for (var i = 0; i < Life.PrevioursReactions.Count; i++) { if (Life.World.Random.NextDouble() < ((double)(i + 1) / (double)Life.PrevioursReactions.Count) * 0.5 + 0.5) { stimulus = Life.PrevioursReactions[Life.PrevioursReactions.Count - i - 1].Stimulus; } } } if (stimulus == null) { return; } int count = (int)(1 - 0.3 / (Life.World.Random.NextDouble() - 1.05)); List <Behaviour> behaviors = new List <Behaviour>(); for (var i = 0; i < count; i++) { var behav = Life.BehaviourList.GetRandom(); if (behaviors.Contains(behav)) { continue; } behaviors.Add(behav); } Life.BuildReaction(stimulus, behaviors.ToArray()); }
public override void ReportFocusedOn(Stimulus stimulus, float after) { if (stimulus != activeStimulus) { Debug.LogError($"{stimulus} stimulus is not the active one, don't care if it reported focused!"); return; } measurement = after; Debug.Log($"{stimulus} reported focused after {after:0.000}s!"); }
public void Notice(GameEntity entity, Stimulus stimulus, bool noticingEnemy) { HashSet <Guid> entitiesSeen = entity.vision.EntitiesNoticed; entitiesSeen.Add(entity.id.Id); entity.ReplaceVision(entity.vision.VisionRange, entity.vision.PerceptionRange, entitiesSeen); if (noticingEnemy && entity.hasAware) { entity.ReplaceAware(int.MaxValue); } }
void OnTriggerExit2D(Collider2D col) { // only untrack the parent creature or dead segments Stimulus stim = col.GetComponent <Stimulus>(); Creature cr = col.GetComponent <Creature>(); Segment seg = col.GetComponent <Segment>(); if (stim && (cr || (seg && seg.creature == null))) { nearbyStimuli.Remove(stim); } }
void OnTriggerEnter2D(Collider2D col) { // only track the parent creature or dead segments Stimulus stim = col.GetComponent <Stimulus>(); Creature cr = col.GetComponent <Creature>(); Segment seg = col.GetComponent <Segment>(); if (stim && (cr || (seg && seg.creature == null)) && !nearbyStimuli.Contains(stim)) { nearbyStimuli.Add(stim); } }
public override void ReportStimulusDied(Stimulus active) { if (active != activeStimulus) { Debug.LogError($"{active} stimulus is not the active one, don't care if it died!"); return; } Debug.Log($"{activeStimulus} has finished"); Destroy(activeStimulus.gameObject); activeStimulus = null; owner.ReportTaskFinished(this, measurement); Destroy(gameObject); }
internal void SendStim(Stimulus s) { if (IsMathEnd()) { return; } foreach (Tank t in m_Tanks) { if (t.IsDead == false) { t.StimulusReceived(s); } } }
void StartNewStimulus() { currentStimulus = stimuli[currentStimulusIndex]; stimulusObject = molObjects [UnityEngine.Random.Range(0, molObjects.Count() - 1)]; stimulusObject.StartStimulus(currentStimulus.waveLength, currentStimulus.amplitude); currentStimulusIndex++; Animate = true; stimulus = true; print("Stimulus: " + currentStimulus); }
// called by external scripts // passed-in: what touched me, at what point did it hit me, what was the normal public void Stimulate(Stimulus stim, Vector3 pos, Vector3 normal) { if (stim.stimType == StimType.Arrow) // could potentially also check for magnitude but right now the arrow's default threshold for stim is good for player damage too { timesHit++; SpawnBloodPFX(pos, normal); if (TakeDamage(1)) { Debug.Log("*** PLAYER GOT KILT!! ***"); } } }
void StartNewStimulus() { Animate = true; Screen.showCursor = true; currentStimulus = stimuli[currentStimulusIndex]; var shuffle = (from mol in molObjects orderby Guid.NewGuid() select mol); molObjects = shuffle.ToArray(); print("Find molObject at position < " + Settings.Values.fovealLimit + " or > " + Settings.Values.periphLimit + " (visionArea=" + currentStimulus.visionArea + ")"); foreach (MolObject mol in molObjects) { if (currentStimulus.visionArea == 0) { if (Math.Abs(mol.transform.position.x) < Settings.Values.fovealLimit) { stimulusObject = mol; break; } } else { if (Math.Abs(mol.transform.position.x) > Settings.Values.periphLimit) { stimulusObject = mol; break; } } } foreach (MolObject mol in molObjects) { mol.StartStimulus(); } if (stimulusObject == null) { throw new System.Exception("Did not find scene element that matches the stimulus properties"); } //stimulusObject.StartStimulus(); print("Start stimulus, visionArea: " + currentStimulus.visionArea + " technique: " + currentStimulus.techID + " distance: " + stimulusObject.gameObject.transform.position.x); currentStimulusIndex++; }
public void OnTriggerExit(Collider other) { Stimulus stimulus = other.GetComponentInParent <Stimulus>(); if (!stimulus) { return; } if (_stimulusCoroutine != null) { StopCoroutine(_stimulusCoroutine); _stimulusCoroutine = null; } }
void OnTriggerEnter(Collider other) { Stimulus stimulus = other.GetComponent <Stimulus>(); if (stimulus != null) { Stimulus.origin currentOrigin = stimulus.GetCurrentOrigin(); //Check the aspect if (currentOrigin == desiredStimulusOrigin || currentOrigin == Stimulus.origin.Sneaking) { print("Touched " + desiredStimulusOrigin + "!"); patientTouched = true; } } }
// Use this for initialization protected void Start() { stimulus = GetComponent <Stimulus>(); segments = new Segment[max_height * 2 + 1, max_width *2 + 1]; placeable = new bool[max_height * 2 + 1, max_width *2 + 1]; //Create Core segments[max_height, max_width] = ((GameObject)Instantiate(core, this.transform.position + new Vector3(0, 0, 0), Quaternion.Euler(new Vector3(0, 0, 0)))).GetComponent <Segment>(); segments[max_height, max_width].Start(); segments [max_height, max_width].transform.parent = transform; segments [max_height, max_width].GetComponent <Segment> ().creature = this; segments [max_height, max_width].GetComponent <SpriteRenderer> ().color = color; RecalculatePlace(Vector2.zero); RecalculateNeighborPlaces(Vector2.zero); }
void LoadStimuli() { stimuli.Clear(); int count = 0; for (int ecc = 0; ecc < 2; ecc++) { for (int rep = 0; rep <= Settings.Values.repeat; rep++) { // TODO: either we have 4 techniques randomized, or one blocked // for(int tech = 0; tech < 4; tech++) // { int tech = -1; if (this.conditionID.CompareTo("AF") == 0) { tech = 0; } else if (this.conditionID.CompareTo("SL") == 0) { tech = 1; } else if (this.conditionID.CompareTo("T") == 0) { tech = 2; } else if (this.conditionID.CompareTo("H") == 0) { tech = 3; } else { Application.Quit(); } Stimulus stimulus = new Stimulus(count, ecc, rep, tech); stimuli.Add(stimulus); count++; // } } } var shuffle = (from stimulus in stimuli orderby Guid.NewGuid() select stimulus); stimuli = shuffle.ToList(); currentStimulusIndex = 0; }
public bool Stimulate(Stimulus incomingStim) { if (incomingStim.strength < strengthThreshold) { return(false); } switch (reaction) { case StimReactions.Break: BreakSelf(incomingStim); break; } return(true); }
private void filter(int id, Stimulus stim) { if (CommonFunctions.distance(AI_.Character_.getPosition(), stim.position_) < (double) stim.radius_) { if (stim.type_ == StimulusType.Position) { Belief b = new Belief(BeliefType.SuspiciousNoise, null, 100); b.position_ = stim.position_; AI_.Memory_.setBelief(b); } else if (stim.type_ == StimulusType.Message && stim.sourceAllegiance_ == AI_.Character_.Allegiance_ && stim.handle_ != AI_.Character_ && !idsHeardBefore.Contains(stim.message_.Id_)) { if (AI_.CommunicationSystem_.communicationLevel_ == SystemCommunication.CommunicationLevel.High && stim.message_.MessageType_ == Message.MessageType.Data) { CommLogger.addOutput("Heard " + stim.message_.ToString()); } idsHeardBefore.Add(stim.message_.Id_); bool isRedundant = false; AI_.CommunicationSystem_.IsListening_ = true; if (stim.message_.MessageType_ == Message.MessageType.Data) { isRedundant = AI_.Memory_.getAllBeliefs().Contains(stim.message_.Belief_); // For now, we believe messages that we receive with 100% certainty AI_.Memory_.setBelief(stim.message_.Belief_); } else if (stim.message_.MessageType_ == Message.MessageType.Hi) { // Someone has requested communication AI_.CommunicationSystem_.communicationRequested_ = true; } else if (stim.message_.MessageType_ == Message.MessageType.Bye) { // End of communication. // Now that I think of it, there's really no reason for a Bye. } if (AI_.CommunicationSystem_.communicationLevel_ == SystemCommunication.CommunicationLevel.High && stim.message_.MessageType_ == Message.MessageType.Data) { CommLogger.recvdMsg(isRedundant); } } } }
private bool ReadStimsRow(Dictionary <string, int> headerMap) { if (DataReader.Read()) { if (!DataReader.IsDBNull(headerMap["Protocol"])) { Protocol protocol = GetOrCreateProtocol(ReadStringAt(headerMap, "Protocol", false)); if (DataReader.IsDBNull(0)) { return(true); } Stimulus stim = new Stimulus(); stim.name = ReadStringAt(headerMap, "Stimulus", false); stim.sound_group = ReadStringAt(headerMap, "Sound Group", false); stim.stim_sound_pairing = ReadStringAt(headerMap, "Stim-Sound Pairing", false); stim.stim_sound_window = ReadStringAt(headerMap, "Stim-Sound Window", false); stim.stim_delivery = ReadStringAt(headerMap, "Intra-Window Stim Delivery", false); stim.num_paired_sounds = ReadUIntAt(headerMap, "Number of Paired Sounds", false); stim.stims_per_sound = ReadUIntAt(headerMap, "Stim Repetitions Per Window", false); stim.dur_min = ReadUIntAt(headerMap, "Stim Min Duration (ms)", false); stim.dur_max = ReadUIntAt(headerMap, "Stim Max Duration (ms)", false); stim.interval_min = ReadUIntAt(headerMap, "Time Between Stims Min", true); stim.interval_max = ReadUIntAt(headerMap, "Time Between Stims Max", true); stim.delay_min = ReadIntAt(headerMap, "Stimulus Delay Min (ms)", true); stim.delay_max = ReadIntAt(headerMap, "Stimulus Delay Max (ms)", true); stim.log_mode = ReadStringAt(headerMap, "Log", false); stim.sound = protocol.Sounds.Find(a => a.name == stim.sound_group); if (stim.sound == null) { throw new Exception($"Stimulus \"{stim.name}\" requires sound \"{stim.sound}\", but that sound is not included in the experiment."); } stim.sound.stimuli.Add(stim); protocol.Stimuli.Add(stim); } return(true); } else { return(false); } }
public void Unnotice(GameEntity entity, Stimulus stimulus) { GameEntity unnoticedEntity = Contexts.sharedInstance.game.GetEntityWithId(stimulus.ObjectEntityId); if (!_friendshipResolver.AreFriends(entity, unnoticedEntity)) { if (entity.hasAware) { entity.aware.TurnsLeft = 8; } } /* todo: how to handle situation like below? * 1. an enemy is noticed * 2. he dies and is removed from the context * 3. next time current actor checks the entities in FOV, the enemy is not detected, so we unnotice him * 4. _friendshipResolver doesn't know if unnoticed entity was enemy or not*/ }
protected override void Initialize() { self = GetComponent <Humanoid>(); allSceneObjects = FindObjectsOfType <GameObject>(); foreach (GameObject o in allSceneObjects) { Humanoid testHumanoid = o.GetComponent <Humanoid>(); if (testHumanoid != null && testHumanoid != self) { Stimulus test_S = o.GetComponent <Stimulus>(); if (test_S.GetCurrentOrigin() == targetOriginType) { humanoids.Add(testHumanoid); } } } targetSeen = false; }
IEnumerator UseStimulus(Stimulus stimulus) { float wait = stimulus.ChargeTime; while (wait > 0) { wait -= Time.deltaTime; yield return(null); } _stimulusCoroutine = null; _usedStimulus.Add(stimulus.StimulusId); //TODO: jāpievieno īpašības Genetics.Add(GameLogic.GameSetup.GetGenetic(stimulus.RandomGenetic())); Params.AddGenetic(Genetics); RecalculateGenetic(); }
private void AssertQueryIterationProtocol(IQuery query, MsgD expectedResultMessage , Stimulus[] stimuli) { var messages = MessageCollector.ForServerDispatcher(ServerDispatcher()); var result = query.Execute(); AssertMessages(messages, new IMessage[] {expectedResultMessage}); messages.Clear(); for (var stimulusIndex = 0; stimulusIndex < stimuli.Length; ++stimulusIndex) { var stimulus = stimuli[stimulusIndex]; stimulus.ActUpon(result); AssertMessages(messages, stimulus.expectedMessagesAfter); messages.Clear(); } if (result.HasNext()) { Assert.Fail("Unexpected item: " + ((Item) result.Next ())); } AssertMessages(messages, new IMessage[] {}); }
// Returns the map address book for the respective stimulus type public List<ItemStimulusValuePair> AddressBook(Stimulus bookType) { return _addressBook[(byte)bookType]; }