Annotation of 43BSD/contrib/X/xdemo/cell.clu, revision 1.1.1.1

1.1       root        1: cell = cluster is new, set_neighbors, set_test_list,
                      2:                  clear,
                      3:                  get_x, get_y,
                      4:                  set_generation, get_generation,
                      5:                  set_alive, get_alive,
                      6:                  born_neighbor, dead_neighbor,
                      7:                  get_died, get_born,
                      8:                  generate, affect_neighbors
                      9: 
                     10:     cells = sequence[cell]
                     11:     acell = array[cell]
                     12: 
                     13:     rep = record[
                     14:              Alive_Last:     bool,
                     15:              Alive_Now:      bool,
                     16:              Generation:     int,
                     17:              Neighbors:      cells,
                     18:              Neigh_Count:    int,
                     19:              Test_List:      acell,
                     20:              X:              int,
                     21:              Y:              int
                     22:                 ]
                     23: 
                     24:     New = proc (X: int, Y: int) returns (cvt)
                     25:        return (rep${
                     26:                    Alive_Last:     false,
                     27:                    Alive_Now:      false,
                     28:                    Generation:     -1,
                     29:                    Neighbors:      _cvt[null, cells](nil),
                     30:                    Neigh_Count:    0,
                     31:                    Test_List:      _cvt[null, acell](nil),
                     32:                    X:              X,
                     33:                    Y:              Y
                     34:                     })
                     35:        end New
                     36: 
                     37:     Set_Neighbors = proc (C: cvt, Ns: cells)
                     38:        C.Neighbors := Ns
                     39:        end Set_Neighbors
                     40: 
                     41:     Set_Test_List = proc (C: cvt, TL: acell);
                     42:        C.Test_List := TL
                     43:        end Set_Test_List;
                     44: 
                     45:     Clear = proc (C: cvt, G: int);
                     46:        C.Alive_Last  := false
                     47:        C.Alive_Now   := false
                     48:        C.Generation  := G
                     49:        C.Neigh_Count := 0
                     50:        end Clear;
                     51: 
                     52:     Get_X = proc (C: cvt) returns (int);
                     53:        return (C.X)
                     54:        end Get_X;
                     55: 
                     56:     Get_Y = proc (C: cvt) returns (int);
                     57:        return (C.Y)
                     58:        end Get_Y;
                     59: 
                     60:     Set_Generation = proc (C: cvt, G: int);
                     61:        C.Generation := G
                     62:        end Set_Generation;
                     63: 
                     64:     Get_Generation = proc (C: cvt) returns (int);
                     65:        return (C.Generation)
                     66:        end Get_Generation;
                     67: 
                     68:     Set_Alive = proc (C: cvt, Al: bool, Generation: int) returns (bool)
                     69:        C.Alive_Last := C.Alive_Now
                     70:        C.Alive_Now  := Al
                     71:        Changed: bool := C.Alive_Last ~= Al
                     72:        if (Changed cand
                     73:            (C.Generation ~= Generation))
                     74:           then acell$AddH(C.Test_List, up(C))
                     75:                C.Generation := Generation
                     76:           end
                     77:        return (Changed)
                     78:        end Set_Alive
                     79: 
                     80:     Get_Alive = proc (C: cvt) returns (bool);
                     81:        return (C.Alive_Now)
                     82:        end Get_Alive;
                     83: 
                     84:     Born_Neighbor = proc (C: cvt)
                     85:        C.Neigh_Count := C.Neigh_Count + 1
                     86:        end Born_Neighbor
                     87: 
                     88:     Dead_Neighbor = proc (C: cvt)
                     89:        C.Neigh_Count := C.Neigh_Count - 1
                     90:        end Dead_Neighbor
                     91: 
                     92:     Get_Died = proc (C: cvt) returns (bool)
                     93:        return (C.Alive_Last cand ~ C.Alive_Now)
                     94:        end Get_Died
                     95: 
                     96:     Get_Born = proc (C: cvt) returns (bool)
                     97:        return (C.Alive_Now cand ~ C.Alive_Last)
                     98:        end Get_Born
                     99: 
                    100:     Generate = proc (C: cvt) returns (bool)
                    101:        C.Alive_Last := C.Alive_Now
                    102:        Count: int := C.Neigh_Count
                    103:        if ((Count < 2) cor (Count > 3))
                    104:           then C.Alive_Now := false
                    105:         elseif (Count = 3)
                    106:           then C.Alive_Now := true
                    107:         end
                    108:        return (C.Alive_Now ~= C.Alive_Last)
                    109:        end Generate
                    110: 
                    111:     Affect_Neighbors = proc (C: cvt, Generation: int)
                    112:        if (C.Alive_Last)
                    113:           then if (~ C.Alive_Now)
                    114:                   then for N: cell in cells$Elements(C.Neighbors) do
                    115:                            NR: rep := down(N)
                    116:                            NR.Neigh_Count := NR.Neigh_Count - 1
                    117:                            if (NR.Generation ~= Generation)
                    118:                               then acell$AddH(NR.Test_List, N)
                    119:                                    NR.Generation := Generation
                    120:                               end
                    121:                            end
                    122:                        if (C.Generation ~= Generation)
                    123:                           then acell$AddH(C.Test_List, up(C))
                    124:                                C.Generation := Generation
                    125:                           end
                    126:                   end
                    127:           else if (C.Alive_Now)
                    128:                   then for N: cell in cells$Elements(C.Neighbors) do
                    129:                            NR: rep := down(N)
                    130:                            NR.Neigh_Count := NR.Neigh_Count + 1
                    131:                            if (NR.Generation ~= Generation)
                    132:                               then acell$AddH(NR.Test_List, N)
                    133:                                    NR.Generation := Generation
                    134:                               end
                    135:                            end
                    136:                        if (C.Generation ~= Generation)
                    137:                           then acell$AddH(C.Test_List, up(C))
                    138:                                C.Generation := Generation
                    139:                           end
                    140:                   end
                    141:           end
                    142:        end Affect_Neighbors
                    143:     end cell

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.