Give me some thoughts how to implement undo/redo functionality - like we have in text editors. What algorithms should I use and what I may read. thanks.
Adding to the discussion, I wrote a blog post on how to implement the UNDO and REDO based on thinking about what is intuitive: http://adamkulidjian.com/undo-and-redo.html
There are several ways to do this, but you could start looking at the Command pattern. Use a list of commands to move back (Undo) or forward (redo) through your actions. An example in C# can be found here.
The Memento pattern was made for this.
Before implementing this yourself, note that this is quite common, and code already exist - For example, if you're coding in .Net, you can use IEditableObject.
If the actions are reversible. e.g Adding 1, make a player move etc see how to use the Command Pattern to implement undo/redo. Follow the link the you will find a detailed examples on how to do that.
If not, use Saved State as explained by @Lazer.