Giter Club home page Giter Club logo

untrusted's Introduction

Untrusted —or— the Continuing Adventures of Dr. Eval is an exciting Meta-JavaScript Adventure Game wherein you guide the dashing, steadfast Dr. Eval through a mysterious MACHINE CONTINUUM, wherein, using only his trusty computer and the TURING-COMPLETE power of JavaScript, he must literally ALTER HIS REALITY in order to find his freedom! You must literally edit and re-execute the very JavaScript running the game in your browser to save Dr. Eval from this dark and confusing reality!

Overview

The game presents you with a roguelike-like playing environment and a console window with the JavaScript code generating each level. As loaded, each level is unbeatable, and most of the JavaScript is blocked from editing. The challenge is to open a path to the next level using only the limited tools left open to you.

Development

Run

make

to merge the JavaScript files into scripts/build/untrusted.js (and enables debug features).

make release

merges and minifies the JavaScript files into scripts/build/untrusted.min.js (and disables debug features).

To run the game locally, you need to set up a local server to serve index.html (this step is necessary due to Access-Control-Allow-Origin restrictions).

First install http-server if you haven't already:

npm install http-server

Then run:

make runlocal

Build your own mod in the mods directory:

make mod=example_mod

Contributing Levels

To add a new level, create a jsx file in /levels/bonus and add the level filename to the bonusLevels array in game.js.

If you are adding any new commands that the player can use, make sure to add them to reference.js.

The .jsx file format

jsx files are like regular JavaScript files, but have some additional syntax:

  • #BEGIN_EDITABLE# and #END_EDITABLE# surround editable lines
  • #{# and #}# wrap editable sections (parts of lines)
  • #BEGIN_PROPERTIES# and #END_PROPERTIES# surround the properties object at the start of the file. Available properties include:
    • commandsIntroduced: array of new commands introduced in the level (see reference.js)
    • mapProperties: optionally contains any of the following:
      • allowOverwrite: if true, placed static objects can be overwritten by other objects
      • keyDelay: specifies the lag, in milliseconds, between player keystrokes (default: 0)
      • refreshRate: the refresh rate of the level, in milliseconds (required for dynamic objects with interval properties to work correctly)
      • showDrawingCanvas: if true, the drawing canvas overlay is displayed
      • showDummyDom: if true, a dummy DOM will be displayed instead of the regular map
    • music: name of the background track for the level (see sound.js)
    • startingMessage: message displayed at the bottom of the screen when the level starts (if any)
    • version: increase the level version whenever you update a level
    • nextBonusLevel: load another level automatically when this one is solved
  • #START_OF_START_LEVEL# and #END_OF_START_LEVEL# should be the first and last line of the startLevel method, respectively

Adding music

To add a new background music track, add an MP3 file (that you have permission to use) to the /music and add a new entry to the tracks array in sound.js.

Acknowledgements

Untrusted is a game by Alex Nisnevich and Greg Shuflin.

We'd like to thank:

  • Dmitry Mazin for design assistance and for the implementation of multiline editing
  • Jordan Arnesen for playtesting and design of lvl17
  • Natasha Hull-Richter for extensive playtesting and assistance in level design
  • Alex Bolotov, Colin Curtin, Conrad Irwin, Devin C-R, Eugene Evans, Gilbert Hsyu, Jacob Nisnevich, James Silvey, Jason Jiang, Jimmy Hack, Philip Shao, Ryan Fitzgerald, Stephen Liu, Yayoi Ukai, and Yuval Gnessin for playtesting and feedback
  • Ondřej Žára for his rot.js library
  • Marijn Haverbeke for his CodeMirror library
  • Brian Harvey for allowing us to use his likeness in lvl19

Soundtrack

You can listen to the full soundtrack here.

The music that appears in Untrusted, in order, is:

License

