Oliver Perez allowed the game-winning home run to Pirates outfielder Starling Marte. (Katherine Frey/The Washington Post)

Dusty Baker helped blow a game for his Washington Nationals on Sunday in the 18th inning. Not only did he admit it, he volunteered the information. With two outs and nobody on base in the top of the inning, Pittsburgh Pirates all-star Starling Marte came to bat. On deck, because Pittsburgh had used all its pinch hitters, was pitcher Jon Niese, who has never hit a home run in 346 major league at-bats. Marte should have been walked intentionally. The Pirates would have been trapped — forced to let Niese (career average .150) hit for himself.

“I was aware of the situation. I just said to [pitching coach] Mike [Maddux], ‘We got Niese on deck,’ ” the Nationals’ manager said. “Before I could put the four fingers up [to signal to catcher Wilson Ramos for an intentional walk], Marte hit the first pitch out [of the ballpark].”

Marte’s home run gave the Pirates a 2-1 win in the longest regular season game since baseball returned to Washington, as well as one of the harder defeats to swallow. The Nationals’ bench coach, pitching coach and even reliever Oliver Perez can lose sleep, if they wish. They could have noticed. “It’s my job to know the situation and make a difficult pitch [to Marte],” Perez said. “I put it in his red-hot zone — my mistake.”

But, as he should, Baker said, “It falls on me. I take full responsibility. I’ve got a scorecard next to me.” Later, he said, “There were so many names scratched out and double switches [on that card].”

Baseball torments those who play it on a brutally regular basis. Sometimes those blows are like a bat over the head. Sometimes they are subtle or even have a cumulative effect over many months. One of the game’s many tests is how players and teams respond to that endless aggravation — all of the grand plans that must be nixed as well as all the individual plays gone wrong that lose games.

Now, with a day off before a three-game series at home against the Dodgers, who swept them in June in Los Angeles, the Nationals simply face another one of those tests of resilience and forgetfulness. But they have been facing them since last winter.

What happens when the manager you want turns you down? The Nats wanted Bud Black but had a fuss during contract negotiations and turned to Baker. That has had double unexpected positive benefits.

First, Baker’s temperament has suited the team — loosened it up and added confidence.

Second, because Baker, not Black, got the job, two of Dusty’s baseball friends — Maddux, perhaps the most respected pitching coach in the game, and Davey Lopes, a top instructor of base stealers — also joined the Nats. The pitching staff, a flop in 2015, leads the majors in ERA (3.18) and has given up only seven runs in its past six games. The Nats have 57 stolen bases, the same total as in 2015, but with 69 games left in the season.

What happens when almost every free agent you pursue refuses to come to town until you grasp desperately at third and fourth choices to fill empty spots? Sunday was full of examples.

The pitcher who worked a scoreless 10th inning was Shawn Kelley, who has had two Tommy John surgeries; the Nats had to sign him to a risky three-year deal, knowing he would always be one pitch from a career-ending injury, because the reliever they really made a run at (Darren O’Day) re-signed with the Orioles. They were desperate to get somebody with passable credentials. Kelley (2.60 ERA) has been stalwart.

Daniel Murphy, the second baseman the Nationals signed last winter only because Ben Zobrist and Brandon Phillips rejected them, hit a home run with Washington down to its last strike in the ninth inning to tie the game at 1. Murphy then pumped his fists, aroused the crowd and took a curtain call — all part of his unexpected emergence as gritty team leader.

What happens when you have two players with trade value and you deal them both for players who flop? The Nats dealt reliever Drew Storen for exactly the leadoff man and fleet center fielder they wanted — Ben Revere. Revere has been the season’s biggest bust so far, hitting .221 after missing a month to injury. For Yunel Escobar, who hit .314 last year, they got Trevor Gott to be a hard-throwing late-inning reliever. Instead he has been injured and ineffective and is at Class AAA. (Escobar, now with the Angels, is batting .320.)

What happens when you have two of the hottest young prospects in baseball, but the All-Star Game comes and goes and they have barely played? Trea Turner has only gotten 18 at-bats and on Sunday made a base-running blunder, getting thrown out trying to stretch a single into a double to lead off the 17th inning. Lucas Giolito has pitched only eight innings and, in effect, will be replaced Tuesday by another prospect with similar numbers to his in the minors — Reynaldo Lopez, who will make his debut start.

What do you do when you have the reigning MVP of your league, but he goes into a three-month slump and is hitting .252 in mid-July? Bryce Harper went 1 for 6 on Sunday.

If you’re the Nats, you’re still in first place by six games in the NL East. When everything goes according to plan and you win, that’s good. But when almost every plan fails, yet you win anyway, that can turn out even better. There is inspiration in the gathering sense of surprise. There’s less pressure when expectations are deflated. Right now, the Nats are a team of this second type. They are winning with Plans B and C because, in almost every case, their Plan A for 2016 blew up.

Every couple of years, at least one of the teams that makes it to a league championship series says, “Things didn’t go the way we figured at all. How did we get here?” That’s when clubs talk about destiny and magic or make up phrases like “You Gotta Believe.” They talk about how they needed all 25 men — and usually more — to get the job done. They brag about all the tough defeats and injuries they shrugged off with key bench contributions. Why, they even ignore defeats inflicted, in part, by their own manager.

Are the Nationals, who have been so resilient so far, one of those teams? You never have to wait long for the next examination — this time, here come the Dodgers.

For more by Thomas Boswell, visit washingtonpost.com/boswell.