getState() public method

public getState ( Coordinates coords ) : cellState
coords Coordinates
return cellState
        public Coordinates getHighest()
        {
            int maxValue = 0;
            int maxX     = 0;
            int maxY     = 0;

            for (int x = 0; x < this.map.Length; x++)
            {
                for (int y = 0; y < this.map[x].Length; y++)
                {
                    //if (cellStateMap.getState(x, y) != cellState.UNKNOWN && value > 0) {
                    //    continue;
                    // should never happen, if it does, there's a bug adding mis-adding probabiliy somewhere
                    //}

                    if (cellStateMap.getState(x, y) != cellState.UNKNOWN)
                    {
                        continue;
                    }

                    int value = this.getValue(x, y);

                    if (value > maxValue)
                    {
                        maxX     = x;
                        maxY     = y;
                        maxValue = value;
                    }
                }
            }

            return(new Coordinates(maxX, maxY));
        }
Esempio n. 2
0
        private Coordinates pickTarget() {
            ProbabilityMap targetMap;

            targetMap = placementMap + huntingMap;

            for (int x = 0; x < placementMap.map.Length; x++) {
                for (int y = 0; y < placementMap.map[x].Length; y++) {
                    if (cellStateMap.getState(x, y) != cellState.UNKNOWN) {
                        continue;
                    }

                    int value = targetMap.getValue(x, y);

                    if (value == 0) {
                        cellStateMap.setState(x, y, cellState.IMPOSSIBLE); // No chance of ship being here, remove from consideration for future passes
                        continue;
                    }

                    if (historyMap.average > 0) {
                        double variation = historyMap.getVariation(x, y);

                        if (variation < 1) {
                            continue;
                        }

                        // This spot has hit targets slightly more than average, let's factor that in
                        targetMap.setValue(x, y, (int)(value * variation));
                    }
                }
            }

            return targetMap.getHighest();// new Coordinates(maxX, maxY);
        }