Good question. After the flood, Genesis recounts G-d in a state of regret, “His heart was saddened.”
Radak explains that: “When it says that He ‘regretted,’ this is the Torah speaking in human terms (Rabbi Ishmael), for in truth, ‘He is not human that He should change his mind [le-hinahem]’ (I Sam. 15:29), for in the Almighty there is no change of will.” Ibn Ezra and Maimonides agreed that the Torah ascribes emotions to G-d figuratively.
Whenever any one of His actions is perceived by us, we ascribe to G-d
that emotion which is the source of the act when performed by
ourselves, and call Him by an epithet which is formed from the verb
expressing that emotion. We see, e.g., how well He provides for the
life of the embryo of living beings; how He endows with certain
faculties both the embryo itself and those who have to rear it after
its birth, in order that it may be protected from death and
destruction, guarded against all harm, and assisted in the performance
of all that is required [for its development]. Similar acts, when
performed by us, are due to a certain emotion and tenderness called
mercy and pity. G-d is, therefore, said to be merciful: e.g., "Like as
a father is merciful to his children, so the L-rd is merciful to them
that fear Him" (Ps. ciii. 13); "And I will spare them, as a man
spareth (yaḥamol) his own son that serveth him" (Mal. iii. 17). Such
instances do not imply that G-d is influenced by a feeling of mercy,
but that acts similar to those which a father performs for his son,
out of pity, mercy and real affection, emanate from G-d solely for the
benefit of His pious men, and are by no means the result of any
impression or change--[produced in G-d].--When we give something to a
person who has no claim upon us, we perform an act of grace; e.g.,
"Grant them graciously unto us" (Judges xxi. 22). [The same term is
used in reference to G-d, e.g.] "which G-d hath graciously given"
(Gen. xxxiii. 5); "Because G-d hath dealt graciously with me" (ib.
11). Instances of this kind are numerous. G-d creates and guides
beings who have no claim upon Him to be created and guided by Him; He
is therefore called gracious (ḥannun)--His actions towards mankind
also include great calamities, which overtake individuals and bring
death to them, or affect whole families and even entire regions,
spread death, destroy generation after generation, and spare nothing
whatsoever. Hence there occur inundations, earthquakes, destructive
storms, expeditions of one nation against the other for the sake of
destroying it with the sword and blotting out its memory, and many
other evils of the same kind. Whenever such evils are caused by us to
any person, they originate in great anger, violent jealousy, or a
desire for revenge. G-d is therefore called, because of these acts,
"jealous," "revengeful," "wrathful," and "keeping anger" (Nah. i. 2)
that is to say, He performs acts similar to those which, when
performed by us, originate in certain psychical dispositions, in
jealousy, desire for retaliation, revenge, or anger: they are in
accordance with the guilt of those who are to be punished, and not the
result of any emotion: for He is above all defect! The same is the
case with all divine acts: though resembling those acts which emanate
from our passions and psychical dispositions, they are not due to
anything superadded to His essence. (Friedlander translation)
"For He is above all defect!" Since God is perfect, G-d does not have human emotions. According to Rambam, G-d does not become angry. When the Bible says that G-d becomes angry this is there to prompt people to act properly. The Rambam continues:
You, no doubt, know the Talmudical saying, which includes in itself
all the various kinds of interpretation connected with our subject. It
runs thus: “The Torah speaks according to the language of man,” that
is to say, expressions, which can easily be comprehended and
understood by all, are applied to the Creator. Hence the description
of G-d by attributes implying corporeality, in order to express His
existence: because the multitude of people do not easily conceive
existence unless in connection with a body, and that which is not a
body nor connected with a body has for them no existence. (Guide for
the Perplexed 1.26; Friedlander translation, p. 111)[1]
[1] From Dr. Yair Barkai’s essay “The L-rd and Regret.”