Welcome to Lift! The fastest way to get started building your algorithm is to take an SDK and use it as a base for your code.
If you're interested in building a client from the ground up, you'll need to have a websocket client to connect to the Lift server. A decent Chrone extension is Simple Websocket Client. When you connect, you can start a building by choosing a , entering a username of up to 20 alphanumeric characters, email address, and optionally event information. Your email address will never be sold or shared.
ws://codelift.org/v2/building
You will receive a response that looks something like this:
{"status":"connected","message":"Connected"}
{"username":"[YOUR_USERNAME]", "email":"[YOUR_EMAIL_ADDRESS]", "plan":"training_1", "event_name":"[OPTIONAL_EVENT_NAME]", "event_id":"[OPTIONAL_EVENT_ID]"}
Now is where it gets interesting! The response will be an entire building elevator system state!
{ "floors": 10, "elevators": [ { "id": 0, "floor": 0, "buttons_pressed": [] }, { "id": 1, "floor": 4, "buttons_pressed": [] } ], "requests": [], "status": "in_progress", "message": "Building In Progress" }
Let's issue a command now. Try the following:
{"commands":{"0":{"speed":1,"direction":1}}}
In the system response you should see that elevator "0" has now moved up to floor "1". You'll also notice something interesting in the "requests" object. Someone's requesting an elevator!
"requests": [ { "direction": -1, "floor": 3 } ],
You'll need to control an elevator to respond to this request, and the request will only be fulfilled if you stop an elevator on that floor, but set the direction to be the same as the request, for an entire request cycle. At this point it's probably beyond the scope of using Simple Websocket Client, though, so it's time to start building your control system! Take a look at the Building Rules to get an idea about how Buildings work and the API Reference for more detailed information.
Building Plans are essentially a blueprint for your building. They describe how many floors and elevators exist, and contain all possible passenger requests for the entire lifetime of the building. Every time you build a building from the same plan id, you will get the exact same experience. This allows for consistent scoring on a plan-by-plan basis. See the full list of plans.
There are four metrics that compose a building's score. Different buildings may care more about one metric vs another.
Only complete buildings will be eligible for leaderboards.
{ "username":"silvamerica", # {String} Required, alphanumeric length <= 20 "email":"name@domain.com", # {String} Required, valid email address "plan":"training_1", # {String} Required, must exist in plans "event_name":"pycon2015", # {String} Optional, must be active in events "event_id":"123abc", # {String} Optional, valid event identifier, # such as your registration number }
{ "floors": 10, # {Integer} Required "elevators": [ # {Array} Required, array of objects { "id": 0, # {Integer} Required "floor": 4, # {Integer} Required "buttons_pressed": [] # {Array} Required, array of Integers or [] }... ], "requests": [ # {Array} Required, array of objects or [] { "direction": -1, # {Integer} Required "floor": 3 # {Integer} Required }... ], "status": "in_progress", # {String} Required, "in_progress" "message": "Building In ...", # {String} Required, either message or "" }
{ "commands": { # {Object} Required, if no commands, use {} "0": { # {Key} Required, elevator id "direction": -1, # {Integer} Optional, values other than -1 or 1 ignored "speed": 1 # {Integer} Optional, values other than 0 or 1 ignored }... } }
Same as Building Creation response above
{ "status": "finished", # {String} Required, "finished" "message": "Building Fi ...", # {String} Required, either message or "" "visualization": "http://...",# {String} Required, url to visualize your building "score": 6122, # {String} Required "event_code": "61ABF2" # {String} Optional, present at the end of a # simulation for buildings eligible for a prize # (while supplies last) }