// Start is called before the first frame update void Start() { myOrder = FindOrder.FoodOrder(); OrderFinished = false; myTargetPos = FindCostumerSpot.FindSpot(); SeatTaken = FindCostumerSpot.Spot; Pos = transform.position; int tempCos = Random.Range(0, costumers.Length); GetComponent <Image>().sprite = costumers[tempCos]; }
/// <summary> /// The quantum estimation calls the quantum algorithm in the Q# file which computes the permutation /// πⁱ(input) where i is a superposition of all values from 0 to 7. The algorithm then uses QFT to /// find a period in the resulting state. The result needs to be post-processed to find the estimate. /// <summary> private int GuessOrderQuantumOne(int index) { var result = FindOrder.Run(_sim, new QArray <long>(_p.ConvertAll(x => (long)x)), (long)index).Result; if (result == 0) { var guess = _rnd.NextDouble(); // the probability distribution is extracted from the second // column (m = 0) in Fig. 2's table on the right-hand side, // in the original and referenced paper. if (guess <= 0.5505) { return(1); } else if (guess <= 0.5505 + 0.1009) { return(2); } else if (guess <= 0.5505 + 0.1009 + 0.1468) { return(3); } else { return(4); } } else if (result % 2 == 1) { return(3); } else if (result == 2 || result == 6) { return(4); } else /* result == 4 */ { return(2); } }
// Update is called once per frame private void Update() { Pos = myPosition.transform.position; float MoveSpeed = speed * Time.deltaTime; if (Pos != myTargetPos) { transform.position = Vector2.MoveTowards(transform.position, myTargetPos, MoveSpeed); } else if (Pos == myTargetPos && OrderDone == false) { FoodIWant = FindOrder.FoodOrdered(); Instantiate(FoodIWant, myFoodPosition.transform); OrderDone = true; transform.position = new Vector2(myTargetPos.x, myTargetPos.y + 0.1f); } if (PersonExiting.foodGotten == true) { FindCostumerSpot.AvailableSpots[SeatTaken] = 0; transform.position = Vector2.MoveTowards(transform.position, PersonExiting.Exit, MoveSpeed); } }
private static T GetItemAt <T>(T[] items, int index, FindOrder findOrder) => items[findOrder == FindOrder.Ascending ? index : items.Length - index - 1];