using System.Collections.Generic; using UnityEngine; public class UltimateBotAI : IBotAI { private List knownDeckCoords = new List(); private bool initialized = false; public Vector2Int MakeMove(GamePole pole) { if (!initialized) { InitializeCheatKnowledge(pole); initialized = true; } int totalEnemyShips = 10; int remainingEnemyShips = pole.gameManager.enemyShips; int shipsLost = totalEnemyShips - remainingEnemyShips; float missChance = Mathf.Clamp01(0.9f - shipsLost * 0.1f); bool shouldMiss = Random.value < missChance; if (shouldMiss) { List<(int x, int y)> emptyShots = pole.GetAvailableShots(); if (emptyShots.Count > 0) { var missShot = emptyShots[Random.Range(0, emptyShots.Count)]; return new Vector2Int(missShot.x, missShot.y); } } else { foreach (Vector2Int coord in knownDeckCoords) { if (pole.PoleShot[coord.x, coord.y] == 0) { return coord; } } } return new Vector2Int(-1, -1); // Ходов нет } private void InitializeCheatKnowledge(GamePole pole) { knownDeckCoords.Clear(); foreach (var shipObj in pole.GetPlacedShips()) { var ship = shipObj.GetComponent(); if (ship == null) continue; foreach (Vector2Int coord in ship.deckCoords) { knownDeckCoords.Add(coord); } } } }