Exemplo n.º 1
0
 public void Restart()
 {
     SignalMachine.Call(new RestartSignal());
 }
Exemplo n.º 2
0
 private void OnDestroy()
 {
     SignalMachine.RemoveListener <DeathSignal>(OnDeath);
     SignalMachine.RemoveListener <NewScoreSignal>(OnScoreChange);
     SignalMachine.RemoveListener <NewLeaderboardScoreSignal>(OnHighScore);
 }
Exemplo n.º 3
0
 private void Start()
 {
     SignalMachine.AddListener <DeathSignal>(OnDeath);
     SignalMachine.AddListener <NewScoreSignal>(OnScoreChange);
     SignalMachine.AddListener <NewLeaderboardScoreSignal>(OnHighScore);
 }
Exemplo n.º 4
0
        public void updateIndicators(long timeframeToLookBack, long timeframeToLookBackForIndicatorInit, IndicatorSelector indicatorSelector)
        {
            List <double[]> selectedPriceData = new List <double[]>();

            for (int i = priceData.Count - 1; i > 0; i--)
            {
                if (Convert.ToInt64(priceData[i][(int)PriceDataIndeces.Date]) > timestampNow - timeframeToLookBack)
                {
                    selectedPriceData.Insert(0, priceData[i]); //Todo: List direction correct?
                }
                else
                {
                    break;
                }
            }

            double[][] selectedPriceDataArray = selectedPriceData.ToArray();
            double     s;

            double[][] outcomeData = OutcomeGenerator.getOutcome(selectedPriceDataArray, outcomeTimeframe, out s);
            if (s < 0.6)
            {
                throw new Exception("s < o.6: " + s);
            }

            //bool[][] outcomeCodeData = OutcomeGenerator.getOutcomeCode(selectedPriceDataArray, outcomeData, outcomeCodePercent, out s);
            bool[][] outcomeCodeFirstData = OutcomeGenerator.getOutcomeCodeFirst(selectedPriceDataArray, outcomeTimeframe, outcomeCodePercent, out s);
            if (s < 0.6)
            {
                throw new Exception("s < o.6: " + s);
            }

            string[] indicatorIds;

            //This part can be skipped by caching todo: get from outside
            double hash = outcomeTimeframe + selectedPriceData[0].Sum() + selectedPriceData[selectedPriceData.Count - 1].Sum() + selectedPriceData[selectedPriceData.Count / 2].Sum();
            string optimalIndicatorsFileName = cachePath + "/" + "optimalIndicatorsIn_" + hash + "_" + selectedPriceData[selectedPriceData.Count - 1][(int)PriceDataIndeces.Date] + "_" + timeframeToLookBack + "_" + outcomeCodePercent + ".txt";

            if (cachePath != null && File.Exists(optimalIndicatorsFileName))
            {
                indicatorIds = File.ReadAllText(optimalIndicatorsFileName).Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                Logger.log("Loaded optimal indicators from file: " + optimalIndicatorsFileName);
            }
            else
            {
                //Shuffle okay indicators? todo:
                Logger.log("Generated optimal indicators");
                IndicatorOptimizer optimizer = new IndicatorOptimizer(selectedPriceDataArray, outcomeData, outcomeCodeFirstData, outcomeTimeframe, outcomeCodePercent, minPercentThreshold, learningIndicatorSteps);
                indicatorIds = optimizer.getOptimizedIndicators(okayIndicators, indicatorSelector, 8);

                File.WriteAllLines(optimalIndicatorsFileName, indicatorIds);
            }

            Logger.log("Selected indicators: ");
            List <LearningIndicator> lis = new List <LearningIndicator>();

            foreach (string str in indicatorIds)
            {
                Logger.log(str);

                WalkerIndicator ind = IndicatorGenerator.getIndicatorByString(str);
                if (ind.getName() != str)
                {
                    throw new Exception(str + "!=" + ind.getName());
                }

                lis.Add(new LearningIndicator(ind, selectedPriceDataArray, outcomeCodeFirstData, outcomeData, outcomeTimeframe, outcomeCodePercent, minPercentThreshold, learningIndicatorSteps, false));
            }

            SignalMachine sm = new AlternativeSignalMachine(lis.ToArray()); //Todo: make accessable copy?

            Logger.log("SM STATE: ##################" + Environment.NewLine + sm.getStateMessage());

            //Make them up to date
            List <double[]> selectedPriceDataForIndicatorInit = new List <double[]>();

            for (int i = priceData.Count - 1; i > 0; i--)
            {
                if (Convert.ToInt64(priceData[i][(int)PriceDataIndeces.Date]) > timestampNow - timeframeToLookBackForIndicatorInit)
                {
                    selectedPriceDataForIndicatorInit.Insert(0, priceData[i]); //Todo: List direction correct?
                }
                else
                {
                    break;
                }
            }

            foreach (double[] row in selectedPriceDataForIndicatorInit)
            {
                sm.pushPrice(row);
            }

            this.signalMachine = sm;
        }
Exemplo n.º 5
0
 private void OnDestroy()
 {
     SignalMachine.RemoveListener <NewBombCountSignal>(OnBombCount);
     SignalMachine.RemoveListener <NewScoreSignal>(OnScore);
 }
Exemplo n.º 6
0
 private void Awake()
 {
     content.SetActive(false);
     SignalMachine.AddListener <NewBombCountSignal>(OnBombCount);
     SignalMachine.AddListener <NewScoreSignal>(OnScore);
 }