Skip to content

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
fabio-t committed Nov 6, 2017
2 parents bc7b42e + d6859f6 commit b03f434
Show file tree
Hide file tree
Showing 49 changed files with 1,385 additions and 1,240 deletions.
6 changes: 0 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

- Hide SingleGrid and MultipleGrid behind Map, so that I can generalise MovementSystem to move creatures and items,
without if-else.. maybe? We'll see if this happens more often, if it's only for the movement of
thrown stuff than we can leave it like this.

- Must handle "linked entities" better using LinkListener. It's probably not needed for items, but for creatures, trees
and boulders (eg, entities that can be destroyed) yes. When fire is implemented, items too should be handled.
The approach is simple: inside the ActionSystem get hold of the EntityLinkManager instance and register
Expand All @@ -19,5 +15,3 @@
- LookScreen must show a message when moving around; the white colour of the targeting it's also horrible. It would be
nice to make it better, eg a darker shade of whatever background colour there is? (a TileTransformer would work nicely
maybe)

- weapon damage must be included in the damage formula :) for now only strength it's used!
5 changes: 3 additions & 2 deletions alone-rl.iml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: it.unimi.dsi:fastutil:8.1.0" level="project" />
<orderEntry type="library" name="Maven: com.github.trystan:AsciiPanel:e0c4372" level="project" />
<orderEntry type="library" name="Maven: net.onedaybeard.artemis:artemis-odb:2.1.0" level="project" />
<orderEntry type="library" name="Maven: net.mostlyoriginal.artemis-odb:contrib-core:2.2.0" level="project" />
<orderEntry type="library" name="Maven: com.github.fabioticconi:rlforj-alt:0.1.1" level="project" />
<orderEntry type="library" name="Maven: com.github.fabioticconi:rlforj-alt:0.2.0" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
Expand All @@ -24,5 +23,7 @@
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.3.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.3.0" level="project" />
</component>
</module>
41 changes: 41 additions & 0 deletions data/crafting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

branch:
name: a branch
#source:
# external: tree

tree-trunk:
name: a tree trunk
#source:
# external: tree
tool: axe

stone:
name: a stone
#source:
# external: boulder
tool: stone
n: 3

sharp-stone:
name: a sharp stone
source: stone
tool: stone

#small-sharp-stone:
# name: a small, sharp stone
# source: [sharp-stone]
# tool: stone
# n: 2
#
#stone-hammer:
# name: a stone hammer
# source: [stone, branch]
#
#stone-axe:
# name: a stone axe
# source: [sharp-stone, branch]
#
#stone-spear:
# name: a stone spear
# source: [small-sharp-stone, tree-trunk]
Empty file removed data/flora/tree.yml
Empty file.
12 changes: 12 additions & 0 deletions data/items.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

stone:
name: a stone

branch:
name: a branch

trunk:
name: a tree trunk

boulder:
name: a boulder
Empty file removed data/items/branch.yml
Empty file.
Empty file removed data/items/stone.yml
Empty file.
Empty file removed data/items/trunk.yml
Empty file.
1 change: 1 addition & 0 deletions data/player.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

strength: 2
agility: 2
constitution: 2
Expand Down
15 changes: 7 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>com.github.fabioticconi</groupId>
<artifactId>alone-rl</artifactId>
<version>0.1.0</version>
<version>0.2.1</version>
<packaging>jar</packaging>

<name>AloneRL</name>
Expand All @@ -32,12 +32,6 @@
</properties>

<dependencies>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.1.0</version>
</dependency>

<dependency>
<groupId>com.github.trystan</groupId>
<artifactId>AsciiPanel</artifactId>
Expand All @@ -59,7 +53,7 @@
<dependency>
<groupId>com.github.fabioticconi</groupId>
<artifactId>rlforj-alt</artifactId>
<version>0.1.1</version>
<version>0.2.0</version>
</dependency>

<dependency>
Expand All @@ -80,6 +74,11 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.1</version>
</dependency>

</dependencies>

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/github/fabioticconi/alone/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import com.artemis.utils.BitVector;
import com.github.fabioticconi.alone.behaviours.*;
import com.github.fabioticconi.alone.constants.Options;
import com.github.fabioticconi.alone.map.MultipleGrid;
import com.github.fabioticconi.alone.map.SingleGrid;
import com.github.fabioticconi.alone.screens.*;
import com.github.fabioticconi.alone.systems.*;
import org.slf4j.Logger;
Expand Down Expand Up @@ -74,9 +72,7 @@ public Main() throws IOException
config = new WorldConfiguration();
// first thing to be loaded
config.setSystem(MapSystem.class);
// POJOs
config.register(new SingleGrid());
config.register(new MultipleGrid());
// POJO
config.register(new Random());
config.register(properties);
// passive systems, one-timers, managers etc
Expand All @@ -102,13 +98,15 @@ public Main() throws IOException
config.setSystem(PushSystem.class);
config.setSystem(CrushSystem.class);
config.setSystem(ThrowSystem.class);
config.setSystem(CraftSystem.class);
// ai behaviours (passive)
config.setSystem(FleeBehaviour.class);
config.setSystem(GrazeBehaviour.class);
config.setSystem(ChaseBehaviour.class);
config.setSystem(FlockBehaviour.class);
config.setSystem(ScavengeBehaviour.class);
config.setSystem(WanderBehaviour.class);

