public void Execute(int index) { var random = new Random((uint)(Seed + index)); Target[index] = new DataWithIndex <float> { Index = index, Value = random.NextFloat() }; }
public override void RemoveChicken(int columnIndex, int rowIndex) { base.RemoveChicken(columnIndex, rowIndex); //check if the chicken was added to the aliveChickens if (WasChickenAdded(columnIndex, rowIndex)) { //find the column that have the chicken to be removed List <DataWithIndex <Chicken> > removedFromColumn = null; DataWithIndex <List <DataWithIndex <Chicken> > > removedFromColumnWithIndex = new DataWithIndex <List <DataWithIndex <Chicken> > >(); foreach (DataWithIndex <List <DataWithIndex <Chicken> > > listData in aliveChickens) { if (listData.Index == columnIndex) { removedFromColumnWithIndex = listData; removedFromColumn = listData.Data; break; } } //remove the chicken from alive chicken list(remove from removedFromColumn) foreach (DataWithIndex <Chicken> dataWithIndex in removedFromColumn) { if (dataWithIndex.Index == rowIndex) { removedFromColumn.Remove(dataWithIndex); break; } } //if column has no chicken in it if (removedFromColumn.Count == 0) { //remove column aliveChickens.Remove(removedFromColumnWithIndex); } } }