I'm currently reading the book Programming Game AI By Example.
The book mentions assigning unique ID numbers to each entity in the game. Often when entity A needs to contact entity B, A gets a reference to B by sending B's ID number to an EntityDatabase class. This class recieves ID numbers and returns references to the entities.
The ID numbers of some entities could also be fetched from a file containing the IDs of some of the entities (the main game characters).
My question is: Why would I do this? Why can't I work directly with references? Is it sometimes difficult to get a direct reference? Is using an ID system a common approach? Are there games that don't use IDs?
I'm new to game development. Please explain the benefits of working with an entity ID system. The advantages and disadvantages. Concrete examples would be great. Thanks