Contrary to legend, rangers have found it possible to infuse brainpower in summer tourists in Yosemite National Park.

The numbers this week show that bear incidents are down 99 percent in 20 years at Yosemite, from a peak of 1,500 in 1997 to a low this year of three. In 2018, they verified only 22 incidents for the year.

The consensus is that new rules, enforcement and wildlife education have largely solved what was an epidemic.

Park rangers now require that food and garbage be kept within arm’s reach or placed in bear-proof lockers and garbage cans, and in bear-proof canisters in wilderness. They will write tickets to violators, such as a visitor who leaves an old fast-food bag on the front seat of their car.

The next phase is getting drivers to slow down, and the U.S. Park Police in Yosemite are making headway there, too. An officer in Yosemite Valley showed me how the park police are using radar to write tickets and try to reduce speed and wildlife strikes.

In the past 25 years, vehicles have hit about 300 bears, according to Caitlin Lee-Roney, a park wildlife specialist. In 2015 in Yosemite, cars hit 38 bears and then 28 the next year. Crews then posted signs with the outline of a red bear and the words “Speeding Kills Bears” at sites along roads where bears have been hit. In 2018, bear strikes were down by half.

The biggest problem, according to the folks at Yosemite headquarters, is that people often bring their city driving habits into the park. In California, 93 percent of residents live in cities, drive too fast in the park and don’t anticipate wildlife crossing the road.

The Yosemite Conservancy spent about $70,000 to outfit food-raiding bears with GPS collars. Wildlife specialists now track those bears. In addition, the website, http://keepbearswild.org/bear-tracker, provides a map that shows sites of encounters.

The best estimates show that about 400 bears live in the park. Statewide, the number of bears has increased from about 4,000 to 40,000 in the past 35 years, according to the Department of Fish and Wildlife.

Tom Stienstra is The San Francisco Chronicle’s outdoors writer. Email: tstienstra@sfchronicle.com Twitter: @StienstraTom