Anonim / 2 years, 7 months ago | Download | Plaintext | Odpowiedz |

 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
questions(['What kind of animal is a wale?','What is most dangerous?']).
answers([
[
	%[lizard,mammal],
	['I',think,its,lizard,.],
	[maybe,mammal,?],
	['Im',thinking,about,fish,.],
	[robot,.]
],
[
	[cat,.],
	[mole,?],
	[lion,'!']
]]).
keyss(
[[
	[mammal,100],
	[lizard,4],
	[fish,10],
	['I',20]
],
[
	[cat,20],
	[snake,40],
	[lion,50],
	[mole,100000]
]]).

take_one([H|T],H,T).

addpoints([[Pnts,Nr]|L],L,Pnts,Nr).%dodaje do listy punktow i odpowiedzi I add points
red([H],H).

length([],0).
length([X|L],N):-length(L,M), N is M+1. 

count_pntsss([],[_],0).
count_pntsss([Kh|Kt],Ans,Pnt):- %leci po kluczach
	take_one(Kh,Khh,Kht),
	write(' spr slowo '),
	write(Ans),
	write(' z '),
	write(Khh),nl,
	Ans==Khh,%jak rowne to dodaj punkty i dyla
	Pnt is Kht,!;
	write(Kt),
	Pnt is 0,
	%length(Kt,D),
	%D=:=0,
	count_pntsss(Kt,Ans,Pnt).

add_p(A,B,C) :- C is A + B.
count_pntss([],[],_).
count_pntss([Ah|At],Keys,Sum) :-%leci po slowach w odp
	write('Word from ansewer:  '),
	write(Ah),nl,
	count_pntsss(Keys,Ah,Pnt),%sprawdz slowo z kluczami
	add_p(Pnt,Sum,Ret),
	write(Ret),nl,
	write(At),nl,
	write(Keys),
	count_pntss(At,Keys,Ret).%sprawdz kolejne slowo
count_pnts([],[],[],_).
count_pnts(Listwp,Keys,[Ah|At],Nr) :-%leci po odp
		Num is Nr+1,
		Pnt is 0,
		write('Answer: '),
	write(Ah),nl,
		count_pntss(Ah,Keys,Pnt),%klucze,pierwsza odp,punkty zwraca
		write('i was here'),
		addpoints(Listwp,Listwp,Pnt,Nr),
		write('and here'),
		count_pnts(Listwp,Keys,At,Num).%odpal kolejne pytanie	

test :-
	questions(Q),
	Nr is 1,
	take_one(Q,Qh,Qt),%Qt not used yet
	write(Qh),
	answers(A),
	keyss(K),
	take_one(A,Ah,At),%pierwsze odpowiedzi V first answers
	take_one(K,Kh,Kt),%pierwsze klucze V first keys
	write('List of answers: '),
	write(Ah),nl,
	write('List of keys: '),
	write(Kh),nl,

	%take_one(Answers,Af,Att),
	count_pnts(Listwp,Kh,Ah,Nr),%lista [nr/pkty],klucze,odp,numer
	write(Listwp).
	%read(Input),
	%check_answer(Input,Listwp),