Simulated annealing is used to solve the X-ray phase problem formulated as a minimization problem. The cost function consists of two parts, one represents the discrepancy between measured and calculated intensities while the other monitors the probability distribution of the triplets. From a random real-space structure at the start, the atoms are moved one by one to gradually reduce the cost function until the best structure emerges. Trial calculations for structures including hexadecaisoleucinomycin (HEXIL) are presented. Comparison of this method with other related methods is made.