This work is dual-licensed.

  • Untrusted and the Untrusted soundtrack are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License (CC-BY-NC-SA 3.0). In other words, you are free to use and modify Untrusted for non-commercial purposes, provided that you credit us and your work is also licensed under CC-BY-NC-SA.
  • Additionally, the Untrusted code without the soundtrack is licenced under a commercial license. This means that you are able to use Untrusted for commercial purposes under some conditions, provided that you do not use any of the music. Please contact us for details.

untrusted's People

Contributors

agamemnus avatar aharmsen avatar alexnisnevich avatar alexnsolo avatar alexsclim avatar amahdy avatar caitsith2 avatar camel-lot avatar dmazin avatar extrajordanary avatar g1-dt avatar giacgbj avatar ishanv avatar justblackbird avatar kedilayanaveen10 avatar lakitas avatar luka-zitnik avatar mdunisch avatar mike-perdide avatar mikespook avatar mrtank avatar pavel-kolesnikov avatar pcat0 avatar phelanharris avatar phoeagon avatar pppery avatar reneeslamka avatar shmulim avatar swphantom avatar xadillax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

untrusted's Issues

Better API methods for lvl13

getAdjacentEmptyCells as an api method seems less useful than just a getAdjacentCells, and letting the player filter by getObjectTypeAt, since as documented things like barriers are technically not empty, but passable, forcing me to have to code some special logic in case I'm on the last step in something like an acyclic depth-first search.
Another api method that would make code less hacky is to give a function for "object.positionAtDirection(direction)" which returns an x,y pair corresponding to the box at the specified direction. Much easier than the alternative of "testing" an adjacent square, which is tedious vector mapping.

[Feedback from Philip]

Issues with validateCallback

Feedback from Gilbert:

If I place an object that generates an exit after map generation, I can use the exit to get to the next level even though the map validation complains at me.

Bug with multiline editing (in boss fight?)

another interesting thing! just moved ahead to level 21, but then went back to 20 to look at some code, and because it now reloads whatever your last code was it did that just fine... but because the original code only had 1 black editable line it loaded the rest of my code in the red zone so it's no longer editable... - Jordan

Level versioning system

