Anonymous Anonymous - 1 month ago
366 0

This is the output of the entrance field with 4 robots and two surrounding wall fields for comparison. The exit looks exactly the same, so there is no way of knowing which is which without knowing that the entrance is always in the first line of walls and the exit is in the last line. This too would be solved by some way of adding a key-value-pair in the encoding process.

JSON

Output JSON of Swift Encodable

{
            "content" : "wall",
            "position" : {
              "x" : 13,
              "y" : 0
            }
          },
          {
            "content" : [
              {
                "product" : {
                  "type" : "C"
                },
                "position" : {
                  "x" : 14,
                  "y" : 0
                },
                "id" : 2,
                "routing" : {

                },
                "remainingRoute" : [
                  {
                    "x" : 3,
                    "y" : 5
                  },
                  {
                    "x" : 9,
                    "y" : 7
                  },
                  {
                    "x" : 24,
                    "y" : 1
                  },
                  {
                    "x" : 26,
                    "y" : 5
                  },
                  {
                    "x" : 10,
                    "y" : 4
                  },
                  {
                    "x" : 14,
                    "y" : 1
                  },
                  {
                    "x" : 14,
                    "y" : 9
                  }
                ],
                "state" : "starting",
                "dodgeCounter" : 0
              },
              {
                "product" : {
                  "type" : "C"
                },
                "position" : {
                  "x" : 14,
                  "y" : 0
                },
                "id" : 3,
                "routing" : {

                },
                "remainingRoute" : [
                  {
                    "x" : 3,
                    "y" : 5
                  },
                  {
                    "x" : 9,
                    "y" : 7
                  },
                  {
                    "x" : 24,
                    "y" : 1
                  },
                  {
                    "x" : 26,
                    "y" : 5
                  },
                  {
                    "x" : 10,
                    "y" : 4
                  },
                  {
                    "x" : 14,
                    "y" : 1
                  },
                  {
                    "x" : 14,
                    "y" : 9
                  }
                ],
                "state" : "starting",
                "dodgeCounter" : 0
              },
              {
                "product" : {
                  "type" : "F"
                },
                "position" : {
                  "x" : 14,
                  "y" : 0
                },
                "id" : 1,
                "routing" : {

                },
                "remainingRoute" : [
                  {
                    "x" : 26,
                    "y" : 5
                  },
                  {
                    "x" : 24,
                    "y" : 1
                  },
                  {
                    "x" : 26,
                    "y" : 5
                  },
                  {
                    "x" : 24,
                    "y" : 1
                  },
                  {
                    "x" : 26,
                    "y" : 5
                  },
                  {
                    "x" : 9,
                    "y" : 7
                  },
                  {
                    "x" : 14,
                    "y" : 9
                  }
                ],
                "state" : "starting",
                "dodgeCounter" : 0
              },
              {
                "product" : {
                  "type" : "A"
                },
                "position" : {
                  "x" : 14,
                  "y" : 0
                },
                "id" : 4,
                "routing" : {

                },
                "remainingRoute" : [
                  {
                    "x" : 14,
                    "y" : 1
                  },
                  {
                    "x" : 10,
                    "y" : 4
                  },
                  {
                    "x" : 26,
                    "y" : 5
                  },
                  {
                    "x" : 24,
                    "y" : 1
                  },
                  {
                    "x" : 9,
                    "y" : 7
                  },
                  {
                    "x" : 3,
                    "y" : 5
                  },
                  {
                    "x" : 14,
                    "y" : 9
                  }
                ],
                "state" : "starting",
                "dodgeCounter" : 0
              }
            ],
            "position" : {
              "x" : 14,
              "y" : 0
            }
          },
          {
            "content" : "wall",
            "position" : {
              "x" : 15,
              "y" : 0
            }
          }