From 8d576c3af23753793d351a643a78ed5cc08a5f01 Mon Sep 17 00:00:00 2001 From: se_ga Date: Fri, 27 Feb 2026 17:56:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BB=D0=B0=D0=B4=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F=20=D0=B2=D0=B8=D1=82=D1=80?= =?UTF-8?q?=D0=B8=D0=BD=D1=8B,=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B2=20=D1=81=D0=BE=D0=BB=D0=B2=D0=B5=D1=80=D0=B0=D1=85,=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=B4=D0=BE=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Fonts/NEW/NexaRegular COOL.asset | 2 +- Assets/Scenes/GameScene3D.unity | 55 +--- Assets/Scenes/PrizeStandTest.unity | 266 ++++++++++++++++++ Assets/Scenes/PrizeStandTest.unity.meta | 7 + Assets/Scenes/StandTester.cs | 67 +++++ Assets/Scenes/StandTester.cs.meta | 11 + Assets/Scripts/CoinCounter.cs | 3 +- Assets/Scripts/GameFSM/BotThinkingState.cs | 4 +- Assets/Scripts/Inputs/ComSystem/ComWrapper.cs | 2 +- .../Scripts/DualAvatarController.cs | 4 +- .../PrizeStand/PrizeStandController.cs | 25 +- Assets/Scripts/SolverV2.cs | 40 ++- 12 files changed, 410 insertions(+), 76 deletions(-) create mode 100644 Assets/Scenes/PrizeStandTest.unity create mode 100644 Assets/Scenes/PrizeStandTest.unity.meta create mode 100644 Assets/Scenes/StandTester.cs create mode 100644 Assets/Scenes/StandTester.cs.meta diff --git a/Assets/Fonts/NEW/NexaRegular COOL.asset b/Assets/Fonts/NEW/NexaRegular COOL.asset index c0f85e5..88f3f66 100644 --- a/Assets/Fonts/NEW/NexaRegular COOL.asset +++ b/Assets/Fonts/NEW/NexaRegular COOL.asset @@ -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.6417732, g: 0, b: 1, a: 1} + - _GlowColor: {r: 0, g: 0.086306095, 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} diff --git a/Assets/Scenes/GameScene3D.unity b/Assets/Scenes/GameScene3D.unity index 006fc8e..d26d284 100644 --- a/Assets/Scenes/GameScene3D.unity +++ b/Assets/Scenes/GameScene3D.unity @@ -16607,7 +16607,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 687989434} - - component: {fileID: 687989435} m_Layer: 0 m_Name: TopLeftSlot m_TagString: Untagged @@ -16630,58 +16629,6 @@ Transform: m_Children: [] m_Father: {fileID: 2081516970} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &687989435 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 687989433} - m_Enabled: 0 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1.0227977, y: 1.0208} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 0 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 --- !u!1 &693385447 GameObject: m_ObjectHideFlags: 0 @@ -51551,7 +51498,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &1749880614 RectTransform: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/PrizeStandTest.unity b/Assets/Scenes/PrizeStandTest.unity new file mode 100644 index 0000000..675ee24 --- /dev/null +++ b/Assets/Scenes/PrizeStandTest.unity @@ -0,0 +1,266 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &600622028 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 600622030} + - component: {fileID: 600622029} + m_Layer: 0 + m_Name: scriptHolder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &600622029 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 600622028} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9bc9f2719db463041af996b2dfc020e8, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &600622030 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 600622028} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -35.211643, y: 0.5978498, z: -0.09944603} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &842588986 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 842588989} + - component: {fileID: 842588988} + - component: {fileID: 842588987} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &842588987 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 842588986} + m_Enabled: 1 +--- !u!20 &842588988 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 842588986} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &842588989 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 842588986} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 842588989} + - {fileID: 600622030} diff --git a/Assets/Scenes/PrizeStandTest.unity.meta b/Assets/Scenes/PrizeStandTest.unity.meta new file mode 100644 index 0000000..99ba6ec --- /dev/null +++ b/Assets/Scenes/PrizeStandTest.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7d8f8d0070f2bf745bc49b6b21a1885d +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/StandTester.cs b/Assets/Scenes/StandTester.cs new file mode 100644 index 0000000..e9f4b08 --- /dev/null +++ b/Assets/Scenes/StandTester.cs @@ -0,0 +1,67 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEditor.Experimental.GraphView; +using UnityEngine; + +public class StandTester : MonoBehaviour +{ + int h; + bool initialized = false; + void Start() + { + PrizeStandController.InitializationComplete += PrizeStandController_InitializationComplete; + PrizeStandController.OpeningFinished += PrizeStandController_OpeningFinished; + + + ComNativeWrapper.Serial_CloseAll(); + h = ComNativeWrapper.Serial_Open("COM3", 115200, 8, 0, 1, 4, 10); + Debug.Log(h); + PrizeStandController.Initialize(h, 5, null); + + } + + private void OnDisable() + { + ComNativeWrapper.Serial_CloseAll(); + } + + private void PrizeStandController_InitializationComplete(bool arg1, string arg2) + { + if (arg1) + { + initialized = true; + } + + Debug.Log($"Èíèöèàëèçàöèÿ. Result {arg1}; Message {arg2}"); + } + + private void PrizeStandController_OpeningFinished(bool arg1, string arg2) + { + Debug.Log($"Îòêðûòèå. Result {arg1}; Message {arg2}"); + } + + void Update() + { + if (!initialized) return; + if (Input.GetKeyDown(KeyCode.Alpha0)) + { + + } + if (Input.GetKeyDown(KeyCode.Alpha1)) + { + Debug.Log("=====Îòêðûòü 1====="); + _ = PrizeStandController.OpenBoxAsync(1); + } + if (Input.GetKeyDown(KeyCode.Alpha2)) + { + Debug.Log("=====Îòêðûòü 2====="); + _ = PrizeStandController.OpenBoxAsync(2); + } + if (Input.GetKeyDown(KeyCode.Alpha3)) + { + Debug.Log("=====Îòêðûòü 3====="); + _ = PrizeStandController.OpenBoxAsync(3); + } + + } +} diff --git a/Assets/Scenes/StandTester.cs.meta b/Assets/Scenes/StandTester.cs.meta new file mode 100644 index 0000000..6227b84 --- /dev/null +++ b/Assets/Scenes/StandTester.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9bc9f2719db463041af996b2dfc020e8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/CoinCounter.cs b/Assets/Scripts/CoinCounter.cs index a966374..df4ec63 100644 --- a/Assets/Scripts/CoinCounter.cs +++ b/Assets/Scripts/CoinCounter.cs @@ -36,7 +36,8 @@ public class CoinCounter : MonoBehaviour public void SetRevengePriceVisibility(bool visibility) { - revengeSignGo?.SetActive(visibility); + if(revengeSignGo != null) revengeSignGo.SetActive(visibility); + int priceRevenge = PlayerPrefs.GetInt("PriceRevenge", 10); int pricePve = PlayerPrefs.GetInt("PricePVE", 10); string valutaName = PlayerPrefs.GetString("ValutaName", "руб."); diff --git a/Assets/Scripts/GameFSM/BotThinkingState.cs b/Assets/Scripts/GameFSM/BotThinkingState.cs index 603594e..d0e9468 100644 --- a/Assets/Scripts/GameFSM/BotThinkingState.cs +++ b/Assets/Scripts/GameFSM/BotThinkingState.cs @@ -30,7 +30,7 @@ public class BotThinkingState : IState //Установка пресета сложности DifficultyPreset currentPreset = CharacterController.CurrentCharacter.CurrentDifficultyPreset; - Debug.Log(currentPreset.Description); + //Debug.Log(currentPreset.Description); if (GameManager.instance.dummyBots) currentPreset = GameManager.instance.dummyPreset; @@ -74,7 +74,7 @@ public class BotThinkingState : IState //подсчет времени if(calculatedColumn!= -1 && !displayed) { - Debug.Log($"Думал: {Time.time - startTime}"); + //Debug.Log($"Думал: {Time.time - startTime}"); displayed = true; } diff --git a/Assets/Scripts/Inputs/ComSystem/ComWrapper.cs b/Assets/Scripts/Inputs/ComSystem/ComWrapper.cs index bb56aef..2deabfd 100644 --- a/Assets/Scripts/Inputs/ComSystem/ComWrapper.cs +++ b/Assets/Scripts/Inputs/ComSystem/ComWrapper.cs @@ -323,7 +323,7 @@ public static class ComWrapper if (count >= maxCount) break; if(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - startTime >= timeout) break; } - Debug.Log("count coins " + count); + Debug.Log($"Before game coins: {count}"); } /// diff --git a/Assets/Scripts/PVP Characters/Scripts/DualAvatarController.cs b/Assets/Scripts/PVP Characters/Scripts/DualAvatarController.cs index e92e147..97ef882 100644 --- a/Assets/Scripts/PVP Characters/Scripts/DualAvatarController.cs +++ b/Assets/Scripts/PVP Characters/Scripts/DualAvatarController.cs @@ -153,11 +153,11 @@ public class DualAvatarController : MonoBehaviour } private void NewRound(CellState lastRoundWinner) { - Debug.Log("NEW ROUND LAST WINNER " + lastRoundWinner); + //Debug.Log("NEW ROUND LAST WINNER " + lastRoundWinner); } private void EndGame(CellState gameWinner) { - Debug.Log("ENDGAME"); + //Debug.Log("ENDGAME"); } #endregion diff --git a/Assets/Scripts/PrizeStand/PrizeStandController.cs b/Assets/Scripts/PrizeStand/PrizeStandController.cs index a1309ad..cf2ed64 100644 --- a/Assets/Scripts/PrizeStand/PrizeStandController.cs +++ b/Assets/Scripts/PrizeStand/PrizeStandController.cs @@ -100,6 +100,18 @@ public static class PrizeStandController return; } + //очистка пол сук + await Task.Run(() => + { + byte[] buf = new byte[1024]; + var sw = Stopwatch.StartNew(); + while (sw.Elapsed.TotalSeconds < 0.5) + { + ComNativeWrapper.Serial_ReadLineUTF8_bytes(handle, buf, buf.Length); + } + }); + + try { //Валидация @@ -114,6 +126,7 @@ public static class PrizeStandController //Обработка результатов BoxStatus openStatus = await ReadBoxStatus(boxNumber, 1, WAIT_OPEN_STATUS_TIMEOUT); + UnityEngine.Debug.Log($"Получен статус открытия {openStatus}"); if (openStatus == BoxStatus.OPENED) { OpeningFinished?.Invoke(true, $"Ячейка {boxNumber} успешно открыта"); @@ -222,7 +235,13 @@ public static class PrizeStandController string entry = Encoding.UTF8.GetString(buffer, 0, entryLength).Trim(); + if (!entry.StartsWith("BOX")) + { + continue; + } + var ParseResult = ParseBoxStatus(entry); + UnityEngine.Debug.Log($"{ParseResult.BoxNumber} : {ParseResult.Status}"); if(ParseResult.BoxNumber == -1) { @@ -236,6 +255,9 @@ public static class PrizeStandController } } + if (boxesRecieved == expectedEntriesCount) UnityEngine.Debug.Log("Все коробки считаны"); + if (sw.Elapsed.TotalSeconds >= timeout) UnityEngine.Debug.Log("Вышли по таймауту"); + if (status == BoxStatus.NotFound) _logger?.Log($"[Модуль витрины. Не дождался ответа по статусу ячейки]\n" + $"Ожидаемый номер: {expectedBoxNumber}\n" + @@ -283,9 +305,8 @@ public static class PrizeStandController "OK" => BoxStatus.OK, "OK+CARD" => BoxStatus.OKplusCard, "EMPTY" => BoxStatus.Empty, - "OPEN" => BoxStatus.Open, - "OPENED" => BoxStatus.OPENED, + "OPEN" => BoxStatus.OPENED, "OPEN_ERROR" => BoxStatus.OPEN_ERROR, "ERROR" => BoxStatus.Error, diff --git a/Assets/Scripts/SolverV2.cs b/Assets/Scripts/SolverV2.cs index 227215d..a92aeb1 100644 --- a/Assets/Scripts/SolverV2.cs +++ b/Assets/Scripts/SolverV2.cs @@ -10,16 +10,17 @@ using System.Numerics; public static class SolverV2 { // Поле 6x7 (стандарт Connect4) - private const int WIDTH = 7; - private const int HEIGHT = 6; - private const int H1 = HEIGHT + 1; // 7: с "сентинел" битом на верх колонки - private const int MAX_MOVES = WIDTH * HEIGHT; // 42 + private static int WIDTH = 7; + private static int HEIGHT = 6; + private static int CenterCol => WIDTH / 2; + private static int H1 => HEIGHT + 1; //"сентинел" битом на верх колонки + private static int MAX_MOVES => WIDTH * HEIGHT; /// /// Можешь крутить глубину снаружи (чем выше — тем сильнее, но медленнее). /// Реально "очень высокие" глубины становятся возможны за счёт TT и битбордов. /// - public static int MaxDepth = 21; + public static int MaxDepth = 20; /// /// Ограничение на размер TT (чтобы не раздувать память). При переполнении — чистим. @@ -27,7 +28,8 @@ public static class SolverV2 public static int TranspositionMaxEntries = 1_200_000; // Порядок ходов: центр -> к краям (лучше и для игры, и для отсечений) - private static readonly int[] MoveOrder = { 3, 2, 4, 1, 5, 0, 6 }; + //private static readonly int[] MoveOrder = { 3, 2, 4, 1, 5, 0, 6 }; + private static readonly int[] MoveOrder; // Битовые маски по колонкам private static readonly ulong[] BottomMask = new ulong[WIDTH]; @@ -51,6 +53,9 @@ public static class SolverV2 static SolverV2() { + WIDTH = GameManager.instance.Cols; + HEIGHT = GameManager.instance.Rows; + MoveOrder = GenerateMoveOrder(); // Инициализация масок колонок for (int c = 0; c < WIDTH; c++) { @@ -62,7 +67,17 @@ public static class SolverV2 // Генерация всех выигрышных линий (четвёрок) WinningLineMasks = BuildWinningMasks(); } - + private static int[] GenerateMoveOrder() + { + int center = WIDTH / 2; + var order = new List { center }; + for (int i = 1; i <= center; i++) + { + if (center - i >= 0) order.Add(center - i); + if (center + i < WIDTH) order.Add(center + i); + } + return order.ToArray(); + } /// /// Главный метод: верни индекс колонки 0..6, куда бросать фишку. /// @@ -94,7 +109,7 @@ public static class SolverV2 if (mask == 0) { // На пустом поле лучший ход — центр - return 3; + return WIDTH / 2; } // Камень текущего игрока @@ -209,7 +224,7 @@ public static class SolverV2 int bestValue = -INF; // ordering: TT best first - int ttBest = (entry.BestCol <= 6) ? entry.BestCol : -1; + int ttBest = (entry.BestCol <= WIDTH - 1) ? entry.BestCol : -1; Span cols = stackalloc int[WIDTH]; int n = BuildOrderedMoves(p, cols, ttBest); @@ -240,7 +255,7 @@ public static class SolverV2 { Value = (short)bestValue, Depth = (byte)depth, - BestCol = (byte)(bestCol == 255 ? 3 : bestCol), + BestCol = (byte)(bestCol == 255 ? CenterCol : bestCol), Bound = Bound.Exact }; @@ -287,7 +302,7 @@ public static class SolverV2 private static int CenterControlBonus(ulong bits) { // колонка 3 (центр) - int c = 3; + int c = CenterCol; ulong col = ((1UL << HEIGHT) - 1UL) << (c * H1); int count = PopCount(bits & col); return count; // чем больше в центре, тем лучше @@ -384,7 +399,7 @@ public static class SolverV2 private static bool TryGetTTBestMove(Position p, out int bestCol) { - if (TT.TryGetValue(p.Key(), out var e) && e.BestCol <= 6) + if (TT.TryGetValue(p.Key(), out var e) && e.BestCol <= WIDTH - 1) { bestCol = e.BestCol; return true; @@ -480,7 +495,6 @@ public static class SolverV2 } } } - return list.ToArray(); } }