operator: learn-map

    description:
        learn-map[h, w]
        learn-map[h, w, op]
        learn a rectangular map, of height h, and width w
        where all cells are initialized to zero: 
            op |grid: x: y> => |0>
        and we learn all direction operators, N, NE, E, SE, S, SW, W, NW, that don't point outside the map
        the map is closed boundary, rather than torus shape
      
    examples:
        -- show what we learn for a small example map:
        learn-map[2,2]
        dump
            ----------------------------------------
             |context> => |context: global context>
            
            value |grid: 1: 1> => |0>
            E |grid: 1: 1> => |grid: 1: 2>
            SE |grid: 1: 1> => |grid: 2: 2>
            S |grid: 1: 1> => |grid: 2: 1>
            
            value |grid: 1: 2> => |0>
            S |grid: 1: 2> => |grid: 2: 2>
            SW |grid: 1: 2> => |grid: 2: 1>
            W |grid: 1: 2> => |grid: 1: 1>
            
            value |grid: 2: 1> => |0>
            N |grid: 2: 1> => |grid: 1: 1>
            NE |grid: 2: 1> => |grid: 1: 2>
            E |grid: 2: 1> => |grid: 2: 2>
            
            value |grid: 2: 2> => |0>
            N |grid: 2: 2> => |grid: 1: 2>
            W |grid: 2: 2> => |grid: 2: 1>
            NW |grid: 2: 2> => |grid: 1: 1>
            ----------------------------------------

        -- learn a larger map, then find path/steps between grid cells:    
        learn-map[20,20]
        find-path-between(|grid: 1: 1>, |grid: 4: 6>)
            |op: E> . |op: E> . |op: SE> . |op: SE> . |op: SE>

        find-steps-between(|grid: 1: 1>, |grid: 4: 6>)
            |grid: 1: 1> . |grid: 1: 2> . |grid: 1: 3> . |grid: 2: 4> . |grid: 3: 5> . |grid: 4: 6>

    see also:
        display-map, walking-ant.swc, find-path-between, find-steps-between

Home