private void SummonHare(Move move) { if (move.GetOffset().Legnth != 2) { return; } GameObject hareGo = Instantiate(prefab); hareGo.transform.parent = transform.parent; Hare hare = hareGo.GetComponent <Hare>(); hare.Initialize(owner, Board, prefab); hare.Summon(move.GetStart(Board)); }
static void Main() { Mammal obj1 = new Mammal(); obj1.MammalInfo(); Wolf obj2 = new Wolf(); obj2.InfoWolf(); Hare obj = new Hare(); obj.InfoHare(); Console.ReadKey(); }
static private Arena PrepareArenaHare(Perceptron perceptron) { var arena = new Arena(width, height); var hare = new Hare(arena); var lynx = new Lynx(arena); hare.Other = lynx; lynx.Other = hare; arena.AddAnimal(hare); arena.AddAnimal(lynx); hare.Perceptron = perceptron; return(arena); }
public Form1() { InitializeComponent(); // The objects for the tortise and hare are created/constructed Bob = new Hare(); Shelly = new Tortoise(); // The tracks that the animals run on are declared as children of the animal's picture box // This ensures that the animal moves using the co-ordinates on the track, and not the form pbHare.Parent = pbHareTrack; pbTortoise.Parent = pbTortoiseTrack; // Medium speed is set as default rbtnMedium.Checked = true; // The pause, reset and clear button are disabled when the program originally begins btnPause.Enabled = false; btnReset.Enabled = false; btnClear.Enabled = false; }
public EdgeSource(int[] attr_in, Hare.Geometry.Point PtZ0, Hare.Geometry.Point _PtZ, Vector[] _Tangents) { attr = attr_in; Tangent = _Tangents; Z_Norm = _PtZ - PtZ0; Z_Range = Z_Norm.Length(); Z_dot = Z_Range * Z_Range;//Hare_math.Dot(Z_Norm, Z_Norm); Z_Norm/= Z_Range; Z_Range_2 = Z_Range / 2; Z_mid = (PtZ0 + _PtZ) / 2; Vector Bisector = (Tangent[0] + Tangent[1])/2; Bisector.Normalize(); double BisectAngle = Math.Acos(Hare_math.Dot(Tangent[0], Bisector)); if (BisectAngle == 0) BisectAngle = 1E-12; v = new double[2] { Math.PI / (2 * BisectAngle), Math.PI / (Utilities.Numerics.PiX2 - 2 * BisectAngle) }; v_4pi = new double[2] { v[0] / (4 * Math.PI), v[1] / (4 * Math.PI) }; v_2pi = new double[2] { v[0] / (2 * Math.PI), v[1] / (2 * Math.PI) }; Normal[0] = Hare_math.Cross(_Tangents[0], Z_Norm); Normal[1] = Hare_math.Cross(_Tangents[1], Z_Norm*-1); if(Hare_math.Dot(Normal[0], Bisector) > 0) { Normal[0] *= -1; Normal[1] *= -1; } //////////////////////////// //VisCheck// Rhino.Geometry.Point3d pt = new Rhino.Geometry.Point3d(Z_mid.x, Z_mid.y, Z_mid.z); Rhino.RhinoDoc.ActiveDoc.Objects.AddLine(pt, pt + new Rhino.Geometry.Point3d(Normal[0].x, Normal[0].y, Normal[0].z)); Rhino.RhinoDoc.ActiveDoc.Objects.AddLine(pt, pt + new Rhino.Geometry.Point3d(Normal[1].x, Normal[1].y, Normal[1].z)); //Rhino.RhinoDoc.ActiveDoc.Objects.AddLine(pt, pt + new Rhino.Geometry.Point3d(Tangent[0].x, Tangent[0].y, Tangent[0].z)); //Rhino.RhinoDoc.ActiveDoc.Objects.AddLine(pt, pt + new Rhino.Geometry.Point3d(Tangent[1].x, Tangent[1].y, Tangent[1].z)); //////Rhino.RhinoDoc.ActiveDoc.Objects.AddPoint(new Rhino.Geometry.Point3d(Z_mid.x, Z_mid.y, Z_mid.z)); }
public override System.Numerics.Complex[] Reflection_Spectrum(int sample_frequency, int length, Hare.Geometry.Vector Normal, Hare.Geometry.Vector Dir, int threadid) { int a = (int)(Math.Abs(Hare.Geometry.Hare_math.Dot(Dir, Normal))*180/Math.PI / 18); System.Numerics.Complex[] Ref_trns = new System.Numerics.Complex[length]; for (int j = 0; j < length; j++) { double freq = j * (sample_frequency / 2) / length; Ref_trns[j] = new System.Numerics.Complex(Transfer_FunctionR[a].Interpolate(freq), Transfer_FunctionI[a].Interpolate(freq)); } return Ref_trns; }
public abstract void Scatter_VeryLate(ref OctaveRay Ray, ref Random rand, Hare.Geometry.Vector Normal, double Cos_Theta);
public override void Absorb(ref BroadRay Ray, out double cos_theta, Hare.Geometry.Vector Normal) { cos_theta = Hare.Geometry.Hare_math.Dot(Ray.direction, Normal); int index = 18 - (int)Math.Round(Math.Acos(Math.Abs(cos_theta)) / angle_incr); for (int oct = 0; oct < 8; oct++) Ray.Energy[oct] *= (1 - Ang_Coef_Oct[oct][index]); }
public abstract System.Numerics.Complex[] Reflection_Spectrum(int sample_frequency, int length, Hare.Geometry.Vector Normal, Hare.Geometry.Vector Dir, int threadid);
public abstract void Absorb(ref BroadRay Ray, out double cos_theta, Hare.Geometry.Vector Normal);
public override System.Numerics.Complex[] Reflection_Spectrum(int sample_frequency, int length, Hare.Geometry.Vector Normal, Hare.Geometry.Vector Dir, int threadid) { return Inf_Mat.Reflection_Spectrum(sample_frequency, length, Normal, Dir, threadid); }
static void Main(string[] args) { // Whether we should use the unsafe, Direct interface to MPI. // When false, use the normal MPI.NET interface. bool useDirectInterface = false; using (MPI.Environment env = new MPI.Environment(ref args)) { if (args.Length > 0 && args[0] == "/direct") { useDirectInterface = true; System.Console.WriteLine("Using direct MPI interface."); System.Console.WriteLine("Bzzt. Can't do that here. Goodbye."); return; } else { System.Console.WriteLine("Using MPI.NET interface."); } comm = MPI.Communicator.world; if (comm.Size != 2) { if (comm.Rank == 0) { System.Console.WriteLine("Only two processes allowed. Rerun with -np 2"); } return; } else { self = comm.Rank; other = (comm.Rank + 1) % 2; } System.Console.WriteLine(comm.Rank + ": " + MPI.Environment.ProcessorName); bwdata = new Data[nSamp]; testLatency(); testSyncTime(); comm.Broadcast(ref latency, 0); if (self == 0) { System.Console.WriteLine("Latency: {0:F9}", latency); System.Console.WriteLine("Sync Time: {0:F9}", synctime); System.Console.WriteLine("Now starting main loop"); } int i, j, n, nq; int inc = 1, len; int start = 0, end = 1024 * 1024 * 1024; int bufflen = start, bufalign = 16 * 1024; double tlast = latency; for (n = nq = 0, len = start; tlast < stopTime && len <= end; len += inc, nq++) { if (nq > 2 && (nq % 2 != 0)) { inc *= 2; } int ipert, pert; for (ipert = 0, pert = (inc > PERT + 1) ? -PERT : 0; pert <= PERT; ipert++, n++, pert += (inc > PERT + 1) ? PERT : PERT + 1) { int nRepeat = bufflen == 0 ? latencyReps : (int)Math.Max((RUNTM / ((double)bufflen / (bufflen - inc + 1.0) * tlast)), TRIALS); comm.Broadcast(ref nRepeat, 0); bufflen = len + pert; Hare[] sendBuffer = new Hare[bufflen]; // Align the data? Some day. Maybe. Hare[] recvBuffer = new Hare[bufflen]; if (self == 0) { System.Console.Write("{0,3:D}: {1,9:D} bytes {2,7:D} times ---> ", n, bufflen, nRepeat); } bwdata[n].t = 1e99; double t1 = 0, t2 = 0; for (i = 0; i < TRIALS; i++) { sync(); double t0 = when(); if (useDirectInterface) { } else { for (j = 0; j < nRepeat; j++) { if (self == 0) { comm.Send(sendBuffer, other, 142); comm.Receive(ref recvBuffer, other, 242); } else { comm.Receive(ref recvBuffer, other, 142); comm.Send(sendBuffer, other, 242); } } } double t = (when() - t0) / (2.0 * nRepeat); t2 += t * t; t1 += t; bwdata[n].t = Math.Min(bwdata[n].t, t); bwdata[n].variance = t2 / TRIALS - t1 / TRIALS * t1 / TRIALS; tlast = bwdata[n].t; bwdata[n].bits = bufflen * Marshal.SizeOf(typeof(Hare)) * 8; bwdata[n].bps = bwdata[n].bits / (bwdata[n].t * 1024 * 1024); bwdata[n].repeat = nRepeat; } if (self == 0) { System.Console.WriteLine("{0,9:F2} Mbps in {1:F9} sec", bwdata[n].bps, tlast); } } } } }
public double Rho_C(Hare.Geometry.Point pt) { return this.Env_Prop.Rho_C(pt); }
public double[] Attenuation(Hare.Geometry.Point pt) { return this.Env_Prop.Attenuation_Coef(pt); }
public double AttenuationPureTone(Hare.Geometry.Point pt, double frequency) { return this.Env_Prop.AttenuationPureTone(pt, frequency); }
public void AttenuationFilter(int no_of_elements, int sampleFrequency, double dist, ref double[] Freq, ref double[] Atten, Hare.Geometry.Point pt) { Env_Prop.AttenuationFilter(no_of_elements, sampleFrequency, dist, ref Freq, ref Atten, pt); }
public override void Scatter_VeryLate(ref OctaveRay Ray, ref Random rand, Hare.Geometry.Vector Normal, double Cos_Theta) { if (rand.NextDouble() < Scattering_Coefficient[Ray.Octave, 1]) { Hare.Geometry.Vector diffx; Hare.Geometry.Vector diffy; Hare.Geometry.Vector diffz; double proj; //Check that the ray and the normal are both on the same side... if (Cos_Theta > 0) Normal *= -1; diffz = Normal; diffx = new Hare.Geometry.Vector(0, 0, 1); proj = Math.Abs(Hare.Geometry.Hare_math.Dot(diffz, diffx)); if (0.99 < proj && 1.01 > proj) diffx = new Hare.Geometry.Vector(1, 0, 0); diffy = Hare.Geometry.Hare_math.Cross(diffz, diffx); diffx = Hare.Geometry.Hare_math.Cross(diffy, diffz); diffx.Normalize(); diffy.Normalize(); diffz.Normalize(); double u1; double u2; double x; double y; double z; Hare.Geometry.Vector vect; u1 = 2.0 * Math.PI * rand.NextDouble(); // random azimuth double Scat_Mod = rand.NextDouble(); u2 = Math.Acos(Scat_Mod); // random zenith (elevation) x = Math.Cos(u1) * Math.Sin(u2); y = Math.Sin(u1) * Math.Sin(u2); z = Math.Cos(u2); vect = (diffx * x) + (diffy * y) + (diffz * z); vect.Normalize(); //Return the new direction Ray.direction = vect; } else { //Specular Reflection Ray.direction -= Normal * Cos_Theta * 2; } }
public TortoiseVsHareSimulation(Tortoise tortoise, Hare hare, int raceTrackLength) { this.Tortoise = tortoise; this.Hare = hare; this.RaceTrackLength = raceTrackLength; }
public void GetSims(ref Hare.Geometry.Point[] Src, ref Hare.Geometry.Point[] Rec, ref Direct_Sound[] D, ref ImageSourceData[] IS, ref Receiver_Bank[] RT) { Src = new Hare.Geometry.Point[Source.Length]; for (int i = 0; i < Source.Length; i++) Src[i] = Source[i].H_Origin(); Rec = Recs; if (Direct_Data != null) D = Direct_Data; if (IS_Data != null) IS = IS_Data; if (Receiver != null) RT = Receiver; }
public override System.Numerics.Complex Reflection_Narrow(double frequency, Hare.Geometry.Vector Dir, Hare.Geometry.Vector Normal) { return Inf_Mat.Reflection_Narrow(frequency, Dir, Normal); }
public override System.Numerics.Complex[] Reflection_Spectrum(int sample_frequency, int length, Hare.Geometry.Vector Normal, Hare.Geometry.Vector Dir, int threadid) { System.Numerics.Complex[] Ref_trns = new System.Numerics.Complex[length]; for (int j = 0; j < length; j++) { Ref_trns[j] = new System.Numerics.Complex(Transfer_Function.Interpolate(j * (sample_frequency / 2) / length), 0); } return Ref_trns; }
public abstract void Absorb(ref BroadRay Ray, Hare.Geometry.Vector Normal);
public override void Absorb(ref OctaveRay Ray, Hare.Geometry.Vector Normal) { Ray.Intensity *= (Ref[Ray.Octave]); Ray.phase += PD[Ray.Octave]; }
public abstract System.Numerics.Complex Reflection_Narrow(double frequency, Hare.Geometry.Vector Dir, Hare.Geometry.Vector Normal);
public override void Absorb(ref OctaveRay Ray, out double cos_theta, Hare.Geometry.Vector Normal) { cos_theta = Hare.Geometry.Hare_math.Dot(Normal, Ray.direction); Ray.Intensity *= (Ref[Ray.Octave]); Ray.phase += PD[Ray.Octave]; }
public abstract void Scatter_Early(ref BroadRay Ray, ref Queue<OctaveRay> Rays, ref Random rand, Hare.Geometry.Vector Normal, double Cos_Theta);
public override void Absorb(ref BroadRay Ray, out double cos_theta, Hare.Geometry.Vector Normal) { cos_theta = Hare.Geometry.Hare_math.Dot(Normal, Ray.direction); Ray.Energy[0] *= (Ref[0]); Ray.phase[0] += PD[0]; Ray.Energy[1] *= (Ref[1]); Ray.phase[1] += PD[1]; Ray.Energy[2] *= (Ref[2]); Ray.phase[2] += PD[2]; Ray.Energy[3] *= (Ref[3]); Ray.phase[3] += PD[3]; Ray.Energy[4] *= (Ref[4]); Ray.phase[4] += PD[4]; Ray.Energy[5] *= (Ref[5]); Ray.phase[5] += PD[5]; Ray.Energy[6] *= (Ref[6]); Ray.phase[6] += PD[6]; Ray.Energy[7] *= (Ref[7]); Ray.phase[7] += PD[7]; }
public override void Absorb(ref OctaveRay Ray, out double cos_theta, Hare.Geometry.Vector Normal) { cos_theta = Hare.Geometry.Hare_math.Dot(Ray.direction, Normal); int index = 18 - (int)Math.Round(Math.Acos(Math.Abs(cos_theta)) / angle_incr); Ray.Intensity *= (1 - Ang_Coef_Oct[Ray.Octave][index]); }
public override void Absorb(ref BroadRay Ray, Hare.Geometry.Vector Normal) { Ray.Energy[0] *= (Ref[0]); Ray.phase[0] += PD[0]; Ray.Energy[1] *= (Ref[1]); Ray.phase[1] += PD[1]; Ray.Energy[2] *= (Ref[2]); Ray.phase[2] += PD[2]; Ray.Energy[3] *= (Ref[3]); Ray.phase[3] += PD[3]; Ray.Energy[4] *= (Ref[4]); Ray.phase[4] += PD[4]; Ray.Energy[5] *= (Ref[5]); Ray.phase[5] += PD[5]; Ray.Energy[6] *= (Ref[6]); Ray.phase[6] += PD[6]; Ray.Energy[7] *= (Ref[7]); Ray.phase[7] += PD[7]; }
public override System.Numerics.Complex Reflection_Narrow(double frequency, Hare.Geometry.Vector Dir, Hare.Geometry.Vector Normal) { int a = (int)(Math.Abs(Hare.Geometry.Hare_math.Dot(Dir, Normal))*180/Math.PI / 18); return new System.Numerics.Complex(Transfer_FunctionR[a].Interpolate(frequency), Transfer_FunctionI[a].Interpolate(frequency)); }
public override System.Numerics.Complex Reflection_Narrow(double frequency, Hare.Geometry.Vector Dir, Hare.Geometry.Vector Normal) { return new System.Numerics.Complex(Transfer_Function.Interpolate(frequency), 0); }
public override void Scatter_Early(ref BroadRay Ray, ref Queue<OctaveRay> Rays, ref Random rand, Hare.Geometry.Vector Normal, double Cos_Theta) { double roughness_chance = rand.NextDouble(); if (Cos_Theta > 0) { Normal *= -1; Cos_Theta *= -1; } foreach (int oct in Ray.Octaves) { // 3. Apply Scattering. //// a. Create new source for scattered energy (E * Scattering). //// b. Modify E (E * 1 - Scattering). OctaveRay R = Ray.SplitRay(oct, Scattering_Coefficient[oct, 1]); Hare.Geometry.Vector diffx; Hare.Geometry.Vector diffy; Hare.Geometry.Vector diffz; double proj; //Check that the ray and the normal are both on the same side... diffz = Normal; diffx = new Hare.Geometry.Vector(0, 0, 1); proj = Math.Abs(Hare.Geometry.Hare_math.Dot(diffz, diffx)); if (0.99 < proj && 1.01 > proj) diffx = new Hare.Geometry.Vector(1, 0, 0); diffy = Hare.Geometry.Hare_math.Cross(diffz, diffx); diffx = Hare.Geometry.Hare_math.Cross(diffy, diffz); diffx.Normalize(); diffy.Normalize(); diffz.Normalize(); double u1; double u2; double x; double y; double z; Hare.Geometry.Vector vect; u1 = 2.0 * Math.PI * rand.NextDouble(); // random azimuth double Scat_Mod = rand.NextDouble(); u2 = Math.Acos(Scat_Mod); // random zenith (elevation) x = Math.Cos(u1) * Math.Sin(u2); y = Math.Sin(u1) * Math.Sin(u2); z = Math.Cos(u2); vect = (diffx * x) + (diffy * y) + (diffz * z); vect.Normalize(); //Return the new direction R.direction = vect; if (R.t_sum == 0) { Rhino.RhinoApp.Write("Something's up!"); } Rays.Enqueue(R); } Ray.direction -= Normal * Cos_Theta * 2; }
public override void Absorb(ref BroadRay Ray, out double cos_theta, Hare.Geometry.Vector Normal) { Ray.direction.Normalize(); cos_theta = Math.Acos(Hare.Geometry.Hare_math.Dot(Ray.direction, new Hare.Geometry.Vector(0, 0, -1))); int Alt = (int)Math.Floor((cos_theta * Altitude.Length) / (Math.PI / 2)); if (Alt >= Altitude.Length / 2) Alt = Altitude.Length - 1; int Azi = (int)Math.Round((Math.Atan2(Ray.direction.y, Ray.direction.x) * Azimuth.Length) / Math.PI); if (Ray.direction.y < 0 && Azi < Azimuth.Length / 2) Azi = Azimuth.Length - Math.Abs(Azi); for (int oct = 0; oct < 8; oct++) Ray.Energy[oct] *= alpha[Alt][Azi][oct]; }
public override void Scatter_Late(ref OctaveRay Ray, ref Queue<OctaveRay> Rays, ref Random rand, Hare.Geometry.Vector Normal, double Cos_Theta) { double scat_sel = rand.NextDouble(); if (scat_sel > Scattering_Coefficient[Ray.Octave, 2]) { // Specular Reflection Ray.direction -= Normal * Cos_Theta * 2; return; } else if (scat_sel > Scattering_Coefficient[Ray.Octave, 0]) { //Only for a certain portion of high benefit cases-- //// a. Create new source for scattered energy (E * Scattering). //// b. Modify E (E * 1 - Scattering). //Create a new ray... OctaveRay tr = Ray.SplitRay(1 - Scattering_Coefficient[Ray.Octave,1]); // this is the specular reflection. Save it for later. tr.direction -= Normal * Cos_Theta * 2; if (tr.t_sum == 0) { Rhino.RhinoApp.Write("Something's up!"); } Rays.Enqueue(tr); } //If we are here, the original ray needs a scattered direction: Hare.Geometry.Vector diffx; Hare.Geometry.Vector diffy; Hare.Geometry.Vector diffz; double proj; //Check that the ray and the normal are both on the same side... if (Cos_Theta > 0) Normal *= -1; diffz = Normal; diffx = new Hare.Geometry.Vector(0, 0, 1); proj = Math.Abs(Hare.Geometry.Hare_math.Dot(diffz, diffx)); if (0.99 < proj && 1.01 > proj) diffx = new Hare.Geometry.Vector(1, 0, 0); diffy = Hare.Geometry.Hare_math.Cross(diffz, diffx); diffx = Hare.Geometry.Hare_math.Cross(diffy, diffz); diffx.Normalize(); diffy.Normalize(); diffz.Normalize(); double u1; double u2; double x; double y; double z; Hare.Geometry.Vector vect; u1 = 2.0 * Math.PI * rand.NextDouble(); // random azimuth double Scat_Mod = rand.NextDouble(); u2 = Math.Acos(Scat_Mod); // random zenith (elevation) x = Math.Cos(u1) * Math.Sin(u2); y = Math.Sin(u1) * Math.Sin(u2); z = Math.Cos(u2); vect = (diffx * x) + (diffy * y) + (diffz * z); vect.Normalize(); //Return the new direction Ray.direction = vect; }
public abstract void Absorb(ref OctaveRay Ray, Hare.Geometry.Vector Normal);
public override void Absorb(ref OctaveRay Ray, out double cos_theta, Hare.Geometry.Vector Normal) { Ray.direction.Normalize(); cos_theta = Math.Acos(Hare.Geometry.Hare_math.Dot(Ray.direction, new Hare.Geometry.Vector(0, 0, -1))); int Alt = (int)Math.Floor((cos_theta * Altitude.Length) / (Math.PI / 2)); if (Alt >= Altitude.Length / 2) Alt = Altitude.Length - 1; int Azi = (int)Math.Round((Math.Atan2(Ray.direction.y, Ray.direction.x) * Azimuth.Length) / Math.PI / 2); if (Ray.direction.y < 0 && Azi < Azimuth.Length / 2) Azi = Azimuth.Length - Math.Abs(Azi); if (Azi == Azimuth.Length) Azi = 0; Ray.Intensity *= alpha[Alt][Azi][Ray.Octave]; }
private void Start() { h = new Hare(); }