Skip to content

Commit 7a830a1

Browse files
committed
Some changes.
1 parent e1b2c49 commit 7a830a1

7 files changed

Lines changed: 20 additions & 15 deletions

File tree

Client/src/client/AI.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import client.model.Block;
44
import client.model.Cell;
55
import model.Direction;
6+
import util.Constants;
67
import util.ServerConstants;
78

89
import java.util.Random;
@@ -32,13 +33,13 @@ public void doTurn(World world) {
3233
for(Cell c : world.getMyCells())
3334
{
3435
Block block = world.getMap().at(c.getPos());
35-
if(c.getEnergy() >= ServerConstants.CELL_MIN_ENERGY_FOR_MITOSIS && block.getType().equals(ServerConstants.BLOCK_TYPE_MITOSIS))
36+
if(c.getEnergy() >= Constants.CELL_MIN_ENERGY_FOR_MITOSIS && block.getType().equals(Constants.BLOCK_TYPE_MITOSIS))
3637
{
37-
//System.out.println("mitosis");
38-
//System.out.println(c.getEnergy());
38+
System.out.println("mitosis");
39+
System.out.println(c.getEnergy());
3940
c.mitosis();
4041
}
41-
else if(c.getEnergy() < ServerConstants.CELL_MAX_ENERGY && block.getResource() > 0)
42+
else if(c.getEnergy() < Constants.CELL_MAX_ENERGY && block.getType().equals(Constants.BLOCK_TYPE_RESOURCE) && block.getResource() > 0)
4243
{
4344
//System.out.println("gain");
4445
//System.out.println(block.getResource());

Client/src/client/Model.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
public class Model {
1717

18-
private long turnTimeout = 300;
18+
private long turnTimeout = 400;
1919
private long turnStartTime;
2020
private ArrayList<Event> events;
2121
private World world;

Mithosis/src/core/Context.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import core.model.Map;
77
import model.*;
88
import server.core.model.ClientInfo;
9+
import util.Constants;
910
import util.ServerConstants;
1011

1112
import java.io.*;
@@ -94,6 +95,8 @@ private void loadMap(String dir) throws IOException {
9495
int height = block.values[1].intValue();
9596
int resource = block.values[2].intValue();
9697
boolean isMovable = !types[type].equals(ServerConstants.BLOCK_TYPE_IMPASSABLE);
98+
if (type != 3)
99+
resource = 0;
97100
Block b = new Block(this, ServerConstants.TURN_MAKE_MAP, j, i, height, resource, types[type], isMovable);
98101
map.set(j, i, b);
99102
}
@@ -108,6 +111,8 @@ private void loadMap(String dir) throws IOException {
108111
int dof = instance.values[1].intValue();
109112
int energy = instance.values[2].intValue();
110113
int gainRate = instance.values[3].intValue();
114+
dof = Constants.CELL_DEPTH_OF_FIELD;
115+
gainRate = Constants.CELL_GAIN_RATE;
111116
Cell cell = new Cell(this, new Position(x, y), teamID, dof, energy, gainRate);
112117
addCell(cell);
113118
}

Mithosis/src/core/MitosisGameLogic.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ public void simulateEvents(Event[] terminalEvent, Event[] environmentEvent, Even
242242
}
243243

244244
Collection<GameEvent> currentTurnEventsList = gameObjectEvents.values();
245-
GameEvent[] currentTurnEvents = currentTurnEventsList.toArray(new GameEvent[currentTurnEventsList.size()]);
246-
247-
for (GameEvent event: currentTurnEvents) {
245+
for (GameEvent event: currentTurnEventsList) {
248246
switch (event.getType()) {
249247
case GameEvent.TYPE_MOVE:
250248
moveEvents.add(event);

Mithosis/src/core/model/Cell.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ public boolean mitosis() {
9595
{
9696
continue;
9797
}
98+
int currentHeight = ctx.getMap().at(position).getHeight();
99+
int nextHeight = ctx.getMap().at(tPos).getHeight();
100+
if (nextHeight > currentHeight + 1) {
101+
continue;
102+
}
98103
if(ctx.getMap().at(tPos).isEmpty())
99104
{
100105
secondCellPos = tPos;
@@ -104,11 +109,7 @@ public boolean mitosis() {
104109
if(secondCellPos == null) {
105110
return false;
106111
}
107-
int currentHeight = ctx.getMap().at(position).getHeight();
108-
int nextHeight = ctx.getMap().at(secondCellPos).getHeight();
109-
if (nextHeight > currentHeight + 1) {
110-
return false;
111-
}
112+
112113
int energy = ServerConstants.CELL_MIN_ENERGY_FOR_MITOSIS;
113114
int secondEnergy = energy / 2;
114115
setEnergy(energy - secondEnergy);

Server/src/server/core/GameHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class GameHandler {
4343
private static final String RESOURCE_PATH_OUTPUT_HANDLER = "resources/game_handler/output_handler.conf";
4444
private static final String RESOURCE_PATH_TURN_TIMEOUT = "resources/game_handler/turn_timeout.conf";
4545
private final long GAME_LOGIC_SIMULATE_TIMEOUT;
46-
private final long GAME_LOGIC_TURN_TIMEOUT = 400;
46+
private final long GAME_LOGIC_TURN_TIMEOUT = 1000;
4747
private final long CLIENT_RESPONSE_TIME;
4848

4949
private ClientNetwork mClientNetwork;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"clientResponseTime" : 350,
2+
"clientResponseTime" : 500,
33
"simulateTimeout" : 10000
44
}

0 commit comments

Comments
 (0)