Ядро адаптировано под любой размер поля
This commit is contained in:
parent
2d01e5b2b9
commit
88493e2236
@ -11349,7 +11349,7 @@ Material:
|
||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||
- _EnvMatrixRotation: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _GlowColor: {r: 0.47417736, g: 0, b: 1, a: 1}
|
||||
- _GlowColor: {r: 0.6417732, g: 0, b: 1, a: 1}
|
||||
- _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767}
|
||||
- _OutlineColor: {r: 0.554717, g: 0.554717, b: 0.554717, a: 1}
|
||||
- _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
|
||||
@ -6005,10 +6005,13 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 0427b50b8b84b5641a0188046aaee227, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Rows: 7
|
||||
Cols: 7
|
||||
dummyBots: 0
|
||||
botsAmount: 5
|
||||
dummyPreset: {fileID: 11400000, guid: 35ba7f84d7557e8479f7f086269256f6, type: 2}
|
||||
MistressPreset: {fileID: 11400000, guid: 9aec48759dff81140a8ede5cbefe07d5, type: 2}
|
||||
boardVersion: 1
|
||||
stateMachine: {fileID: 259182281}
|
||||
slotLeftTop: {fileID: 687989434}
|
||||
AdminPanel: {fileID: 581100730}
|
||||
|
||||
@ -60,9 +60,9 @@ public class ClearFieldState : IState
|
||||
|
||||
private void Explode()
|
||||
{
|
||||
for (int i = 0; i < FIELD_HEIGHT; i++)
|
||||
for (int i = 0; i < GameManager.instance.Rows; i++)
|
||||
{
|
||||
for (int j = 0; j < FIELD_WIDTH; j++)
|
||||
for (int j = 0; j < GameManager.instance.Cols; j++)
|
||||
{
|
||||
Transform chipTransform = field[i, j];
|
||||
if (chipTransform != null)
|
||||
@ -85,8 +85,8 @@ public class ClearFieldState : IState
|
||||
{
|
||||
Object.Destroy(GameManager.instance.currentChip);
|
||||
}
|
||||
GameManager.fieldModel.makeEmptyField(width: FIELD_WIDTH, height: FIELD_HEIGHT);
|
||||
GameManager.instance.chipTransforms = new Transform[FIELD_HEIGHT, FIELD_WIDTH];
|
||||
GameManager.fieldModel.makeEmptyField(width: GameManager.instance.Cols, height: GameManager.instance.Rows);
|
||||
GameManager.instance.chipTransforms = new Transform[GameManager.instance.Rows, GameManager.instance.Cols];
|
||||
}
|
||||
|
||||
public void update(){ }
|
||||
|
||||
@ -196,7 +196,7 @@ public class PositioningState : IState
|
||||
void CollectValidPositions()
|
||||
{
|
||||
validPositions = new List<int>();
|
||||
for (int i = 0; i < 7; i++)
|
||||
for (int i = 0; i < gm.Cols; i++)
|
||||
{
|
||||
if (GameManager.fieldModel.getHeight(i) != -1)
|
||||
{
|
||||
|
||||
@ -324,6 +324,7 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
#region MAIN
|
||||
|
||||
public int Rows = 6, Cols = 7;
|
||||
public PlayerStatsService StatsService;
|
||||
public bool dummyBots = false;
|
||||
public int botsAmount = 5;
|
||||
@ -443,8 +444,8 @@ public class GameManager : MonoBehaviour
|
||||
Application.targetFrameRate = 60;
|
||||
|
||||
instance = this;
|
||||
fieldModel = new FieldModel(7, 6);
|
||||
chipTransforms = new Transform[6, 7];
|
||||
fieldModel = new FieldModel(Cols, Rows);
|
||||
chipTransforms = new Transform[Rows, Cols];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -32,22 +32,22 @@ public class In : MonoBehaviour
|
||||
/// </remarks>
|
||||
public void Initialize()
|
||||
{
|
||||
/* source = inputType switch
|
||||
{
|
||||
InputSourceType.Keyboard => new KeyboardInput(),
|
||||
InputSourceType.COM => new COMinput(),
|
||||
_ => throw new System.NotImplementedException()
|
||||
};*/
|
||||
/* source = inputType switch
|
||||
{
|
||||
InputSourceType.Keyboard => new KeyboardInput(),
|
||||
InputSourceType.COM => new COMinput(),
|
||||
_ => throw new System.NotImplementedException()
|
||||
};*/
|
||||
|
||||
|
||||
//ТЕСТЫ
|
||||
//#if UNITY_EDITOR
|
||||
// source = new KeyboardInput();
|
||||
//#else
|
||||
// source = new COMinput();
|
||||
//#endif
|
||||
|
||||
#if UNITY_EDITOR
|
||||
source = new KeyboardInput();
|
||||
#else
|
||||
source = new COMinput();
|
||||
#endif
|
||||
|
||||
//source = new COMinput();
|
||||
|
||||
|
||||
var success = source.Initialize();
|
||||
|
||||
@ -7,8 +7,8 @@ using UnityEngine;
|
||||
public class Solver
|
||||
{
|
||||
// -------- Параметры/пресет --------
|
||||
private const int ROWS = 6;
|
||||
private const int COLS = 7;
|
||||
private static int ROWS = 6;
|
||||
private static int COLS = 7;
|
||||
|
||||
private static readonly int[] MoveOrder = new[] { 3, 4, 2, 5, 1, 6, 0 }; // центр → края
|
||||
private static readonly int[] CenterWeights = new[] { 3, 4, 5, 7, 5, 4, 3 }; // «полуцентр» тоже ценим
|
||||
@ -60,6 +60,9 @@ public class Solver
|
||||
// -------- Публичный API --------
|
||||
public static int FindBestMove(CellState[,] board, CellState currentPlayer)
|
||||
{
|
||||
ROWS = board.GetLength(0);
|
||||
COLS = board.GetLength(1);
|
||||
|
||||
// сохраняем, за кого сейчас считаем
|
||||
BotPiece = currentPlayer;
|
||||
HumanPiece = (currentPlayer == CellState.Player1) ? CellState.Player2 : CellState.Player1;
|
||||
@ -326,7 +329,7 @@ public class Solver
|
||||
// -------- Хелперы по ходам/победам --------
|
||||
private static List<int> GetValidLocations(CellState[,] board)
|
||||
{
|
||||
var res = new List<int>(7);
|
||||
var res = new List<int>(COLS);
|
||||
for (int c = 0; c < COLS; c++)
|
||||
if (board[0, c] == CellState.Empty)
|
||||
res.Add(c);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user