Skip to content

Commit 15ceec4

Browse files
committed
Fix GeneratePossibleMoves()
1 parent bdb9576 commit 15ceec4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

socha-backend/State.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ private List<Move> GeneratePossibleMoves(List<Action> pastActions = null, Ship c
110110
{
111111
var newCurShip = (Ship)curShip.Clone();
112112
var newOtherShip = (Ship)otherShip.Clone();
113+
var newActions = pastActions.Clone();
114+
newActions.Add(newAction);
113115
newAction.PerformOn(this, newCurShip, newOtherShip);
114116

115117
// You're on a path in the woods, and at the end of that path is a cabin...
116-
re.AddRange(GeneratePossibleMoves(new List<Action> { newAction }, newCurShip, newOtherShip));
118+
re.AddRange(GeneratePossibleMoves(newActions, newCurShip, newOtherShip));
117119
}
118120
}
119121
}
@@ -129,10 +131,12 @@ private List<Move> GeneratePossibleMoves(List<Action> pastActions = null, Ship c
129131
{
130132
var newCurShip = (Ship)curShip.Clone();
131133
var newOtherShip = (Ship)otherShip.Clone();
134+
var newActions = pastActions.Clone();
135+
newActions.Add(newAction);
132136
newAction.PerformOn(this, newCurShip, newOtherShip);
133137

134138
// You're on a path in the woods, and at the end of that path is a cabin...
135-
re.AddRange(GeneratePossibleMoves(new List<Action> { newAction }, newCurShip, newOtherShip));
139+
re.AddRange(GeneratePossibleMoves(newActions, newCurShip, newOtherShip));
136140
}
137141
}
138142
}

0 commit comments

Comments
 (0)