In this challenge, teams compete to help Lyft earn more riders in the city of Chicago. The challenge simulates an alternate reality where there are no Lyft cars (or any other ridesharing services), only taxis... all of which are operated by the infamous Bauer Taxi Service.
Using the resources provided, work with your team to analyze data on rides around the city and form a competitive pricing model to earn business from citizens who normally ride taxis. You can change the price of Lyft rides as well as designate community areas in Chicago as "Power Zones." In power zones, Lyft pays drivers extra to increase the supply of available rides. When you set a power zone, riders may be willing to pay more if a Lyft will arrive faster than a taxi. Be careful thoughl, as power zones become more costly the more rides they convert.
There will be multiple checkpoints in simulation time where we check up on all the teams' progress and see which teams are earning the most revenue. Each team exists in its own separate, simulated universe.
On first use, install the dependencies.
$ npm i
If you are using Firebase as a backend for the game, add a config.js
file in the /server
folder with the relevant keys like so:
// In: /server/config.js
module.exports = {
apiKey: "secretKey",
authDomain: "projectId.firebaseapp.com",
databaseURL: "https://projectId.firebaseio.com",
projectId: "projectId",
storageBucket: "projectId.appspot.com",
messagingSenderId: "secretNumber"
}
Set a game key. This key may be shared publicly. Participants will use it to see the results.
export GAME_KEY=lyft_game
Set a secret key to protect administrative operations. Only share this key with other challenge administrators.
export ADMIN_SECRET=something_secret
Start the test server.
node server/main.js
To move the game to the next defined checkpoint, make a POST request to the admin /checkpoint
endpoint with the secret admin key.
POST https://workspacename-username.c9users.io/checkpoint/?admin=ADMIN_SECRET
Then, you can simulate the trips from the last checkpoint using the admin /simulate
endpoint. There is a helper script to save these results. Run the script with the date range to simulate over and it will pull and store the simulated data.
node server/simulate.js 10/1/2017 10/8/2017
If you start the server from a Cloud9 workspace, the API will be available at:
- https://
workspacename
-username
.c9users.io - For the primary Cloud9 workspace, the API runs here.
You can use the primary project workspace to run the API, but do not do any development work there. To edit samples, clone the repository into another workspace.
Run any client scripts in a different terminal while the server is up. Ensure requests are made to the correct API URL.
Set your secret team key.
export TEAM_SECRET=your_team
Save and run your script.
python main.py
Set your secret team key.
export TEAM_SECRET=your_team
Save, compile, and run your script.
javac -cp ".:lib/*" Main.java
java -cp ".:lib/*" Main
Teams play this challenge with a RESTful API, allowing analysts to work in any programming language. Each team will receive a secret API key to use when making requests and accessing other challenge services. Keep this key secret, otherwise other teams may be able to observe or manipulate your strategy.
Note: When using the test server, you can make up any team key you want or simulate different teams playing by using multiple keys.
There are five public endpoints:
/trips
: Search for all valid trip records between two date/time points./count
: Count the total number of valid trip records between two date/time points./time
: Get the current time in the simulation./pricing
: Update your team's pricing model for the current simulation checkpoint./zones
: Set community areas in the city as power zones for the current simulation checkpoint.
And two administrative endpoints:
/checkpoint
: Move the simulation to the next checkpoint date./simulate
: Simulate rides won and revenue earned for teams between two date/time points.
See the Client Instructions section for sample starter code.
Search for all valid trip records between two date/time points.
/trips
team
[required]: secret key for your teamstart
[required]: date/time string to start search atend
[required]: date/time string to end search atlimit
: maximum number of results to returnoffset
: only return search results past this index
You can fine tune your search query with a SQL WHERE clause instead of start
and end
.
team
[required]: secret key for your teamwhere
[required]: SQL WHERE clause
When querying across dates and times, wrap the values with curly braces. This applies to the columns trip_start_timestamp
and trip_end_timestamp
.
{
"where": "(trip_start_timestamp BETWEEN {9/10/2017 2:00 PM} AND {9/10/2017 3:00 PM}) AND (trip_total BETWEEN 10 AND 20)"
}
{
success: true,
length: 750,
response: {
{
"company": "Bauer Taxi Service",
"dropoff_census_tract": "17031081300",
"dropoff_centroid_latitude": "41.898331794",
"dropoff_centroid_location": {
"type": "Point",
"coordinates": [
-87.6207628651,
41.8983317935
]
},
"dropoff_centroid_longitude": "-87.620762865",
"dropoff_community_area": "8",
"extras": "1",
"fare": "7.85",
"payment_type": "Cash",
"pickup_census_tract": "17031320600",
"pickup_centroid_latitude": "41.870607372",
"pickup_centroid_location": {
"type": "Point",
"coordinates": [
-87.6221729369,
41.8706073724
]
},
"pickup_centroid_longitude": "-87.622172937",
"pickup_community_area": "32",
"taxi_id": "e3490f01724ad4a617a42371dab38fcbcb4b7f6418d451b7c8392135a040d2f63591def795e0ec2564c589bae2d2169b0d778204659910d80932d3b69eff4eda",
"tips": "0",
"tolls": "0",
"trip_end_timestamp": "2014-09-10T12:15:00",
"trip_id": "8ba13d43087a7d5279b788c7d6e89b765ea5db82",
"trip_miles": "21",
"trip_seconds": "540",
"trip_start_timestamp": "2014-09-10T12:00:00",
"trip_total": "8.85",
"entry_idx": 0
},
...
}
}
- You must include your team key in the request parameters
- You cannot search rides past the current time in the simulation
Count the total number of valid trip records between two date/time points.
/count
team
[required]: secret key for your teamstart
[required]: date/time string to start search atend
[required]: date/time string to end search at
{
success: true,
count: 750
}
- You must include your team key in the request parameters
- You cannot search rides past the current time in the simulation
Get the current time in the simulation.
/time
- None
{
"sucess": true,
"time": 1507420800000,
"message": "The simulation is not over, the time is 10/8/2017."
}
Update your team's pricing model for the current simulation checkpoint.
/pricing
team
[required]: secret key for your teambase
: base cost of a ride in dollarspickup
: cost of picking up a rider in dollarsper_mile
: cost per mile driven in dollarsper_minute
: cost per minute driven in dollars
{
success: true,
team: "YOUR_SECRET_TEAM_KEY",
pricing: {
{
base: 3.00,
pickup: 1.70,
per_mile: 0.90,
per_minute: 0.90
}
...
}
}
- You must include your team key in the request parameters
- Fields left blank in the pricing model will be given values of 0: it is possible to lose money by giving way free rides!
- Extra decimal places will be rounded when setting price
- This POST request responds with your team's updated pricing model: double-check to make sure it is structured the way you want
- You can only edit your pricing model for the current checkpoint, not past or future ones
Set community areas in the city as power zones for the current simulation checkpoint.
/zones
team
[required]: secret key for your teamzones
: comma-separated list of community area numbers to set as power zones
{
success: true,
team: "YOUR_SECRET_TEAM_KEY",
zones: {
{
"32": true,
"76": true
}
...
}
}
- You must include your team key in the request parameters
This endpoint is only for challenge administrators. Move the simulation to the next checkpoint date.
/checkpoint
admin
[required]: secret admin key
{
"status": true,
"time": 1507420800000,
"message": "The simulation is not over, the time is 10/8/2017."
}
Simulate rides won and revenue earned for teams between two date/time points.
/simulate
admin
[required]: secret admin keyteams
[required]: comma-separated list of team keysstart
[required]: date/time string to start search atend
[required]: date/time string to end search at
{
"success": true,
"data": {
"team1": {
"trips": {
"lyft": 0,
"taxi": 31143
},
"revenue": {
"lyft": "0.00",
"taxi": "320012.90"
}
}
...
}
}