Вот след от пробега:
[trace] 42 ?- start.
Call: (6) start ? creep
^ Call: (7) _G537 is random(9) ? creep
^ Exit: (7) 6 is random(9) ? creep
^ Call: (7) _G539 is random(9) ? creep
^ Exit: (7) 6 is random(9) ? creep
^ Call: (7) _G541 is random(9) ? creep
^ Exit: (7) 1 is random(9) ? creep
^ Call: (7) _G543 is random(9) ? creep
^ Exit: (7) 4 is random(9) ? creep
Call: (7) _G555=[6, 6, 1, 4] ? creep
Exit: (7) [6, 6, 1, 4]=[6, 6, 1, 4] ? creep
Call: (7) write('Generated number:') ? creep
Generated number:
Exit: (7) write('Generated number:') ? creep
Call: (7) writeln([6, 6, 1, 4]) ? creep
[6,6,1,4]
Exit: (7) writeln([6, 6, 1, 4]) ? creep
Call: (7) write('Make a guess:') ? creep
Make a guess:
Exit: (7) write('Make a guess:') ? creep
Call: (7) read(_G555) ? creep
| 6614.
Exit: (7) read(6614) ? creep
Call: (7) atom_chars(6614, _G556) ? creep
Exit: (7) atom_chars(6614, ['6', '6', '1', '4']) ? creep
Call: (7) nl ? creep
Exit: (7) nl ? creep
Call: (7) check_length(['6', '6', '1', '4'], [6, 6, 1, 4]) ? creep
Call: (8) length(['6', '6', '1', '4'], _G568) ? creep
Exit: (8) length(['6', '6', '1', '4'], 4) ? creep
Call: (8) length([6, 6, 1, 4], 4) ? creep
Exit: (8) length([6, 6, 1, 4], 4) ? creep
Call: (8) writeln('The Lists have the same length!') ? creep
The Lists have the same length!
Exit: (8) writeln('The Lists have the same length!') ? creep
Exit: (7) check_length(['6', '6', '1', '4'], [6, 6, 1, 4]) ? creep
Call: (7) check_equality(['6', '6', '1', '4'], [6, 6, 1, 4]) ? creep
Call: (8) equal(['6', '6', '1', '4'], [6, 6, 1, 4]) ? creep
Call: (9) '6'=6 ? creep
Fail: (9) '6'=6 ? creep
Fail: (8) equal(['6', '6', '1', '4'], [6, 6, 1, 4]) ? creep
Fail: (7) check_equality(['6', '6', '1', '4'], [6, 6, 1, 4]) ? creep
Fail: (6) start ? creep
false.
важная часть такова:
Call: (9) '6'=6 ? creep
Fail: (9) '6'=6 ? creep
так что проблема в том, что символ '6' не равен числу 6
Другая проблема заключается в том, что нули в начале будут удалены
23 ?- atom_chars(0042,L).
L = ['4', '2'].
поэтому я бы предложил избавиться от atom_chars / 2 и заняться чем-нибудь еще; читать четыре числа по одному или разбивать число вручную