public void TestGetPitchAbove1() { Pitch E = new Pitch(PitchClasses.E, 3); IPitch above = E.GetPitchAbove(3); Assert.AreEqual(new Pitch(PitchClasses.G, 3), above); }
public void TestGetPitchBelow1() { Pitch E = new Pitch(PitchClasses.E, 3); IPitch below = E.GetPitchAbove(-2); Assert.AreEqual(new Pitch(PitchClasses.D, 3), below); }
public void TestGetPitchBelowOctave() { Pitch CSharp = new Pitch(PitchClasses.CSharp, 4); IPitch sameoctave = CSharp.GetPitchAbove(-1); IPitch octaveabove = CSharp.GetPitchAbove(-2); Assert.AreEqual(new Pitch(PitchClasses.C, 4), sameoctave); Assert.AreEqual(new Pitch(PitchClasses.B, 3), octaveabove); }
public void TestGetPitchAboveOctave() { Pitch ASharp = new Pitch(PitchClasses.ASharp, 4); IPitch sameoctave = ASharp.GetPitchAbove(1); IPitch octaveabove = ASharp.GetPitchAbove(2); Assert.AreEqual(new Pitch(PitchClasses.B, 4), sameoctave); Assert.AreEqual(new Pitch(PitchClasses.C, 5), octaveabove); }
public override bool Equals(object o) { if (o == null) { return(false); } IPitch p = o as IPitch; if (p == null) { return(false); } return(p.GetOctave() == this.GetOctave() && p.GetPitchClass().Equals(this.pitchClass)); }
public List <IPitch> getPitches(IPitch tonic, int numPitches) { List <IPitch> pitches = new List <IPitch>(); if (numPitches == 0) { return(pitches); } pitches.Add(tonic); for (int i = 0; i < prioritizedIntervals.Length && i + 1 < numPitches; i++) { pitches.Add(tonic.GetPitchAbove(prioritizedIntervals[i])); } pitches.Sort(); return(pitches); }
public int CompareTo(IPitch other) { return(GetHashCode() - other.GetHashCode()); }
public void SetPitchBehavior(IPitch value) { pitchBehavior = value; }
public List <IPitch> getPitches(IPitch tonic) { return(getPitches(tonic, prioritizedIntervals.Length)); }
public Pitcher() { pitchBehavior = new Fastball(); }
public Note(IPitch pitch) : this(pitch, 1) { }
public Note(IPitch pitch, double duration) { this.pitch = pitch; this.duration = duration; }
/// <summary> /// Decide the moving target while player's in the offense side. /// </summary> /// <param name="player">Represents the deciding player.</param> /// <returns>Represents the moving target.</returns> public virtual Coordinate OffenseSideDecide(IPlayer player) { var random = player.Match; if (player.Match.Status.IsNoBallHandler) { return(player.Match.Football.Current); } #region 持球人行动 if (player.Status.Hasball) { if (player.Status.DefenceStatus.DefenderDistancePow <= 1600) { var goal = (player.Side == Side.Home) ? player.Match.Pitch.AwayGoal : player.Match.Pitch.HomeGoal; return(Utility.GetPointWithRange(player, goal, Defines.Player.SHORT_MOVE_RANGE)); } int index = player.Match.RandomInt32(0, 2); IPitch pitch = player.Match.Pitch; Dictionary <Direction, Line> lines = (player.Side == Side.Home) ? pitch.AwayDestinations : pitch.HomeDestinations; Coordinate target = new Coordinate(); if (index == 0) { target = lines[Direction.Left].GetRandomPoint(random); } if (index == 1) { target = lines[Direction.Center].GetRandomPoint(random); } if (index == 2) { target = lines[Direction.Right].GetRandomPoint(random); } player.Rotate(target); var x = player.Current.X + Defines.Player.SHORT_MOVE_RANGE * Math.Cos(player.Status.Angle * Math.PI / 180); var y = player.Current.Y + Defines.Player.SHORT_MOVE_RANGE * Math.Sin(player.Status.Angle * Math.PI / 180); return(new Coordinate(x, y)); } #endregion const double lx_min = 0; const double rx_min = 8d / 8d * Defines.Pitch.MAX_WIDTH; const double lx_max = 3d / 8d * Defines.Pitch.MAX_WIDTH; const double rx_max = 12d / 8d * Defines.Pitch.MAX_WIDTH; const double uy_min = (-1d / 8d) * Defines.Pitch.MAX_HEIGHT; const double dy_min = 7d / 8d * Defines.Pitch.MAX_HEIGHT; const double uy_max = 1d / 8d * Defines.Pitch.MAX_HEIGHT; const double dy_max = (9d / 8d) * Defines.Pitch.MAX_HEIGHT; bool isHome = player.Side == Side.Home; double lxmin = isHome ? lx_min : Defines.Pitch.MAX_WIDTH - rx_max; double lxmax = isHome ? lx_max : Defines.Pitch.MAX_WIDTH - rx_min; double rxmin = isHome ? rx_min : Defines.Pitch.MAX_WIDTH - lx_max; double rxmax = isHome ? rx_max : Defines.Pitch.MAX_WIDTH - lx_min; double lux = lxmin + player.Match.Football.Current.X / Defines.Pitch.MAX_WIDTH * (lxmax - lxmin); double luy = uy_min + player.Match.Football.Current.Y / Defines.Pitch.MAX_HEIGHT * (uy_max - uy_min); double rdx = rxmin + player.Match.Football.Current.X / Defines.Pitch.MAX_WIDTH * (rxmax - rxmin); double rdy = dy_min + player.Match.Football.Current.Y / Defines.Pitch.MAX_HEIGHT * (dy_max - dy_min); double rx = lux + player.Status.Default.X / Defines.Pitch.MAX_WIDTH * (rdx - lux); double ry = luy + player.Status.Default.Y / Defines.Pitch.MAX_HEIGHT * (rdy - luy); const double midY = Defines.Pitch.MID_HEIGHT; int offsetX = 0; int offsetY = 0; if (player.Input.AsPosition == Position.Fullback) { offsetX = isHome ? 20 : -20; offsetY = player.Match.Football.Current.Y > midY ? 10 : -10; } else if (player.Input.AsPosition == Position.Midfielder) { offsetX = isHome ? 8 : -8; offsetY = player.Match.Football.Current.Y > midY ? 10 : -10; } double fact = 0; if (offsetX != 0) { fact = Math.Abs(player.Status.Default.Y - midY) / midY; if (offsetX != 0) { rx += offsetX * fact; } } if (offsetY != 0) { fact = Math.Abs(player.Status.Default.Y - player.Match.Football.Current.Y) / dy_max; if (0.4 <= fact) { ry += offsetY * fact; } } return(new Coordinate(rx, ry)); }
public void SetUpperBound(IPitch upperBound) { this.upperBound = upperBound; }
public void SetLowerBound(IPitch lowerBound) { this.lowerBound = lowerBound; }
public void AddPitch(IPitch pitch) { pitches.Add(pitch); }