protected override void NotifyOthers() { //ご近所さん全員に伝える foreach (Agent neighbour in this.Neighbours) { if (!messageBox.ReceivedFrom(neighbour) || //ただし、意見をくれたやつにはあげる必要ない。 messageBox.OpinionOf(neighbour) != this.Opinion) //くれてるやつでも、違う意見もってるやつには投げる。 { //センサーが入ってるとバグるよ。なぜならば、receivedFromが成立しないから? if (Opinion == null) { throw new Exception("こんなことありえない。バグだ"); } BlackWhiteSubject myopinion = thought.Opinion.Value; //nullableを通常に変換 this.SendOpinion(myopinion, neighbour); //送る } } messageBox = new DRMessageQueue(); }