-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.pl
More file actions
42 lines (38 loc) · 1.1 KB
/
input.pl
File metadata and controls
42 lines (38 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
% get_user_input(-Move)
:- [configurations].
% Receives input from the user.
% The user will be repeatedly asked to give a valid move or "ff" that signals he resigns.
get_user_move(Type@Origin goto Position) :-
write('Enter your move:'), nl,
read(Input),
(
Input = (Type@Origin goto Position)
;
Input \= 'ff',
write('Invalid move, try again'), nl,
get_user_move(Type@Origin goto Position)
).
% Get difficult level from user
get_user_difficulty(Difficulty) :-
write('Please select a difficulty level (easy / medium / hard):'), nl,
read(Input),
(
difficulty(Input, opening, _),
Difficulty = Input
;
Input \= 'ff',
write('Invalid difficulty, try again.'), nl,
get_user_difficulty(Difficulty)
).
% Get user's piece colour
get_user_colour(Colour) :-
write('Please select your piece colour (white / black):'), nl,
read(Input),
(
colour(Input),
Colour = Input
;
Input \= 'ff',
write('Invalid colour, try again.'), nl,
get_user_colour(Colour)
).