예제 #1
0
 public void Stop()
 {
     CurrentTime = -1;
     board       = boardBackup;
     boardBackup = null;
     Photons.Clear();
 }
예제 #2
0
    public void Start(int seed)
    {
        // Bookkeeping
        CurrentTime  = 0;
        nextPhotonId = 0;
        Photons.Clear();

        // Get input/output from script
        System.Random random  = new System.Random(seed);
        DynValue      iovalue = luaEnvironment.Call(
            luaGetIO, (Func <int, int>)((max) => random.Next(max))
            );

        input  = iovalue.Tuple[0].ToObject <List <int> >();
        golden = iovalue.Tuple[1].ToObject <List <int> >();
        output = new List <int>();

        // Save the original state of board
        boardBackup = board.Clone() as Cell[, ];

        // Find out where input is
        FindCell((x, y, cell) => cell.type == CellType.INPUT,
                 (x, y, cell) =>
        {
            inputPosition  = new Vector2Int(x, y);
            inputDirection = DirectionIdToVector(cell.param);
        });
        //Debug.Log($"Input coordinate: ({inputX}, {inputY})");

        // Generate first input Photon
        GeneratePhoton(input[0], inputPosition, inputDirection);
    }