Beispiel #1
0
        private void CalcNextShipState(int turnNumber, ShipState ss)
        {
            if (turnNumber == calcTurn)
            {
                ShipState putss = ShipState.getFromPool();
                putss.set(ss);
                all_combinations.Add(putss);
                return;
            }
            ShipState newss = ShipState.getFromPool();

            for (int thr = 0; thr <= divThrust; thr++)
            {
                for (int tur = 0; tur <= divTurn; tur++)
                {
                    newss.set(ss);
                    newss.move(thr * maxThrust / divThrust, tur * (2 * maxTurn) / divTurn - maxTurn);
                    CalcNextShipState(turnNumber + 1, newss);
                }
            }
            newss.putToPool();
        }
Beispiel #2
0
        private void CalcAllShipStates(int turnNumber, Node <ShipState> parentNode)
        {
            allNodesNumber++;

            for (int thr = 0; thr <= divThrust; thr++)
            {
                for (int tur = 0; tur <= divTurn; tur++)
                {
                    ShipState newss = ShipState.getFromPool();
                    newss.set(parentNode.value);
                    newss.move(thr * maxThrust / divThrust, tur * (2 * maxTurn) / divTurn - maxTurn);
                    Node <ShipState> newnode = new Node <ShipState>(newss, parentNode);
                    if (turnNumber + 1 == calcTurn)
                    {
                        allNodesNumber++;
                    }
                    else
                    {
                        CalcAllShipStates(turnNumber + 1, newnode);
                    }
                }
            }
        }