To be frank, I was a little surprised that this was a draw per the computer from move one all the way through to your stalemate. You did not make a mistake. My initial thought was to play the black king to g8-f8-e7, but the problem is that white can keep the K out of e7 with his own king, or keep you on the back rank, or force you to make pawn moves that are not good for you.
The biggest problem is that you do have a doubled pawn, and thus, cannot make a passed pawn. His three pawns very efficiently hold up your four pawns. Simply moving the Pf6 to e6, and the computer immediately registers -153!, a clear win.
There are no hard-and-fast rules about pawn endings as they are notorious for being very specific, and requiring exact calculation, but here are some basic pawn endgame principles.
- Centralize your king as quickly as possible.
- Try to create a passed pawn, especially an outside passed pawn.
- Watch out for the opposition (when the other guy has to give way, and move aside).
- Pawn endgames with an extra pawn and pawns on both sides are usually won. You create a passed pawn on the side with the extra pawn, then assuming you cannot queen it outright, at the right moment, abandon it and run to the other side and take all the opponent's remaining pawns.
- Watch out for the rook pawn. Assuming that the pawn cannot queen outright, the defender can draw if he gets in front of it, regardless of opposition. If you are in front of it, let's say with a white h-pawn, he can draw if he gets to f8 even.
Lastly, a great K+P vs. K almost rule (there are a few exceptions) is that you need to be in front of the pawn and have opposition to win. See the second diagram.
[FEN "8/8/8/2k5/6KP/8/8/8 b - - 0 0"]
1...Kd6 2.Kg5 Ke7 3.Kg6 Kf8 4.Kh7 (4.h5 Kg8 5.h6 Kh8 6.h7=) Kf7 5.h5 Kf8 6.h6 Kf7 7.Kh8 Kf8 8.h7 Kf7= {Stalemate.}
Here is rule 6: Per the rule, white to move draws, but black to move loses.
[FEN "8/4k3/8/4K3/4P3/8/8/8 b - - 0 1"]
1...Ke8 2.Ke6! {keeping the opposition} Kd8 3.Kf7 Kd7 4.e5+- {and the pawn cannot be stopped}