 import ReinforcementLearning
 import TensorFlow
 
+fileprivate let rebuttal: Bool = true
+
 public let banana = Item(
   name: "Banana",
-  scent: ShapedArray([1.92, 1.76, 0.40]),
-  color: ShapedArray([0.96, 0.88, 0.20]),
+  scent: rebuttal ? ShapedArray([0.0, 1.0, 0.0]) : ShapedArray([1.92, 1.76, 0.40]),
+  color: rebuttal ? ShapedArray([0.0, 1.0, 0.0]) : ShapedArray([0.96, 0.88, 0.20]),
   requiredItemCounts: [:],
   requiredItemCosts: [:],
   blocksMovement: false,
   visualOcclusion: 0.0,
   energyFunctions: EnergyFunctions(
-    intensityFn: .constant(1.5),
-    interactionFns: [
-      .piecewiseBox(itemId: 0, 10.0,  100.0,  0.0,    -6.0),
-      .piecewiseBox(itemId: 2, 10.0,  100.0,  2.0,  -100.0),
-      .piecewiseBox(itemId: 4, 50.0, 100.0, -100.0, -100.0)]))
+    intensityFn: rebuttal ? .constant(-5.3) : .constant(1.5),
+    interactionFns: rebuttal ?
+      [
+        .piecewiseBox(itemId: 0,  10.0, 200.0,  0.0,    -6.0),
+        .piecewiseBox(itemId: 1, 200.0,   0.0, -6.0,    -6.0),
+        .piecewiseBox(itemId: 2,  10.0, 200.0,  2.0,  -100.0)] :
+      [
+        .piecewiseBox(itemId: 0, 10.0,  100.0,  0.0,    -6.0),
+        .piecewiseBox(itemId: 2, 10.0,  100.0,  2.0,  -100.0),
+        .piecewiseBox(itemId: 4, 50.0, 100.0, -100.0, -100.0)]))
 public let onion = Item(
   name: "Onion",
-  scent: ShapedArray([0.68, 0.01, 0.99]),
-  color: ShapedArray([0.68, 0.01, 0.99]),
+  scent: rebuttal ? ShapedArray([1.0, 0.0, 0.0]) : ShapedArray([0.68, 0.01, 0.99]),
+  color: rebuttal ? ShapedArray([1.0, 0.0, 0.0]) : ShapedArray([0.68, 0.01, 0.99]),
   requiredItemCounts: [:],
   requiredItemCosts: [:],
   blocksMovement: false,
   visualOcclusion: 0.0,
   energyFunctions: EnergyFunctions(
-    intensityFn: .constant(-3.0),
-    interactionFns: []))
+    intensityFn: rebuttal ? .constant(-5.0) : .constant(-3.0),
+    interactionFns: rebuttal ?
+      [
+        .piecewiseBox(itemId: 0, 200.0, 0.0,   -6.0,   -6.0),
+        .piecewiseBox(itemId: 2, 200.0, 0.0, -100.0, -100.0)] :
+      []))
 public let jellyBean = Item(
   name: "JellyBean",
-  scent: ShapedArray([1.64, 0.54, 0.40]),
-  color: ShapedArray([0.82, 0.27, 0.20]),
+  scent: rebuttal ? ShapedArray([0.0, 0.0, 1.0]) : ShapedArray([1.64, 0.54, 0.40]),
+  color: rebuttal ? ShapedArray([0.0, 0.0, 1.0]) : ShapedArray([0.82, 0.27, 0.20]),
   requiredItemCounts: [:],
   requiredItemCosts: [:],
   blocksMovement: false,
   visualOcclusion: 0.0,
   energyFunctions: EnergyFunctions(
-    intensityFn: .constant(1.5),
-    interactionFns: [
-      .piecewiseBox(itemId: 0, 10.0,  100.0,  2.0,  -100.0),
-      .piecewiseBox(itemId: 2, 10.0,  100.0,  0.0,    -6.0),
-      .piecewiseBox(itemId: 4, 50.0, 100.0, -100.0, -100.0)]))
+    intensityFn: rebuttal ? .constant(-5.3) : .constant(1.5),
+    interactionFns: rebuttal ?
+      [
+        .piecewiseBox(itemId: 0,  10.0, 200.0,    2.0, -100.0),
+        .piecewiseBox(itemId: 1, 200.0,   0.0, -100.0, -100.0),
+        .piecewiseBox(itemId: 2,  10.0, 200.0,   0.0,    -6.0)] :
+      [
+        .piecewiseBox(itemId: 0, 10.0,  100.0,  2.0,  -100.0),
+        .piecewiseBox(itemId: 2, 10.0,  100.0,  0.0,    -6.0),
+        .piecewiseBox(itemId: 4, 50.0, 100.0, -100.0, -100.0)]))
 public let truffle = Item(
   name: "Truffle",
   scent: ShapedArray([8.40, 4.80, 2.60]),

) -> Simulator.Configuration {
  let wall = Item(
    name: "Wall",
    scent: ShapedArray([0.00, 0.00, 0.00]),
    color: ShapedArray([0.20, 0.47, 0.67]),
    requiredItemCounts: [3: 1], // Make walls impossible to collect.
    requiredItemCosts: [:],
    blocksMovement: true,
    visualOcclusion: enableVisualOcclusion ? 1.0 : 0.0,
    energyFunctions: EnergyFunctions(
      intensityFn: .constant(-12.0),
      interactionFns: [
        .cross(itemId: 3, 20.0, 40.0, 8.0, -1000.0, -1000.0, -1.0)]))
  let tree = Item(
    name: "Tree",
    scent: ShapedArray([0.00, 0.47, 0.06]),

    maxStepsPerMove: 1,
    scentDimensionality: 3,
    colorDimensionality: 3,
    visionRange: rebuttal ? 5 : 8,
    movePolicies: [.up: .allowed],
    turnPolicies: [.left: .allowed, .right: .allowed],
    noOpAllowed: false,
    patchSize: rebuttal ? 32 : 64,
    mcmcIterations: rebuttal ? 4000 : 10000,
    items: rebuttal ?
      [banana, onion, jellyBean, wall] :
      [banana, onion, jellyBean, wall, tree, truffle],
    agentColor: [0.0, 0.0, 0.0],
    agentFieldOfView: Float(agentFieldOfView) * .pi / 180.0,
    moveConflictPolicy: .firstComeFirstServe,
