{load_file("invl.hoc")}
objref nil

proc create_cells() { local i, gid  localobj cell, nc
	for pcitr(&i, &gid) {
		pnm.set_gid2node(gid, pc.id)
		pnm.gid_exists(gid)
		cell = new IF_IntervalFire(gid*ranoffset_ + 1)
		pnm.cells.append(cell)
		cell.connect2target(nil, nc)
		pnm.pc.cell(gid, nc)
		pnm.pc.outputcell(gid)
	}
}

proc connect_cells() { local i, j, gid, r   localobj cell
	// random connections but not self
	mcell_ran4_init(connect_random_low_start_)
	for pcitr(&i, &gid) {
		cell = pnm.cells.object(i)
		cell.r.uniform(1, ncell-1) // 0 refers to "this"
		cell.ranstart()
		for j=0, ncon-1 {
			r = (cell.r.repick + gid)%ncell // can never be gid
			pnm.nc_append(r, gid, -1, 0, 1)
		}
	}
}


proc init_run_random() {local i, gid  localobj cell
	mcell_ran4_init($1)
	for pcitr(&i, &gid) {
		cell = pnm.cells.object(i)
		cell.r.uniform(10,20) //interval variation
		cell.ranstart()
	}
}

create_cells()
connect_cells()