Analysis.
First we have Rick who is very cynical, often blunt and overly self-centered. Rick follows a simple code of order at his nightclub, he never drinks with clients and he never sticks his neck out for anybody. Rick seems to believe in ETHICAL EGOISM, the idea that each person ought to pursue his or her own self-interest exclusively. His duty was to do what is best for him and only him. Rick was selfish not foolish.
Ungarte at the beginning of the movie comes to Rick and begs him for help he refuses. Rick does not want to break the law after all there is nothing in it for him. We know that Rick has stole money, ran off with someone's wife, and killed a man. So we know Rick will break the law if he wants to. All of these things are consequences of thinking of only yourself. He cannot go back to America he has a price on his head. Rick never seams to harm anyone, he does not lie and he keeps his promises. At the same time he sticks his neck out for no one. This all is ETHICAL EGOISM. But a time is coming when he will be asked to challenge his moral code of ethics and risk everything to save someone else. Rick is torn between his desire for revenge and his wanting to know the truth. Rick is forced to evaluate his morality, both his ethics and matters of the heart, and to decide where his loyalties will lie. We believe Rick at first to be a rake, a careless man with few scruples, but through the course of the film we actually realize what a kind and goodhearted man he truly is. How he puts the wants and needs of others first before his own.
At the end of the movie Rick ultimately makes a UTILITARIAN decision. Ilsa says she cannot make a decision Rick must think for the both of them. Rick agrees that he will do the thinking. Rick tricks her until the very end convinces her that they will go away together then at the last minute talks her into getting on the plane with Victor. Rick says they must both save Victor.