The next time you hear someone prattling on about life’s simple pleasures, remind them of one of life’s more complicated ones: eating delicious food in your home. For those of us who aren’t natural chefs — and even for the weary ones who are — that means having it delivered. As DoorDash well knows, that can at times be a devilishly difficult business.

That’s one reason why Tony Xu, DoorDash’s cofounder and current CEO, decided in 2013 to build the company’s food-delivery software on artificial intelligence. “DoorDash at the end of the day has to be a phenomenal measurement and data business,” Xu said at MB 2017. “There’s lot of information in the software world and in the physical world. From day one, our thinking was to create a business to bridge the two.”

DoorDash is a nimble intermediary between a family’s table and a chef’s kitchen. Connecting the two involves certain complexities. Restaurants, for example, often run out of dishes — easy enough to note on a menu, much harder when a fixed online menu promised a dish to a hangry household. Consumers have their own needs, such as dietary restrictions. And the drivers shuttling hot-cooked meals between them have their own concerns, like where to put their car on a street with limited parking.

In other words, if you want to make everyone happy, food delivery is an especially challenging market. “There are a lot of restaurants out there, more than 750,000 in the U.S. When you multiply that with a million more preferences that people have on top of that, that makes the problem very difficult,” Xu said. “It’s a problem more suited to the world of machine learning than the world of human computation.”

Machine learning can help DoorDash in a couple of ways. First, it can create a smarter logistics system, navigating “dashers” (the company’s preferred name for its drivers) to the right places at the right time. It can recalibrate a restaurant’s offerings when, say, a worker has called in sick. AI for DoorDash means using machine learning to smooth the process out.

Another benefit of AI is more efficient personalization. In-app or email recommendations from meal-delivery services often rely on popular restaurants nearby, but having too many customers acting on those recommendations can tax a restaurant’s supply. DoorDash began experimenting with AI to introduce personal recommendations, which gave the company a 25 percent increase in orders over users who saw the most popular listings.

DoorDash, which raised a $127 million round of financing in early 2016, says some but not all of its markets are cash-flow positive. The company currently offers delivery to 39 North American markets and, starting tomorrow, will begin introducing its service into three more — Orlando, Florida; Long Island, New York; and New Jersey — bringing the total to 42 markets.

Tackling the challenges of a logistics system capable of delivering food opens DoorDash up to the opportunity of delivering goods from other stores and merchants. “Food is definitely the hardest,” Xu said. “If we can get food right, we can get anything delivered.”

Xu envisions not just merchants changing to adapt to the new demands of consumers, but also city infrastructures evolving in coming years to respond as well. “The change will happen faster than it did in previous decades, but it will happen in years rather than months,” he said. “The city of tomorrow will be optimized for more convenience. With technologies like AI, you will see more facets of that.”