Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 216
Joined: 24 Apr 2007 12:26


Unread post by Ferenc Nagy » 31 Dec 2015 12:31

Happy New Year!
I have a map of cells with key generation and coordinates.
I'd like to iterate on each cells belonging to the last generation, count their neighbors, and decide about the birth, death and survival of the cells.
Does the map::upFrom_nd procedure call below return only the cells of a given generation if cells having Generation>last_generation do not exist?
In other words, what is the sorting order of composite keys like the term g(generation,coordinates)?
Is the strongest sort key the generation, and the weakest the last integer of coordinate domain?

Code: Select all

domains     generation = positive.     gen_and_coord = g(generation,coordinates).     map_coordinates_to_cell = mapM{gen_and_coord, cell}.   properties     cell_map : map_coordinates_to_cell.     facts - for_properties     cell_map : map_coordinates_to_cell := erroneous.     predicates     generate:() procedure.   clauses  generate() :-         NextGeneration=last_generation+1,         if my_type=hexagonal then             LowestCoordinates=h(-max_abs_coord,-max_abs_coord,-max_abs_coord)         else             LowestCoordinates=r(-max_abs_coord,-max_abs_coord)         end if         _ =             [ Cell ||                 tuple(g(last_generation,Coordinates),Cell)=cell_map:upFrom_nd(g(last_generation,LowestCoordinate),                 NumInhabited=countNeigbors(g(last_generation,Coordinates),inhabited) % Place for decision about birth, death and survival of cells in the next generation.             ],        last_generation:=NextGeneration.  
TIA, Regards,
Frank Nagy

User avatar
Thomas Linder Puls
VIP Member
Posts: 1158
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 1 Jan 2016 14:10


Notice that you can create maps based on your own comparison operation (e.g. mapM_redBlack::newCustom).
Regards Thomas Linder Puls

Post Reply