config.setSystem(UnderwaterBehaviour.class);
config.setSystem(FleeFromActionBehaviour.class);
// screens (passive)
Expand All @@ -118,6 +116,8 @@ public Main() throws IOException
config.setSystem(EatScreen.class);
config.setSystem(LookScreen.class);
config.setSystem(EquipScreen.class);
config.setSystem(CraftScreen.class);
config.setSystem(CraftItemScreen.class);
// last systems
config.setSystem(DeadSystem.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@

import com.artemis.Aspect;
import com.artemis.ComponentMapper;
import com.artemis.annotations.Wire;
import com.artemis.utils.IntBag;
import com.github.fabioticconi.alone.components.Herbivore;
import com.github.fabioticconi.alone.components.Hunger;
import com.github.fabioticconi.alone.components.Position;
import com.github.fabioticconi.alone.components.Speed;
import com.github.fabioticconi.alone.components.attributes.Sight;
import com.github.fabioticconi.alone.map.SingleGrid;
import com.github.fabioticconi.alone.systems.BumpSystem;
import com.github.fabioticconi.alone.systems.MapSystem;
import com.github.fabioticconi.alone.utils.Coords;
import it.unimi.dsi.fastutil.ints.IntSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -48,9 +46,6 @@ public class ChaseBehaviour extends AbstractBehaviour
BumpSystem sBump;
MapSystem sMap;

@Wire
SingleGrid grid;

private Position chasePos;

@Override
Expand All @@ -73,17 +68,17 @@ public float evaluate(final int entityId)
final Hunger cHunger = mHunger.get(entityId);
final float hunger = cHunger.value / cHunger.maxValue; // need a value between 0 and 1

// System.out.println(entityId + " " + curPos);

// all creatures in the visible area for this predator
final IntSet creatures = grid.getEntities(sMap.getVisibleCells(pos.x, pos.y, sight));
final IntBag creatures = sMap.getObstacles().getEntities(sMap.getVisibleCells(pos.x, pos.y, sight));

float minDistance = Float.MAX_VALUE;
chasePos = null;

Position temp;
for (final int creatureId : creatures)
for (int i = 0, size = creatures.size(); i < size; i++)
{
final int creatureId = creatures.get(i);

if (mHerbivore.has(creatureId))
{
temp = mPosition.get(creatureId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@

import com.artemis.Aspect;
import com.artemis.ComponentMapper;
import com.artemis.annotations.Wire;
import com.artemis.utils.IntBag;
import com.github.fabioticconi.alone.components.Carnivore;
import com.github.fabioticconi.alone.components.Position;
import com.github.fabioticconi.alone.components.Speed;
import com.github.fabioticconi.alone.components.attributes.Sight;
import com.github.fabioticconi.alone.constants.Side;
import com.github.fabioticconi.alone.map.SingleGrid;
import com.github.fabioticconi.alone.systems.BumpSystem;
import com.github.fabioticconi.alone.systems.MapSystem;
import com.github.fabioticconi.alone.utils.Coords;
import it.unimi.dsi.fastutil.ints.IntSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -48,9 +46,6 @@ public class FleeBehaviour extends AbstractBehaviour

MapSystem sMap;

@Wire
SingleGrid grid;

Position curPos;
Position fleeFrom;

Expand All @@ -73,9 +68,7 @@ public float evaluate(final int entityId)
curPos = mPosition.get(entityId);
final int sight = mSight.get(entityId).value;

// System.out.println(entityId + " " + curPos);

final IntSet creatures = grid.getEntities(sMap.getVisibleCells(curPos.x, curPos.y, sight));
final IntBag creatures = sMap.getObstacles().getEntities(sMap.getVisibleCells(curPos.x, curPos.y, sight));

if (creatures.isEmpty())
return 0f;
Expand All @@ -85,8 +78,10 @@ public float evaluate(final int entityId)

int count = 0;
Position tempPos;
for (final int creatureId : creatures)
for (int i = 0, size = creatures.size(); i < size; i++)
{
final int creatureId = creatures.get(i);

if (mCarnivore.has(creatureId))
{
tempPos = mPosition.get(creatureId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@

import com.artemis.Aspect;
import com.artemis.ComponentMapper;
import com.artemis.annotations.Wire;
import com.artemis.utils.IntBag;
import com.github.fabioticconi.alone.components.Position;
import com.github.fabioticconi.alone.components.Speed;
import com.github.fabioticconi.alone.components.Underwater;
import com.github.fabioticconi.alone.components.actions.Action;
import com.github.fabioticconi.alone.components.attributes.Sight;
import com.github.fabioticconi.alone.constants.Side;
import com.github.fabioticconi.alone.map.SingleGrid;
import com.github.fabioticconi.alone.systems.BumpSystem;
import com.github.fabioticconi.alone.systems.MapSystem;
import it.unimi.dsi.fastutil.ints.IntSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -51,9 +49,6 @@ public class FleeFromActionBehaviour extends AbstractBehaviour

MapSystem sMap;

@Wire
SingleGrid grid;

Position curPos;
Position fleeFrom;

Expand All @@ -76,7 +71,7 @@ public float evaluate(final int entityId)
curPos = mPosition.get(entityId);
final int sight = mSight.get(entityId).value;

final IntSet creatures = grid.getEntities(sMap.getVisibleCells(curPos.x, curPos.y, sight));
final IntBag creatures = sMap.getObstacles().getEntities(sMap.getVisibleCells(curPos.x, curPos.y, sight));

if (creatures.isEmpty())
return 0f;
Expand All @@ -86,8 +81,10 @@ public float evaluate(final int entityId)

int count = 0;
Position tempPos;
for (final int creatureId : creatures)
for (int i = 0, size = creatures.size(); i < size; i++)
{
final int creatureId = creatures.get(i);

// only avoid non-fish
if (mAction.has(creatureId) && !mUnderWater.has(creatureId))
{
Expand Down
Loading

0 comments on commit b03f434

Please sign in to comment.