From c4e603fa7bee278ede16e9e32a074c15ec67457c Mon Sep 17 00:00:00 2001 From: Niklas Carstensen Date: Mon, 22 Jan 2024 02:55:38 +0100 Subject: [PATCH] Fix GeneratePossibleMoveEndings() --- socha-backend/State.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/socha-backend/State.cs b/socha-backend/State.cs index 30faf48..de6a157 100644 --- a/socha-backend/State.cs +++ b/socha-backend/State.cs @@ -103,7 +103,7 @@ private List GeneratePossibleMoveEndings(List pastActions, Ship cu List re = new(); - if (curShip.MovementPoints > 0 && pastActions.Last() is not Advance) + if (curShip.MovementPoints > 0 && (!pastActions.Any() || pastActions.Last() is not Advance)) { // Add advance action for (int i = 1; i < curShip.MovementPoints + 1; i++) @@ -124,7 +124,7 @@ private List GeneratePossibleMoveEndings(List pastActions, Ship cu } } - if ((curShip.Coal > 0 || curShip.FreeTurns > 0) && pastActions.Last() is not Backend.Turn) + if ((curShip.Coal > 0 || curShip.FreeTurns > 0) && (!pastActions.Any() || pastActions.Last() is not Backend.Turn)) { // Add turn action for (int i = 0; i < Enum.GetNames(typeof(Direction)).Length; i++)