The first question is answered that the duplicate question suggested by Fard. However, the second question is distinct.
The comma is somewhat necessary, as it and the "and" connect your independent clause (My dream is to code a chess game) to your dependent clause (then have the AI I developed legitimately checkmate me).
However, as The Editor's Blog points out, the comma + coordinating conjunction implies that the dependent clause is nonessential. This would mean that much more focus would go to the independent clause, which I would assume is not your intention. Thus, removing the comma may be better in your situation.
However, if anything is actually unnecessary to the sentence, it's the "and". The "then" implies an "and" with it.