Created
April 26, 2024 09:00
-
-
Save Untrusted-Game/f3c0d7330531fcb8440c346959bf0771 to your computer and use it in GitHub Desktop.
Solution to level 3 in Untrusted: http://alex.nisnevich.com/untrusted/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************ | |
* validationEngaged.js * | |
************************ | |
* | |
* They're really on to us now! The validateLevel function | |
* has been activated to enforce constraints on what you can | |
* do. In this case, you're not allowed to remove any blocks. | |
* | |
* They're doing all they can to keep you here. But you | |
* can still outsmart them. | |
*/ | |
function startLevel(map) { | |
map.placePlayer(map.getWidth()-7, map.getHeight()-5); | |
for (var y = 10; y <= map.getHeight() - 3; y++) { | |
map.placeObject(2, y, 'block'); | |
map.placeObject(map.getWidth() - 5, y, 'block'); | |
} | |
for (var x = 5; x <= map.getWidth() - 5; x++) { | |
map.placeObject(x, 10, 'block'); | |
map.placeObject(x, map.getHeight() - 3, 'block'); | |
} | |
map.placeObject(7, 5, 'exit'); | |
} | |
function validateLevel(map) { | |
var numBlocks = 2 * (map.getHeight()-13) + 2 * (map.getWidth()-10); | |
map.validateAtLeastXObjects(numBlocks, 'block'); | |
map.validateExactlyXManyObjects(1, 'exit'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment