Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "description": [
- "<h1>La caminata alrededor del lago</h1>",
- "<p> Ya alguna vez hicimos un ejercicio donde el Robot caminaba al rededor de un lago. ",
- " solo que en esta ocasión, la forma del lago es compleja y Reeborg lleva una banana ",
- " dentro de si. El robot debe colocar la banana en el sitio de inicio (que va a cambiar ",
- " de ejecución en ejecución) y empezar a caminar alrededor del lago hasta que encuentre la ",
- " banana nuevamente. OJO: <b>Reeborg nunca comienza en el mismo sitio, sin embargo, tampoco ",
- " iniciará en un sitio que tenga un obstáculo frente a él. </b>.</p>",
- "DIFFICULTY5",
- ""
- ],
- "onload": [
- "var _tiles, i, j, choice, x, y, name, backgrounds, obstacles;",
- "var len, path, pos_0, pos_1, orientation, ",
- " x0, y0, x1, y1; ",
- "",
- "backgrounds = ['water', 'gravel'];",
- "obstacles = ['fence_double', 'fence_vertical', 'fence_left', 'fence_right'];",
- "",
- "_tiles = {};",
- "_tiles['path1'] = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1],",
- " [7, 1], [8, 1], [8, 2], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3],",
- " [3, 3], [3, 4], [3, 5], [3, 6], [4, 6], [5, 6], [6, 6], [7, 6],",
- " [8, 6], [9, 6], [10, 6], [10, 5], [10, 4], [10, 3], [11, 3], [12, 3],",
- " [13, 3], [13, 4], [13, 5], [13, 6], [13, 7], [13, 8], [13, 9], [12, 9],",
- " [11, 9], [10, 9], [9, 9], [9, 8], [8, 8], [7, 8], [6, 8], [5, 8], [5, 9],",
- " [5, 10], [4, 10], [3, 10], [2, 10], [1, 10], [1, 9], [1, 8], [1, 7],",
- " [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1]];",
- "_tiles['gravel1'] = _tiles['path1'];",
- "",
- "_tiles['water1'] = [[2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [2, 3],",
- " [2, 4], [11, 4], [12, 4], [2, 5], [11, 5], [12, 5], [2, 6], [11, 6], [12, 6],",
- " [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7], [8, 7], [9, 7], [10, 7], [11, 7],",
- " [12, 7], [2, 8], [3, 8], [4, 8], [10, 8], [11, 8], [12, 8], [2, 9], [3, 9], [4, 9]];",
- " ",
- "_tiles['fence_vertical1'] = [[4, 5], [6, 10], [6, 11], [8, 10],",
- " [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [14, 3], [14, 4],",
- " [14, 5], [14, 6], [14, 7], [14, 8], [14, 9], [14, 10]];",
- "",
- "_tiles['fence_double1'] = [[10, 2], [11, 2], [12, 2], [13, 2],",
- " [5, 4], [6, 4], [7, 4], [8, 4], [5, 5], [6, 5], [7, 5], [8, 5],",
- " [7, 9], [9, 10], [10, 10], [11, 10], [12, 10], [13, 10],",
- " [2, 11], [3, 11], [4, 11], [5, 11]];",
- "",
- "_tiles['fence_left1'] = [[14, 2], [9, 4], [9, 5], [8, 9], [14, 10], [6, 11]];",
- "_tiles['fence_right1'] = [[9, 2], [4, 4], [4, 5], [6, 9], [8, 10], [1, 11]];",
- "",
- "",
- "_tiles['path2'] = [[1, 1], [2, 1], [3, 1], [4, 1], [4, 2],",
- " [4, 3], [5, 3], [6, 3], [7, 3], [7, 4], [7, 5], [7, 6],",
- " [8, 6], [9, 6], [10, 6], [11, 6], [12, 6], [13, 6], [13, 7],",
- " [13, 8], [13, 9], [13, 10], [12, 10], [11, 10], [10, 10],",
- " [10, 9], [9, 9], [8, 9], [8, 10], [7, 10], [6, 10], [5, 10],",
- " [4, 10], [3, 10], [2, 10], [1, 10], [1, 9], [1, 8], [2, 8],",
- " [3, 8], [4, 8], [4, 7], [4, 6], [3, 6], [2, 6], [1, 6], [1, 5],",
- " [1, 4], [1, 3], [1, 2], [1, 1]];",
- "_tiles['gravel2'] = _tiles['path2'];",
- "",
- "_tiles['water2'] = [[2, 2], [3, 2], [2, 3], [3, 3],",
- " [2, 4], [3, 4], [4, 4], [5, 4], [6, 4],",
- " [2, 5], [3, 5], [4, 5], [5, 5], [6, 5],",
- " [5, 6], [6, 6],",
- " [5, 7], [6, 7], [7, 7], [8, 7], [9, 7], [10, 7], [11, 7], [12, 7],",
- " [5, 8], [6, 8], [7, 8], [8, 8], [9, 8], [10, 8], [11, 8], [12, 8],",
- " [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [11, 9], [12, 9]]; ",
- " ",
- "_tiles['fence_vertical2'] = [[5, 1], [5, 2], [8, 3], [8, 4], [8, 5],",
- " [14, 6], [14, 7], [14, 8], [14, 9], [14, 10], [14, 11],",
- " [9, 10], [9, 11]];",
- "",
- "_tiles['fence_double2'] = [[6, 2], [7, 2], ",
- " [9, 5], [10, 5], [11, 5], [12, 5], [13, 5],",
- " [2, 7], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], ",
- " [8, 11], [9, 11], [10, 11], [11, 11], [12, 11], [13, 11]];",
- "",
- "_tiles['fence_left2'] = [[8, 2], [14, 5], [3, 7], [14, 11]];",
- "_tiles['fence_right2'] = [[5, 2], [8, 5], [1, 7], [1, 11]];",
- "",
- "",
- "RUR.fill_background('grass');",
- "RUR.add_decorative_object('tulip', 14,12);",
- "RUR.add_decorative_object('daisy', 10,1);",
- "RUR.add_decorative_object('dandelion', 14,1);",
- "",
- "choice = RUR.randint(1,2).toString();",
- "",
- "if (choice == '1') {",
- " RUR.add_decorative_object('tulip', 7,10);",
- " RUR.add_decorative_object('daisy', 4,5);",
- " RUR.add_decorative_object('daisy', 2,12);",
- "} else {",
- " RUR.add_decorative_object('daisy', 2,12);",
- " RUR.add_decorative_object('tulip', 10,4);",
- " RUR.add_decorative_object('tulip', 6,1);",
- "}",
- "",
- "for (j=0; j<backgrounds.length; j++){",
- " name = backgrounds[j];",
- " for (i=0; i<_tiles[name+choice].length; i++) {",
- " x = _tiles[name+choice][i][0];",
- " y = _tiles[name+choice][i][1];",
- " RUR.add_background_tile(name, x, y);",
- " } ",
- "}",
- "",
- "for (j=0; j<obstacles.length; j++){",
- " name = obstacles[j];",
- " for (i=0; i<_tiles[name+choice].length; i++) {",
- " x = _tiles[name+choice][i][0];",
- " y = _tiles[name+choice][i][1];",
- " RUR.add_obstacle(name, x, y);",
- " } ",
- "}",
- "",
- "path = _tiles['path'+choice];",
- "len = path.length;",
- "",
- "i = RUR.randint(0, len-2);",
- "pos_0 = path[i];",
- "x0 = pos_0[0];",
- "y0 = pos_0[1];",
- "pos_1 = path[i+1];",
- "x1 = pos_1[0];",
- "y1 = pos_1[1];",
- "",
- "if (x0 == x1) {",
- " if (y1 == y0 + 1) {",
- " orientation= 'n';",
- " } else {",
- " orientation = 's';",
- " }",
- "} else {",
- " if (x1 == x0 + 1) {",
- " orientation = 'e';",
- " } else {",
- " orientation = 'w';",
- " }",
- "}",
- "r = new UsedRobot(x0, y0, orientation);",
- "RUR.give_object_to_robot('banana', 1);",
- "",
- "RUR.public.path = path.slice(i, len-1).concat(path.slice(0, i+1));"
- ],
- "post": [
- "RUR.check_path(RUR.public['path'],",
- " {'failure':\"Reeborg no siguió la ruta dada!.\", ",
- " 'success': 'Muy bien hecho!',",
- " 'show_path': 'true', 'color': 'white'})"
- ],
- "small_tiles": false,
- "rows": 12,
- "cols": 14
- }
Advertisement
Add Comment
Please, Sign In to add comment