public void streight_handCards_3() { var set = new Straight(); var cards = new List <Card> { new Card(Suit.Clubs, Rank.Six), new Card(Suit.Diamonds, Rank.Two), new Card(Suit.Spades, Rank.Three), new Card(Suit.Hearts, Rank.Five), new Card(Suit.Spades, Rank.Four), new Card(Suit.Spades, Rank.Queen), new Card(Suit.Clubs, Rank.Seven) }; set.SetCards(cards); var result = set.IsPresent(); var handCards = set.HandCards.OrderBy(x => x.Rank.Score).ToList(); Assert.True(result); handCards[0].AssertRank(Rank.Three); handCards[1].AssertRank(Rank.Four); handCards[2].AssertRank(Rank.Five); handCards[3].AssertRank(Rank.Six); handCards[4].AssertRank(Rank.Seven); }
public void TestStraightDerivedValues() { Straight straight = new Straight(previous, 5f, 1f); straight.EndPoint = new Vector2(20, 0); Assert.AreEqual(20f, straight.Length, 1E-10); }
protected override IEnumerator Fire() { yield return(new WaitForSeconds(attackRate)); while (true) { animationController.PlayAttackAnimation(); yield return(new WaitForSeconds(0.9f));//変数置いてやる必要があるかも for (var i = 0; i < burstCount; i++) { Straight straight = new Straight(); straight.Velocity = 5f; // 仮の値 straight.AttackPoint = 10; //仮の値 Vector3 position = transform.position; Vector3 dir = (playerTf.position - position).normalized; //straight.Direction = -transform.forward; // 前方向 straight.Direction = dir; // プレイヤーの方向 GameObject enemyBullet = BulletPool.Instance.GetInstance(straight); enemyBullet.GetComponent <BulletObject>().Force = Force.Enemy; enemyBullet.transform.position = position; GameObject effect = enemyBullet.transform.GetChild(0).gameObject; effect.GetComponent <Renderer>().material.SetColor(EmissionColor, straightColor); yield return(new WaitForSeconds(burstTime)); } // クールダウン yield return(new WaitForSeconds(attackRate)); } }
void sendRay() { Vector3 mousePos = Input.mousePosition; mousePos.z = 20f; Vector3 mousePos3D = Camera.main.ScreenToWorldPoint(mousePos); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Debug.DrawRay(ray.origin, ray.direction * 100, Color.green, 5, false); if (Physics.Raycast(Camera.main.transform.position, (mousePos3D - Camera.main.transform.position), out hit, 100f)) { //Debug.Log(hit.collider.gameObject.name); //Debug.Log("衝突位置 : "+hit.point); //ここでストレートを打つ //hit.collider.gameObjectでぶつかったオブジェクトのことを指す Vector3 array = (hit.point - Camera.main.transform.position).normalized; Straight straight = new Straight(); straight.Velocity = 10f; // 仮の値 straight.AttackPoint = 1; // 仮の値 straight.Direction = array; GameObject bullet = bulletPool.GetInstance(straight); bullet.transform.position = this.transform.position; GameObject effect = bullet.transform.GetChild(0).gameObject; effect.GetComponent <Renderer>().material.SetColor("_EmissionColor", _straightColor); bullet.GetComponent <BulletObject>().Force = Force.Player; } }
protected void Shift(IScrollComponent <TData> component, Vector2 delta) { //! temporal - item height limit speed //delta = delta.magnitude > ScrollerExtensions.SCROLL_SPEED_LIMIT_F ? delta.normalized * ScrollerExtensions.SCROLL_SPEED_LIMIT_F : delta; var direction = new Straight { Direction = GrowDirection }; VectorGeneric2 intersection; if (!component.RectTransform.GetIntersectionInLocalSpace(direction, out intersection)) { return; } if (Vector2.Dot(delta, GrowDirection) > 0) { var first = component.VisibleWindow.First; if (first != null && !first.RectTransform.IsInsideParentSpace(intersection.Origin) && component.RectTransform.IsOverlapsChild(first.RectTransform)) { component.ShiftWindowUp(); } } if (Vector2.Dot(delta, GrowDirection) < 0) { var last = component.VisibleWindow.Last; if (last != null && !last.RectTransform.IsInsideParentSpace(intersection.Target) && component.RectTransform.IsOverlapsChild(last.RectTransform)) { component.ShiftWindowDown(); } } }
public void HandIsStraightAceHigh() { //Arrange List <Card> cards = new List <Card>() { new Card(Suits.Clubes, "J"), new Card(Suits.Hearts, 9), new Card(Suits.Dimensions, "Q"), new Card(Suits.Dimensions, "T"), new Card(Suits.Clubes, "A"), new Card(Suits.Clubes, "K"), new Card(Suits.Hearts, "K") }; //Act Straight h = new Straight(); Hand straight = h.IsMatch(cards).Value; //Assert Assert.IsNotNull(straight); Assert.AreEqual(5, straight.CardsInTheHand.Count); Assert.AreEqual <int>(14, straight.CardsInTheHand[0].Value); Assert.AreEqual <int>(10, straight.CardsInTheHand[4].Value); Assert.AreEqual(Constancts.HandRanks.Straight, straight.Rank); }
private void AddBlock() { var key = new Random().Next(7); AbstractBlock b = new TBlock(0, 5); if (key == 1) { b = new SBlock(0, 5); } if (key == 2) { b = new ZBlock(0, 5); } if (key == 3) { b = new LBlock(0, 5); } if (key == 4) { b = new JBlock(0, 5); } if (key == 5) { b = new Square(0, 5); } if (key == 6) { b = new Straight(0, 5); } blockQueue.Enqueue(b); }
private bool IsAllInside(out VectorGeneric2 lastItemIntersection, bool oppositeDirection) { var cutting = new Straight { Direction = GrowDirection, }; var result = true; var intersection = new VectorGeneric2(); var current = _window.Count > 0 ? oppositeDirection ? _window.Last : _window.First : null; while (!ReferenceEquals(null, current)) { current.Value.RectTransform.GetIntersectionInParentSpace(cutting, out intersection); result = result && RectTransform.IsInsideLocalSpace(intersection.Origin) || RectTransform.IsInsideLocalSpace(intersection.Target); DebugWindow(current.Value); current = oppositeDirection ? current.Previous : current.Next; } lastItemIntersection = intersection; return(result); }
public void Test_Straight_CreateInstance(string strCards, bool isValid) { var cards = Utils.ParseCards(strCards); var straight = Straight.CreateInstance(cards); CreateInstanceHelper(straight, HandRanks.Straight, cards, isValid); }
public FreeCarrier(IScrollController <TData> controller) { var delta = controller.PointerEventData.delta.ProjectTo(controller.GrowDirection); //! temporal - item height limit speed _delta = delta.magnitude > ScrollerExtensions.SCROLL_SPEED_LIMIT_F ? delta.normalized * ScrollerExtensions.SCROLL_SPEED_LIMIT_F : delta; var cutting = new Straight { Direction = _delta.normalized, }; _isAtTarget = !controller.RectTransform.GetIntersectionInLocalSpace(cutting, out _target); var item = controller.FirstOrDefault(_ => _.RectTransform.IsInsideParentSpace(_target.Origin)) ?? (Vector2.Dot(_delta, controller.GrowDirection) > 0 ? controller.First() : controller.Last()); VectorGeneric2 @internal; item.RectTransform.GetIntersectionInParentSpace(cutting, out @internal); _necessaryDist = (_target.Origin - @internal.Origin).magnitude; _acceleration = -_delta.normalized * (_necessaryDist / (STOP_TIME_F * STOP_TIME_F) + _delta.magnitude / STOP_TIME_F); //ScrollerExtensions.MultiLine(controller.RectTransform.GetSidesInLocalSpace(), Color.yellow * .5f, true, 1f); //ScrollerExtensions.Cross(_target.Origin, Color.yellow, 30f, 1f); //ScrollerExtensions.Cross(@internal.Origin, Color.yellow, 30f, 1f); //Debug.Log(string.Format("speed: {0}, acceleration: {1}, distance is: {2}", _delta, _acceleration, _necessuaryDist)); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { _bullet = BulletPool.GetInstance(new Homing()); Homing homing = _bullet.GetComponent <BulletObject>().bulletclass as Homing; homing.Velocity = 6f; homing.HomingStrength = 1f; homing.Target = GameObject.Find("Target"); homing.AttackPoint = 10; homing.Direction = new Vector3(0, 0, 1); particleColor = _homingColor; Generate(); } else if (Input.GetKeyDown(KeyCode.LeftShift)) { _bullet = BulletPool.GetInstance(new Straight()); Straight straight = _bullet.GetComponent <BulletObject>().bulletclass as Straight; straight.Velocity = 12f + Random.Range(-4f, 4f); straight.AttackPoint = 10; straight.Direction = Vector3.Normalize(GameObject.Find("Target").transform.position - this.transform.position); particleColor = _straightColor; Generate(); } }
public void test_scores() { var highCard = new HighCard(); Assert.AreEqual(0, highCard.Score); var onePair = new OnePair(); Assert.AreEqual(1, onePair.Score); var twoPairs = new TwoPairs(); Assert.AreEqual(2, twoPairs.Score); var set = new Set(); Assert.AreEqual(3, set.Score); var straight = new Straight(); Assert.AreEqual(4, straight.Score); var flush = new Flush(); Assert.AreEqual(5, flush.Score); var fullHouse = new FullHouse(); Assert.AreEqual(6, fullHouse.Score); var quads = new Quads(); Assert.AreEqual(7, quads.Score); var straightFlush = new StraightFlush(); Assert.AreEqual(8, straightFlush.Score); var royalFlush = new RoyalFlush(); Assert.AreEqual(9, royalFlush.Score); }
public Destacker(DestackerInfo info) : base(info) { destackerInfo = info; DrawTracks(); // Conveyor for stacking StraightInfo straightInfo = new StraightInfo { thickness = destackerInfo.thickness, speed = destackerInfo.speed, width = destackerInfo.width, height = destackerInfo.height, length = destackerInfo.length, }; stackConveyor = new Straight(straightInfo); stackConveyor.Color = Color.Violet; Add(stackConveyor); stackConveyor.Visible = false; stackConveyor.StartFixPoint.Dispose(); stackConveyor.EndFixPoint.Dispose(); stackConveyor.TransportSection.Route.Motor.Stop(); stackConveyor.LocalPosition = new Vector3(0, PalletHeight + 0.005f, 0); // Initialise as request ThisRouteStatus.Available = RouteStatuses.Request; }
protected override void PreEvaluate() { Straight.PreEvaluateStraight(ref bucketSpades, ref specialSpades); Straight.PreEvaluateStraight(ref bucketHearts, ref specialHearts); Straight.PreEvaluateStraight(ref bucketClubs, ref specialClubs); Straight.PreEvaluateStraight(ref bucketDiamonds, ref specialDiamonds); }
public bool Calculate(IPokerHand hand) { var straight = new Straight(hand); var flush = new Flush(hand); return(straight.IsHighRank && flush.IsHighRank); }
public void AceAsOne() { var hand1 = new Straight(); hand1.SetCards(Cards.New() .Ace(Suit.Clubs) .Two(Suit.Clubs) .Three(Suit.Diamonds) .Four(Suit.Diamonds) .Five(Suit.Hearts) .Nine(Suit.Spades) .Ten(Suit.Spades)); var hand2 = new Straight(); hand2.SetCards(Cards.New() .Two(Suit.Clubs) .Three(Suit.Diamonds) .Four(Suit.Diamonds) .Five(Suit.Hearts) .Six(Suit.Hearts) .Nine(Suit.Spades) .Jack(Suit.Spades)); Assert.IsTrue(hand1.IsPresent()); Assert.IsTrue(hand2.IsPresent()); Assert.Less(hand1, hand2); }
public void Nao_deve_ser_uma_jogada_valida(int[] mao) { //When var jogada = new Straight(mao); //Then Assert.False(jogada.EhValida()); }
public void TestStraightPreviousTrackSegmentChanged() { Straight straight = new Straight(previous, 5f, 1f); previous.TrySetEndDirection(v3); Assert.IsTrue(straight.EndPoint.Equals(v3, (float)1E-5)); previous.TrySetEndDirection(v1); //make sure the old value is restored for other tests }
public void ShouldSayIfStraight() { Hand theHand = new Hand("7H, 8D, 9H, 10S, JH"); Straight straight = new Straight(); var result = straight.IsTypeOf(theHand); Assert.That(result, Is.EqualTo(true)); }
public void GivenHandCardThenCheckIfStraight(string handCard, bool expectedResult) { var handCardFormatted = Common.ConvertCardStringToList(handCard); var isStraightFlush = new Straight().IsThisType(handCardFormatted); Assert.True(isStraightFlush == expectedResult); }
protected override object Solve(System.IO.StreamReader input) { int n = NextInt(); if (n == 0) { return(0); } elements = NextInts(n); List <Straight> list = new List <Straight>(); Array.Sort(elements); foreach (var e in elements) { Straight bestStraight = null; foreach (var straight in list) { if (straight.lastElement == e - 1) { if (bestStraight == null) { bestStraight = straight; } else { if (bestStraight.Length > straight.Length) { bestStraight = straight; } } } } if (bestStraight != null) { bestStraight.lastElement = e; bestStraight.Length++; } else { list.Add(new Straight() { Length = 1, lastElement = e }); } } int shortest = int.MaxValue; foreach (var stra in list) { if (stra.Length < shortest) { shortest = stra.Length; } } return(shortest); }
public bool IsTypeOf(Hand theHand) { var straight = new Straight(); var flush = new Flush(); var isStraight = straight.IsTypeOf(theHand); var isFlush = flush.IsTypeOf(theHand); return(isStraight && isFlush); }
protected override void PostEvaluate() { Straight.PostEvaluateStraight(ref results, ref bucketSpades, ref specialSpades); Straight.PostEvaluateStraight(ref results, ref bucketHearts, ref specialHearts); Straight.PostEvaluateStraight(ref results, ref bucketClubs, ref specialClubs); Straight.PostEvaluateStraight(ref results, ref specialDiamonds, ref specialDiamonds); results.Sort(); }
public void Test_Straigh_EqualityOperators(string strInputA, string strInputB, bool areEqual) { var cardsA = Utils.ParseCards(strInputA); var cardsB = Utils.ParseCards(strInputB); var straightOne = Straight.CreateInstance(cardsA); var straightTwo = Straight.CreateInstance(cardsB); EqualityOperatorsHelper(straightOne, straightTwo, areEqual); }
public void Test_Straigh_ComparableTests(string strInputA, string strInputB, int comp) { var cardsA = Utils.ParseCards(strInputA); var cardsB = Utils.ParseCards(strInputB); var straightOne = Straight.CreateInstance(cardsA); var straightTwo = Straight.CreateInstance(cardsB); ComparableTestsHelper(straightOne, straightTwo, comp); }
public ActionResult About(float firstX1, float firstY1, float firstX2, float firstY2, float secondX1, float secondY1, float secondX2, float secondY2) { CreateImageSoapClient createImageClient = new CreateImageSoapClient(); CalculatePointServiceReference.CalculatePointSoapClient calculatePointClient = new CalculatePointServiceReference.CalculatePointSoapClient(); Straight first = new Straight() { FirstPoint = new CreateImageServiceReference.Point() { X = firstX1, Y = firstY1 }, SecondPoint = new CreateImageServiceReference.Point() { X = firstX2, Y = firstY2 } }; Straight second = new Straight() { FirstPoint = new CreateImageServiceReference.Point() { X = secondX1, Y = secondY1 }, SecondPoint = new CreateImageServiceReference.Point() { X = secondX2, Y = secondY2 } }; CalculatePointServiceReference.Straight first2 = new CalculatePointServiceReference.Straight() { FirstPoint = new CalculatePointServiceReference.Point() { X = firstX1, Y = firstY1 }, SecondPoint = new CalculatePointServiceReference.Point() { X = firstX2, Y = firstY2 } }; CalculatePointServiceReference.Straight second2 = new CalculatePointServiceReference.Straight() { FirstPoint = new CalculatePointServiceReference.Point() { X = secondX1, Y = secondY1 }, SecondPoint = new CalculatePointServiceReference.Point() { X = secondX2, Y = secondY2 } }; var result = calculatePointClient.CalculateIntersection(first2, second2); ViewBag.Message = "Intersection point [" + result.X + ", " + result.Y + "]"; ViewBag.imageBytes = createImageClient.HelloWorld(first, second); return(View()); }
public void ShiftWindowDown() { // попадает ли хвост в диапазон и отправлен ли запрос if (!(_currentBindRequest is BindNextRequest) && _bindings.ContainsFromTail(_preBoundaryThreshold, _window.Last.Value.LinkedData)) { _currentBindRequest = new BindNextRequest(this); _currentBindRequest.Execute(); } var next = _bindings.Find(_window.Last.Value.LinkedData).Next; // while scrolling up (moving down) if (next == null) { var measureCutting = new Straight { Direction = GrowDirection }; VectorGeneric2 firstIntersection; VectorGeneric2 lastIntersection; VectorGeneric2 boundIntersection; _window.First.Value.RectTransform.GetIntersectionInParentSpace(measureCutting, out firstIntersection); _window.Last.Value.RectTransform.GetIntersectionInParentSpace(measureCutting, out lastIntersection); RectTransform.GetIntersectionInLocalSpace(measureCutting, out boundIntersection); if (boundIntersection.Direction.sqrMagnitude < (lastIntersection.Target - firstIntersection.Origin).sqrMagnitude) { CarrierFactory.SetBumperCoDirection(this); } else { CarrierFactory.SetBumperCounterDirection(this); } return; } _itemFactory.Put(_window.First.Value); _window.RemoveFirst(); var cutting = new Straight { Direction = GrowDirection, }; VectorGeneric2 intersection; var item = _itemFactory.Get(next.Value); // TODO: one record cause en error here _window.Last.Value.RectTransform.GetIntersectionInParentSpace(cutting, out intersection); _window.AddLast(item); item.RectTransform.anchoredPosition = intersection.Target; if (ReferenceEquals(item.LinkedData, _bindings.Last.Value)) { OnCoDirectionBoundReach(); } }
void Start() { _overheat = 0.75f; _reload = 0f; maxDistance = 40f; minDistance = 3f; _linerAngleToAngleConverter = new Straight(-30f, -45f, -2700f); _linerDistanceToAngleConverter = new Straight(35f, 37f, -3065f); _trajectory = FindObjectOfType <Trajectory>().GetComponent <Trajectory>(); _animationState = FindObjectOfType <PlayerController>().GetComponent <Animator>(); }
public static ushort EnCodeIConduction(IConduction conduction) { return(conduction switch { Sigmoind _ => 1, ReLU _ => 2, SoftReLU _ => 3, Straight _ => 4, SoftMax _ => 5, _ => throw new ArgumentException( nameof(conduction), $"this type of IConduction is not registered. {conduction}"), });
private void SetUpLines(Vector2 distancePoint, Vector2 direction, Vector2 startPoint, Vector2 endPoint, float width) { this.distancePoint = distancePoint; Vector2 normal = new Vector2(-direction.y, direction.x); maxY = new Straight(startPoint + width * normal, normal, endPoint + width * normal); minY = new Straight(startPoint - width * normal, normal, endPoint - width * normal); maxX = new Straight(endPoint + width * normal, direction, endPoint - width * normal); minX = new Straight(startPoint + width * normal, direction, startPoint - width * normal); }