Once we push live the solution-saving feature, we need to be able to override saved levels when we modify the level itself. A simple versioning system (clear localStorage for a given level if the current level file's version differs from the version saved in localStorage) ought to suffice.

_executingUserCode local var in Game

Dangerous functions (e.g. moveToNextLevel()) should not be able to execute while user code is being run (either on level execution or on callback).

Music

The bad news: CC-ND only permits you to use up to 30 sec samples of music as "fair use". We need to ask permission to use all of the CC-ND songs we have right now.

The good news: There are >18,000 electronic CC songs available at http://freemusicarchive.org/genre/Electronic/?sort=track_interest and most of them are not ND. We can look through it and see what works.

And I think Dmitry's working on music too.

Ideas

Ideas for the Game in General

  • API Reference - constantly growing
  • Decide what errors are "exploitable" and which are just errors (example: river.jsx)
  • Make validators execute on every frame + make this an exploitable mechanic

Ideas for Levels

  • Introduce a simplified sandboxed "DOM" at the very end of the game
  • Make monster.js actually interesting (i.e. make game entities objects with a hierarchy)
  • Puzzle where you have to use == vs ===
  • "Interconnected maze" where you can just call a limited set of functions
  • "Robot Friend" mechanic: a level where the player cannot move, but there is a robot, so you have to come up with an algorithm for the robot to move through the maze
  • Level where the game suddenly becomes side-scrolling - need to implement jump to complete it

More Minor Things

  • "Meta" inventory distinct from actual item inventory (per-level)
  • Add something to editor object to keep track of last good executed version of code and swap it out whenever there is a successful execution and use it to replace what's in the editor on a syntax error. Also, have it flash static for a couple of seconds

Making tricky levels more fun

This is really three issues in one:

  • there's no protection against infinite loops happening, and when they do, the whole page freezes
  • when syntax errors occur, no line numbers are given to the player
  • Enter doesn't work, which makes adding lines to the middle of a 30-line block very tedious

General code cleanup

This is just a note to myself to at some point go through the code and clean up formatting and perhaps stylistic things

Restriction against eval doesn't protect against new Function()

First off, I really enjoyed your game!

There is protection against the input block containing eval, but it's not that hard to work around. I found it was as simple as calling new Function on some string to run, but there are some other ways I found by just googling "eval without eval."

For example, on level 14 (crispsContest.js), the user-defined string can be defined like:

player.removeItem(''+new Function(prompt()).apply(map)+'');

and then at the textbox you just paste in the code:

this.placeObject(20, 10, 'theAlgorithm');
return 'greenKey';

which is too long to put by itself in the user-entered code area.

(As another issue, maybe validation on level 14 should include counts on theAlgorithm?)

(As another issue, maybe you want to forbid prompt and confirm? Keeping alert is nice for debugging without resorting to the browser inspector.)

Bug with drones over exit

Feedback from Yuval:

found a bug on level 10 (I've been taking breaks between levels lol), there was a drone on top of the goal but I just rushed the goal and the screen said I was killed but the goal still triggered and I moved on to the next level

Level: DOM Manipulation

well, we could do something like
overlay (real?) HTML elements over the game area canvas
and then present as the sekeleton code
just html
with a script tag
so there's the clue that DOM manipulation is what needs to happen
or maybe
for the last level
we abandon the roguelike environment altogether
and it's just the player
moving around on a html page
I'm thinking, like, build an obvious parody of facebook or google or some other popular website
with a lot of complexity in the dom
like, visual complexity, lots of differnet things happening on the page
and you have to move through it like a maze

Organization of levels

Chapter One. Prison Break

  • blocks.jsx
  • levelThree.jsx
  • theReturnOfBlocks.jsx
  • multiplicity.jsx
  • traps.jsx
  • introduction to monsters - drones 101!
  • colors.jsx

Chapter Two. Search for the Artifacts

  • forest.jsx
  • "Interconnected maze" where you can just call a limited set of functions
  • monster.jsx
    • Idea: Multiple groups of monsters where your only control over them is who they chase. Goal is to get them to chase each other in such a way that a path to the exit opens up.
  • Monsters with weapons
  • river.jsx
  • Introduction to robot
  • Simple navigation with robot
  • robot.jsx - the dreaded maze level
  • some sort of level where you give the three Artifacts to the Mysterious Benefactor

Chapter Three. Betrayal

  • backToTheRiver.jsx (having to throw a certain exception)
  • Platformer level
    • Idea: Make the player have to implement jump()
  • Teleporters and canvas manipulation - it's safe to just modify
  • DOM manipulation
  • FINAL BOSS FIGHT - your own editor turns against you!
    - sometimes lines turn red, and when they turn fully red they erase

Fin

  • Scrolling credits level?

Fix issues with bullets in boss fight

  • Bullets should pass through each other
  • Bullets shouldn't be able to destroy the Algorithm
  • Should bullets be able to pass through blocks?
  • Also, check victory conditions

Better infinite-loop prevention

Idea: maybe do a separate preprocessing step that converts Allman style indentation to K&R style indentation.

[Feedback from Philip]

Level 16_pointers won't load

untrusted

I tried to solve the previous level in a way which allowed me to walk out with theAlgorithm, and it crashed on trying to load the next one. I tried reloading a couple of times, and discovered my character could still move, so I moved over the exit again and it incremented again. Doesn't look like it goes beyond that, but regardless, I can't seem to progress the level any further. I've tried refreshing the page and redoing level 15 as well as loading 16 separately and they all break with the same error.

I'm playing on Chrome Version 31.0.1650.63 m on Windows 8.1.

map.createFromGrid()

Should be fun to write, and will simplify the code for Crisp's Contest a fair bit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.