2001-06-06 20:40:57 +01:00
|
|
|
=================================================================
|
|
|
|
Logtalk - Object oriented extension to Prolog
|
2005-05-24 00:33:41 +01:00
|
|
|
Release 2.25.0
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2005-01-13 12:22:42 +00:00
|
|
|
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
|
2001-06-06 20:40:57 +01:00
|
|
|
=================================================================
|
|
|
|
|
|
|
|
|
2004-11-29 20:36:31 +00:00
|
|
|
% start by loading the necessary library and support example files (if not
|
|
|
|
% already loaded):
|
2004-06-13 19:04:28 +01:00
|
|
|
|
2004-11-29 20:36:31 +00:00
|
|
|
| ?- logtalk_load([library(events_loader), library(types_loader), library(metapredicates_loader), library(hierarchies_loader)]).
|
|
|
|
...
|
|
|
|
|
|
|
|
| ?- logtalk_load(roots(loader)).
|
|
|
|
...
|
|
|
|
|
|
|
|
| ?- logtalk_load(relations(loader)).
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
% now you are ready for loading the example:
|
|
|
|
|
|
|
|
| ?- logtalk_load(points(loader)).
|
2004-06-13 19:04:28 +01:00
|
|
|
...
|
|
|
|
|
|
|
|
|
2001-06-06 20:40:57 +01:00
|
|
|
% let's start with a simple point:
|
|
|
|
|
|
|
|
| ?- point::new(Point,[position-(1, 3)]), Point::(print, move(7, 4), print).
|
|
|
|
|
|
|
|
p1 @ (1, 3)
|
|
|
|
p1 @ (7, 4)
|
|
|
|
|
|
|
|
Point = p1 ?
|
|
|
|
|
|
|
|
yes
|
|
|
|
|
|
|
|
|
|
|
|
% same problem but with bounds on coordinate values:
|
|
|
|
|
|
|
|
| ?- bounded_point::new(Point,[position-(1, 3), bounds(x)-(0, 13), bounds(y)-(-7, 7)]), Point::(print, move(7, 4), print).
|
|
|
|
|
|
|
|
bounds(x) : 0,13
|
|
|
|
bounds(y) : -7,7
|
|
|
|
bp2 @ (1, 3)
|
|
|
|
bounds(x) : 0,13
|
|
|
|
bounds(y) : -7,7
|
|
|
|
bp2 @ (7, 4)
|
|
|
|
|
|
|
|
Point = bp2 ?
|
|
|
|
|
|
|
|
yes
|
|
|
|
|
|
|
|
|
|
|
|
% same problem but storing the history of coordinate values:
|
|
|
|
|
|
|
|
| ?- history_point::new(Point,[position-(1, 3)]), Point::(print, move(7, 4), print).
|
|
|
|
|
|
|
|
location history: []
|
|
|
|
hp3 @ (1, 3)
|
|
|
|
location history: [(1,3)]
|
|
|
|
hp3 @ (7, 4)
|
|
|
|
|
|
|
|
Point = hp3 ?
|
|
|
|
|
|
|
|
yes
|
|
|
|
|
|
|
|
|
|
|
|
% same problem but with bounds on coordinate values and storing past values:
|
|
|
|
|
|
|
|
| ?- bounded_history_point::new(Point,[position-(1, 3), bounds(x)-(0, 13), bounds(y)-(-7, 7)]), Point::(print, move(7, 4), print).
|
|
|
|
|
|
|
|
bounds(x) : 0,13
|
|
|
|
bounds(y) : -7,7
|
|
|
|
location history: []
|
|
|
|
bhp4 @ (1, 3)
|
|
|
|
bounds(x) : 0,13
|
|
|
|
bounds(y) : -7,7
|
|
|
|
location history: [(1,3)]
|
|
|
|
bhp4 @ (7, 4)
|
|
|
|
|
|
|
|
Point = bhp4 ?
|
|
|
|
|
|
|
|
yes
|
|
|
|
|
|
|
|
|
|
|
|
% clean up instances:
|
|
|
|
|
2002-04-03 14:26:59 +01:00
|
|
|
| ?- (point, bounded_point, history_point, bounded_history_point)::delete_all.
|
2001-06-06 20:40:57 +01:00
|
|
|
yes
|