In 1499, Ludovico il Moro was overthrown. Leonardo left Milan with his servant Salai and a friend, Luca Pacioli, who was a mathematician. They went to Venice. Leonardo worked as a military architect and engineer. Because Venice is a city on many islands, Leonardo tried to think of ways to defend the city from a naval attack.