/
teste2.py
127 lines (84 loc) · 3.23 KB
/
teste2.py
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from rtools import rsplit as rp
__author__ = 'astrowar'
from shlex import split as sp
import re
from Scene import *
s = Scene()
#macro comandos
s << rp("Kind book Thing")
s << rp("Instance diary book")
s << rp("Kind Animal Thing" )
s << rp("Kind Ox Animal" )
s << rp("Instance jairo Ox" )
s << rp("Set diary rare" )
s << rp("Set diary hidden" )
s << rp("Set [location book] library" )
s << rp("Set [title diary] untitled" )
s << rp("Set book portable" )
s << rp("Kind Color KindValue ")
s << rp("Instance red Color")
s << rp("Instance blue Color")
s << rp("Instance green Color")
s << rp("Property [color book] Color")
print(s.data)
print(s.kinds)
s<< rp("Kind? diary") # return "book"
s << rp("Is? diary book ") # diary is an book ?
s << rp("Is? diary Thing ") #true
s << rp("Is? diary Place ") #false
rpp = lambda x:print(rp(x))
rpp("Kind? [noum] [is kind of [some]] ")
rpp("Is? diary Place ")
xx = s.match(rp("Instance :Noum :kind"), rp("Instance book thing ") )
print(xx)
print("------------")
for x in s.matchs(rp("Instance $Noum $Kind") ):
print( x)
print("------------")
def func_eval_if( ex ):
# (If X THEN_ELEM ELSE_ELEM )
return True
print("F: ", s.func_is_kind("diary", "Animal"))
print("------------")
print("T: ", s.func_is_kind("jairo", "Animal"))
print("IS------------")
print("T: ", s.func_obj_is("diary", "rare"))
print("IS Portable----------")
print("T: ", s.func_obj_is("diary", "portable"))
print("F: ", s.func_obj_is("jairo", "portable"))
print("T: ", s.func_obj_is("diary", "book"))
print("Property----------")
print("T: ", s.func_eval_named_prop("location","diary"))
print("N: ", s.func_eval_named_prop("color","jairo"))
print("Kind Values ----------")
print("T: ", s.func_is_kind("red", "KindValue"))
print("T: ", s.func_is_kind("green", "Color"))
print("F: ", s.func_is_kind("white", "Color"))
# Brightness is a kind of value. The brightnesses are guttering, weak, radiant and blazing.
s << rp("Kind Brightness KindValue")
s << rp("Instance guttering Brightness")
s << rp("Instance weak Brightness")
s << rp("Instance radiant Brightness")
s << rp("Instance blazing Brightness")
# The lantern has a brightness called the flame strength. The flame strength of the lantern is blazing.
s << rp("Property ['flame strength' lantern] Brightness")
s << rp("Set ['flame strength' lantern] blazing")
print("T: ", s.func_eval_named_prop('flame strength' ,"lantern"), "blazing")
print("F: ", s.func_eval_named_prop('flame strength' , "lantern"), "weak")
print("T: ", s.func_is_kind("blazing", "Brightness" ))
# CanBe
# A fruit can be unripened, ripe, overripe, or mushy
s << rp("CanBe fruit [unripened, ripe, overripe, mushy]")
s << rp("Set fruit ripe")
s << rp("Set [ color fruit ] red ")
s << rp("Set [ location fruit ] cozinha ")
s << rp("Set [food player] fruit ")
s << rp("Set ['favorite food' Animal] fruit ")
#print("T: ", s.func_eval(rp("[color [key player]]")))
print("T: ", s.is_named_property("color"))
print("T: ", s.is_named_property("location"))
print("F: ", s.is_named_property("book"))
print("Eval Values ----------")
print("T: ", s.func_eval(rp("color [food player]"))) #red
print("T: ", s.func_eval(rp("location ['favorite food' jairo]"))) #cozinha
print("T: ", s.func_eval(rp("color [location jairo]"))) #None