diff --git a/monolith/src/main/java/eu/solven/territory/app/mvc/Snake_v0DummyController.java b/monolith/src/main/java/eu/solven/territory/app/mvc/Snake_v0DummyController.java index 6454af2..e5154d2 100644 --- a/monolith/src/main/java/eu/solven/territory/app/mvc/Snake_v0DummyController.java +++ b/monolith/src/main/java/eu/solven/territory/app/mvc/Snake_v0DummyController.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.app.mvc; import org.slf4j.Logger; diff --git a/monolith/src/main/java/eu/solven/territory/app/mvc/Snake_v2MultipleController.java b/monolith/src/main/java/eu/solven/territory/app/mvc/Snake_v2MultipleController.java index af6e698..f441fe6 100644 --- a/monolith/src/main/java/eu/solven/territory/app/mvc/Snake_v2MultipleController.java +++ b/monolith/src/main/java/eu/solven/territory/app/mvc/Snake_v2MultipleController.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.app.mvc; import java.util.Random; diff --git a/monolith/src/main/java/eu/solven/territory/snake/ISnakeCell.java b/monolith/src/main/java/eu/solven/territory/snake/ISnakeCell.java index c38ea37..31e52ef 100644 --- a/monolith/src/main/java/eu/solven/territory/snake/ISnakeCell.java +++ b/monolith/src/main/java/eu/solven/territory/snake/ISnakeCell.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.snake; import eu.solven.territory.snake.strategies.dummy.WholeSnake; diff --git a/monolith/src/main/java/eu/solven/territory/snake/SnakeCell.java b/monolith/src/main/java/eu/solven/territory/snake/SnakeCell.java index a039185..0004ce1 100644 --- a/monolith/src/main/java/eu/solven/territory/snake/SnakeCell.java +++ b/monolith/src/main/java/eu/solven/territory/snake/SnakeCell.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.snake; import java.util.LinkedList; @@ -32,15 +47,15 @@ public class SnakeCell extends SnakeOrApple implements ISnakeCell, IsSnake { public static SnakeCell headToRight() { WholeSnake wholeSnake = new WholeSnake(1, new LinkedList<>()); - SnakeCell head = new SnakeCell(wholeSnake, true, 0, 0); + var head = new SnakeCell(wholeSnake, true, 0, 0); wholeSnake.appendAsHead(head); return head; } public static SnakeCell headToRight_canSmell(Supplier randomSupplier) { - WholeSnake wholeSnake = new WholeSnake_SmellApplesLoseWeightWithTime( randomSupplier, 1, new LinkedList<>()); - SnakeCell head = new SnakeCell(wholeSnake, true, 0, 0); + WholeSnake wholeSnake = new WholeSnake_SmellApplesLoseWeightWithTime(randomSupplier, 1, new LinkedList<>()); + var head = new SnakeCell(wholeSnake, true, 0, 0); wholeSnake.appendAsHead(head); return head; @@ -50,10 +65,10 @@ public void newHead(int direction) { ISnakeCell previousHead = whole.loseHead(); int previousHeadCellIndex = previousHead.getCellIndex(); - SnakeCell behindNewHead = new SnakeCell(whole, false, previousHeadCellIndex, previousHead.getDirection()); + var behindNewHead = new SnakeCell(whole, false, previousHeadCellIndex, previousHead.getDirection()); whole.appendAsHead(behindNewHead); - SnakeCell futureHead = new SnakeCell(whole, true, previousHeadCellIndex + 1, direction); + var futureHead = new SnakeCell(whole, true, previousHeadCellIndex + 1, direction); whole.appendAsHead(futureHead); // return futureHead; } diff --git a/monolith/src/main/java/eu/solven/territory/snake/SnakeInRectangleOccupation.java b/monolith/src/main/java/eu/solven/territory/snake/SnakeInRectangleOccupation.java index cbf541b..a684fc2 100644 --- a/monolith/src/main/java/eu/solven/territory/snake/SnakeInRectangleOccupation.java +++ b/monolith/src/main/java/eu/solven/territory/snake/SnakeInRectangleOccupation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.snake; import java.util.HashSet; diff --git a/monolith/src/main/java/eu/solven/territory/snake/strategies/dummy/WholeSnake.java b/monolith/src/main/java/eu/solven/territory/snake/strategies/dummy/WholeSnake.java index 1784d49..58dd24c 100644 --- a/monolith/src/main/java/eu/solven/territory/snake/strategies/dummy/WholeSnake.java +++ b/monolith/src/main/java/eu/solven/territory/snake/strategies/dummy/WholeSnake.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.snake.strategies.dummy; import java.util.Collection; @@ -66,7 +81,7 @@ public void loseTail() { } public WholeSnake copy() { - WholeSnake newSnake = new WholeSnake(uuid, getCapacity(), new LinkedList<>()); + var newSnake = new WholeSnake(uuid, getCapacity(), new LinkedList<>()); LinkedList newCells = cells.stream().map(cell -> cell.editSnake(newSnake)).collect(Collectors.toCollection(LinkedList::new)); diff --git a/monolith/src/main/java/eu/solven/territory/snake/strategies/v1_cansmell/WholeSnake_SmellApplesLoseWeightWithTime.java b/monolith/src/main/java/eu/solven/territory/snake/strategies/v1_cansmell/WholeSnake_SmellApplesLoseWeightWithTime.java index 9fc9b25..265f231 100644 --- a/monolith/src/main/java/eu/solven/territory/snake/strategies/v1_cansmell/WholeSnake_SmellApplesLoseWeightWithTime.java +++ b/monolith/src/main/java/eu/solven/territory/snake/strategies/v1_cansmell/WholeSnake_SmellApplesLoseWeightWithTime.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.snake.strategies.v1_cansmell; import java.util.Deque; @@ -56,7 +71,7 @@ private WholeSnake_SmellApplesLoseWeightWithTime(UUID uuid, } public WholeSnake copy() { - WholeSnake_SmellApplesLoseWeightWithTime newSnake = new WholeSnake_SmellApplesLoseWeightWithTime(this.getId(), + var newSnake = new WholeSnake_SmellApplesLoseWeightWithTime(this.getId(), randomSupplier, getCapacity(), new LinkedList<>()); diff --git a/monolith/src/main/java/eu/solven/territory/snake/strategies/v2_multiplesnakes/MultipleSnakeInRectangleOccupation.java b/monolith/src/main/java/eu/solven/territory/snake/strategies/v2_multiplesnakes/MultipleSnakeInRectangleOccupation.java index d6a104b..b2d257a 100644 --- a/monolith/src/main/java/eu/solven/territory/snake/strategies/v2_multiplesnakes/MultipleSnakeInRectangleOccupation.java +++ b/monolith/src/main/java/eu/solven/territory/snake/strategies/v2_multiplesnakes/MultipleSnakeInRectangleOccupation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.snake.strategies.v2_multiplesnakes; import java.util.HashSet; diff --git a/monolith/src/main/java/eu/solven/territory/snake/strategies/v2_multiplesnakes/PositionnedSnake.java b/monolith/src/main/java/eu/solven/territory/snake/strategies/v2_multiplesnakes/PositionnedSnake.java index cbc709d..062a69c 100644 --- a/monolith/src/main/java/eu/solven/territory/snake/strategies/v2_multiplesnakes/PositionnedSnake.java +++ b/monolith/src/main/java/eu/solven/territory/snake/strategies/v2_multiplesnakes/PositionnedSnake.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.snake.strategies.v2_multiplesnakes; import java.util.concurrent.atomic.AtomicReference; diff --git a/monolith/src/main/java/eu/solven/territory/snake/v0_only_snake/GameOfSnake.java b/monolith/src/main/java/eu/solven/territory/snake/v0_only_snake/GameOfSnake.java index c8c58ae..30ff9b6 100644 --- a/monolith/src/main/java/eu/solven/territory/snake/v0_only_snake/GameOfSnake.java +++ b/monolith/src/main/java/eu/solven/territory/snake/v0_only_snake/GameOfSnake.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.snake.v0_only_snake; import java.util.HashSet; @@ -48,7 +63,7 @@ public GameOfSnake(SquareMap map) { @Override public IWorldOccupation cycle(IWorldOccupation occupation) { - int cyrrentCycle = cycleIndex.getAndIncrement(); + var cyrrentCycle = cycleIndex.getAndIncrement(); IWorldOccupation rawCopy = rawCycle(occupation); @@ -63,8 +78,8 @@ public IWorldOccupation cycle(IWorldOccupation private IWorldOccupation rawCycle(IWorldOccupation occupation) { IWorldOccupation rawCopy = occupation.mutableCopy(); - int includeSelfRadius = 1; - int gameOfLifeRadius = 1; + var includeSelfRadius = 1; + var gameOfLifeRadius = 1; IMapWindow windowBuffer = occupation.makeWindowBuffer(includeSelfRadius + gameOfLifeRadius); SnakeTurnContext context = buildContext(occupation, windowBuffer); @@ -129,9 +144,9 @@ private void growApples(SnakeTurnContext context, SnakeInRectangleOccupation sna int worldSize = map.size(); // 1 apple plus one apple per 10x10 blocks - int targetNbApples = 1 + worldSize / (10 * 10); + var targetNbApples = 1 + worldSize / (10 * 10); - int missingApples = Math.max(0, targetNbApples - nbApples); + var missingApples = Math.max(0, targetNbApples - nbApples); if (missingApples > 0) { // Apples can pop anywhere, even under the snake diff --git a/monolith/src/main/java/eu/solven/territory/snake/v0_only_snake/GameOfSnake_Multiple.java b/monolith/src/main/java/eu/solven/territory/snake/v0_only_snake/GameOfSnake_Multiple.java index 7d46a07..af395f6 100644 --- a/monolith/src/main/java/eu/solven/territory/snake/v0_only_snake/GameOfSnake_Multiple.java +++ b/monolith/src/main/java/eu/solven/territory/snake/v0_only_snake/GameOfSnake_Multiple.java @@ -1,3 +1,18 @@ +/* + * Copyright 2023 Benoit Lacelle - SOLVEN + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package eu.solven.territory.snake.v0_only_snake; import java.util.HashSet; @@ -49,7 +64,7 @@ public GameOfSnake_Multiple(SquareMap map) { @Override public IWorldOccupation cycle(IWorldOccupation occupation) { - int cyrrentCycle = cycleIndex.getAndIncrement(); + var cyrrentCycle = cycleIndex.getAndIncrement(); IWorldOccupation rawCopy = rawCycle(occupation); @@ -64,8 +79,8 @@ public IWorldOccupation cycle(IWorldOccupation private IWorldOccupation rawCycle(IWorldOccupation occupation) { IWorldOccupation rawCopy = occupation.mutableCopy(); - int includeSelfRadius = 1; - int gameOfLifeRadius = 1; + var includeSelfRadius = 1; + var gameOfLifeRadius = 1; IMapWindow windowBuffer = occupation.makeWindowBuffer(includeSelfRadius + gameOfLifeRadius); SnakeTurnContext context = buildContext(occupation, windowBuffer); @@ -133,9 +148,9 @@ private void growApples(SnakeTurnContext context, MultipleSnakeInRectangleOccupa int worldSize = map.size(); // 1 apple plus one apple per 10x10 blocks - int targetNbApples = 1 + worldSize / (10 * 10); + var targetNbApples = 1 + worldSize / (10 * 10); - int missingApples = Math.max(0, targetNbApples - nbApples); + var missingApples = Math.max(0, targetNbApples - nbApples); if (missingApples > 0) { // Apples can pop anywhere, even under the snake