示例#1
0
        private void SetAllStatesForShips(LabelledDCNode ship, int length)
        {
            double possiblePosForRow = Settings.boardWidth - length + 1;
            // Finds all possible positions on the board for the ship
            double numberOfStates = Settings.boardWidth * possiblePosForRow * Settings.dimension;
            ulong  count          = 0;

            ship.SetNumberOfStates((ulong)numberOfStates);
            // Sets state labels and creates table for all states of the ship
            // Runs through the two orientations; horizontal and vertical
            for (int orientation = 0; orientation < Settings.dimension; orientation++)
            {
                for (int i = 0; i < (orientation == 0 ? Settings.boardWidth : possiblePosForRow); i++)
                {
                    for (int j = 0; j < (orientation == 1 ? Settings.boardWidth : possiblePosForRow); j++)
                    {
                        ship.SetStateLabel(count, (orientation == 1 ? "H" : "V") + $"_{i}{j}");
                        ship.GetTable().SetDataItem(count++, 1 / numberOfStates);
                    }
                }
            }
        }