Skip to content

Commit

Permalink
update README for v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami Farhat committed Apr 10, 2017
1 parent 5374928 commit fd3b73d
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Welcome to the Jungle
# Welcome to the Jungle (v0.1)

## Agent
Any agent in the system. An agent is characterised by:

* by an identifier unique for the duration of the simluation
* a position

Expand All @@ -10,29 +11,16 @@ Any agent in the system. An agent is characterised by:
LifeAgent: anything that has a life and has energy.

Interfaces implemented:

* Reproducable :
* Consumable : can be consumed, every lifeagent is prone to being consumed
* Consumable : can be consumed, every lifeagent is prone to being consumed

AliveAgents can always die, but
do not necessarily age, the implementer can choose to implement the interface **Age** or not.
AliveAgents can always die, but do not necessarily age, the implementer can choose to implement the interface **Age** or not.

## How consuming other LifeAgents works

We cannot trust the implementers of Consumer to follow proper logic and reasoning: Deer.java can be implemented such that
the deer consumes ANY LifeAgent it is passed (including Wolves..).

And so it must be that whichever class calls consume() on a LifeAgent, also has to ensure the LifeAgents() passed are
consumable.

** An implementation of Consumable that makes me go mad**
If we do not design it like this then implementers will have the power of doing the below:
`
public void consume(LifeAgent prey) {
if (prey instanceof Grass) {
prey.die();
}
else if (prey instanceof Lion) {
prey.die(); // <== this would be absurd!!
}
}
`
We cannot trust the implementers of Consumer to follow proper logic and reasoning: Deer can be implemented such that the deer consumes ANY LifeAgent it is passed - including Wolves.

Whichever class calls
```deer.consume(agents)``` has to ensure that the agents passed as param are consumable by the deer. Hence, the responsibility lies with the caller.

0 comments on commit fd3b73d

Please sign in to comment.