Beispiel #1
0
 private void updateSensors(Tablero t)
 {
     sensors[(int)coord.N] = t.getCell(x, y - 1);
     sensors[(int)coord.E] = t.getCell(x + 1, y);
     sensors[(int)coord.S] = t.getCell(x, y + 1);
     sensors[(int)coord.W] = t.getCell(x - 1, y);
 }
Beispiel #2
0
        private void update(Tablero t)
        {
            var coords = Enum.GetValues(typeof(coord));

            direccioAnt = direccio;
            foreach (coord c in coords)
            {
                int i = (int)c;
                memoria[i] = sensors[i];
            }

            sensors[(int)coord.N] = t.getCell(x, y - 1);
            sensors[(int)coord.E] = t.getCell(x + 1, y);
            sensors[(int)coord.S] = t.getCell(x, y + 1);
            sensors[(int)coord.W] = t.getCell(x - 1, y);
        }
Beispiel #3
0
        public Robot(int x, int y, int id, ref Tablero t)
        {
            this.x   = x;
            this.y   = y;
            this.id  = id;
            direccio = coord.N;

            sensors[(int)coord.N] = t.getCell(x, y - 1);
            sensors[(int)coord.E] = t.getCell(x + 1, y);
            sensors[(int)coord.S] = t.getCell(x, y + 1);
            sensors[(int)coord.W] = t.getCell(x - 1, y);

            var coords = Enum.GetValues(typeof(coord));

            foreach (coord c in coords)
            {
                memoria[(int)c] = 0;
            }
        }
Beispiel #4
0
        void paint()
        {
            TableroUI.Children.Clear();
            double size = (TableroUI.ActualHeight < TableroUI.ActualWidth - 100) ? TableroUI.ActualHeight / tablero.Length : (TableroUI.ActualWidth - 100) / tablero.Length;

            for (int i = 0; i < tablero.Length; i++)
            {
                for (int j = 0; j < tablero.Length; j++)
                {
                    Image image = new Image();
                    int   cell  = tablero.getCell(i, j);
                    if (cell == 0)
                    {
                        var uri = new Uri("pack://application:,,,/Textures/floor.png");
                        image.Source = new BitmapImage(uri);
                    }
                    else if (cell == 1)
                    {
                        var uri = new Uri("pack://application:,,,/Textures/wall.png");
                        image.Source = new BitmapImage(uri);
                    }
                    else if (cell == 2)
                    {
                        var uri = new Uri("pack://application:,,,/Textures/floor.png");
                        image.Source = new BitmapImage(uri);
                    }
                    image.Width  = size;
                    image.Height = image.Width;
                    image.Margin = new Thickness(image.Width * i, image.Height * j, image.Width * (i + 1), image.Height * (j + 1));
                    TableroUI.Children.Add(image);
                }
            }
            foreach (Robot r in robotList)
            {
                var   uri   = new Uri("pack://application:,,,/Textures/" + r.direccio.ToString() + "robot.png");
                Image image = new Image();
                image.Source = new BitmapImage(uri);
                image.Width  = size;
                image.Height = image.Width;
                image.Margin = new Thickness(image.Width * r.X, image.Height * r.Y, image.Width * (r.X + 1), image.Height * (r.Y + 1));
                TableroUI.Children.Add(image);
            }

            paintInternState();
        }