Skip to content

Commit

Permalink
fixed negative prob
Browse files Browse the repository at this point in the history
  • Loading branch information
jstar88 committed Mar 23, 2015
1 parent 1483379 commit 7a52eb5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions combatObject/ShipsCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class ShipsCleaner
public function __construct(ShipType $shipType, $lastShipHit, $lastShots)
{
if ($lastShipHit < 0)
throw new Exception('negative $lastShipHit');
throw new Exception('Negative $lastShipHit');
if ($lastShots < 0)
throw new Exception('negative $lastShots');
throw new Exception('Negative $lastShots');
$this->fighters = $shipType->cloneMe();
$this->lastShipHit = $lastShipHit;
$this->lastShots = $lastShots;
Expand All @@ -64,6 +64,10 @@ public function start()
//the mean probably to explode based on damage
$prob = 1 - $this->fighters->getCurrentLife() / ($this->fighters->getHull() * $this->fighters->getCount());
log_var('prob',$prob);
if ($prob < 0 && $prob > -EPSILON)
{
$prob = 0;
}
if ($prob < 0)
{
throw new Exception("Negative prob");
Expand Down

0 comments on commit 7a52eb5

Please sign in to comment.