Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for different obs sizes
  • Loading branch information
cswinter committed Oct 26, 2019
1 parent 8d607c1 commit 38c6d9d
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -128,15 +128,16 @@ class Application @Inject()(
val drone = ob.alliedDrones(i)
val x = drone.xPos
val y = drone.yPos
// 10 closest minerals
for (m <- ob.minerals.sortBy(m => (m.xPos * m.xPos + m.yPos * m.yPos) / m.size).take(10)) {
for (m <- ob.minerals
.sortBy(m => (m.xPos * m.xPos + m.yPos * m.yPos) / m.size)
.take(obsConfig.minerals)) {
bb.putFloat((m.xPos - x) / 1000.0f)
bb.putFloat((m.yPos - y) / 1000.0f)
bb.putFloat(
math.sqrt((m.yPos - y) * (m.yPos - y) + (m.xPos - x) * (m.xPos - x)).toFloat / 1000.0f)
bb.putFloat(m.size / 100.0f)
}
for (_ <- 0 until (10 - ob.minerals.size) * mineralProperties) {
for (_ <- 0 until (obsConfig.minerals - ob.minerals.size) * mineralProperties) {
bb.putFloat(0.0f)
}
}
Expand All @@ -151,8 +152,7 @@ class Application @Inject()(
val y = drone.yPos
val dronesSorted =
allDrones.sortBy(d => (d._1.xPos - x) * (d._1.xPos - x) + (d._1.yPos - y) * (d._1.yPos - y))
// 10 closest drones
for ((drone, isEnemy) <- dronesSorted.slice(1, 11)) {
for ((drone, isEnemy) <- dronesSorted.slice(1, obsConfig.drones + 1)) {
bb.putFloat((drone.xPos - x) / 1000.0f)
bb.putFloat((drone.yPos - y) / 1000.0f)
bb.putFloat(math.sin(drone.orientation).toFloat)
Expand All @@ -169,7 +169,7 @@ class Application @Inject()(
bb.putFloat(if (drone.isStunned) 1.0f else -1.0f)
bb.putFloat(if (isEnemy) -1.0f else 1.0f)
}
for (_ <- 0 until (11 - allDrones.size) * droneProperties) {
for (_ <- 0 until (obsConfig.drones + 1 - allDrones.size) * droneProperties) {
bb.putFloat(0.0f)
}
}
Expand All @@ -182,6 +182,7 @@ class Application @Inject()(
bb.putFloat(ob.enemyScore.toFloat)
}

// Action masks
for (ob <- obs) {
for (i <- 0 until obsConfig.allies) {
if (ob.alliedDrones.size <= i) {
Expand Down

0 comments on commit 38c6d9d

Please sign in to comment.