注の注:A software feature is "a prominent or distinctive user-visible aspect, quality, or characteristic of a software system or systems", as defined by Kang et al ... (wiki)
【Worldクラス中盤】
public void Goes_Around() //「世界が廻る(時が過ぎる)」→セルに日常活動を行わせる
{
if(!Gameover)
{ //最大人口超の場合
if(CellList.Count > Max_Population)
{
Gameover = true; //ゲームオーバー
Message += "現在の人口過密が異常となりました!(人口爆発)" +
Environment.NewLine + Get_Distribution() +
Environment.NewLine + "(詳細はログを参照ねがいます。)";
return;
}
bool extinction = true; //絶滅チェッカー
int LastCell = CellList.Count;
for(int i = 0; i < LastCell; i++) //"foreach"は配列が変化するとエラーになる為
{
Cell cell = CellList[i]; //IDから対象セルを求める
cell.VitalCheck(); //対象セルの生死状態をチェック
if(cell.Alive) //生存している場合
{
Check_Around(cell); //対象セルの周囲を確認する
Point loc = cell.Where(); //対象セルの位置を取得
Map[loc.Y * Wld_Width + loc.X] = ' '; //対象セルの旧座標を' 'にする //周囲のセルの有無を確認する
Cell y = null; //周囲のセル
int dir = Not_Found; //周囲のセルのいる方向
int val = cell.Find_Cell(); //対象セルの周囲にセルがいるか確認
if(val != Not_Found) //周囲にセルが見つかったならば
{
dir = val & 0x0F; //dirは周囲のセルの絶対方向(0 - 7)
y = Get_Cell(val >> 4); //周囲のセルのポインターを取得
} //コンピューター処理とマニュアル処理へ分岐させる(解説:ここが最大の変更点)
if(i == MyID && cell.Alive) //ユーザー判断による処理(アバターの場合)(死んだcellは食物でしかない)
public void Flee(Cell x, Cell y, int dir) //敵対状態になっても、攻撃力、防御力の差が大きければ逃走する
{
int reverse = x.Find_Field(false, dir); //相手yの反対方向の野原を探す
x.Get_Move(reverse); //逃走する
}
public Cell Get_Cell(int n) //CellListの指定番目のセルを返す
{
return CellList[n];
}
public Cell Get_Cell(int x, int y) //座標位置にあるセルを返す
{
int LastCell = CellList.Count;
for(int i = 0; i < LastCell; i++)
{
Point loc = CellList[i].Where();
if(loc.X == x && loc.Y == y)
return CellList[i];
}
return null;
}
public string Get_Distribution() //ピンク、ブルー、グリーンの生死状況を返す
{ //解説:C++の時はデータのみ整数配列で戻していましたが、C#では最初から文字列にしています。 //Tribe_Statusの初期化
for(int i = 0; i < Tribe_Status.Length; i++)
Tribe_Status[i] = 0;
int LastCell = CellList.Count;
for(int i = 0; i < LastCell; i++)
{
switch(CellList[i].Tribe)
{
case 0: //ピンク
Tribe_Status[0]++;
break;
case 1: //ブルー
Tribe_Status[1]++;
break;
case 2: //グリーン
Tribe_Status[2]++;
break;
default: //死亡(モノ)
Tribe_Status[3]++;
break;
}
}
string Distribution = "----------" + Environment.NewLine
+ "ピンク セル:" + Tribe_Status[0].ToString() + Environment.NewLine
+ "ブルー セル:" + Tribe_Status[1].ToString() + Environment.NewLine
+ "グリーンセル:" + Tribe_Status[2].ToString() + Environment.NewLine
+ "死亡 セル:" + Tribe_Status[3].ToString();
return Distribution;
}
public string Show_Cell_Param() //総てのcell属性を表示する
{
string parameters = String.Empty;
int LastCell = CellList.Count;
for(int i = 0; i < LastCell; i++)
{
parameters += CellList[i].Show_Param();
if(i == MyID) //アバターを指定している場合にアバターのCellについて修正する
{ //解説:以下は文字列末尾の改行コードを外し、" - My avatar"を付けてからまた改行コードを付けています。
parameters = parameters.TrimEnd('\r', '\n') + " - My avatar" + Environment.NewLine;
}
}
return parameters;
}
//////////////////////////////////
// Cell_World.cs
// Class Definitions for Cells.cs
// Copyright (c) 2026 by Y-sama
//////////////////////////////////
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D; //Graphicsクラス(アンチエイリアス)使用の為
using System.Collections.Generic; //List使用の為
using System.IO; //FileStream使用の為
using System.Text; //Encording使用の為
using System.Reflection; //Assemblyを使う為
using System.Resources; //リソース使用の為
namespace Cell_World
{ /////////////////
//Cellクラス定義
/////////////////
public class Cell
{ ///////////////////////
//ゲーム関係フィールド
// 定数定義
///////////////////////
int Max_Left = 17520; //セルの最長余命(単位1時間、2年で24hours x 365days x 2years = 17,520)
int Max_Life = 4320; //セルの最大初期エネルギー(半年で24hours x 180days = 4320)
const int Max_Tribe = 4; //現在はCell-P, Cell-B, Cell-G, Cell-D(死亡)
const int Max_Dir = 8; //↑:0、↗:1、→:2、↘:3、↓:4、↙:5、←:6、↖:7
const int Not_Found = -1; //Find_***処理用
int Living_Cost = 24; //【調整項目】余命(Left)、生命力(Life)の消耗時間 /////////////////////////////////
//メンバーフィールドとプロパティ
/////////////////////////////////
//生存フラグ
public bool Alive {get; private set;} //生存(true)、死亡(false) //繁殖フラグ
public bool Intmarg {get; set;} //異種族間婚の許可 //位置
private Point Location; //Cellの位置(World内の位置座標)
private int[] m_Around = new int[8]; //環境情報フィールド(Aroundの実体)
public int[] Around //Cell周囲の存在(野原:0、山:1、河川:2、食物:3、セル:4 + ID)
{ get
{
return m_Around;
}
private set
{
m_Around = value;
}
} //性格系
public int Affection {get; set;} //愛着性
public int Hostility {get; set;} //敵対性 //能力系
public int Left {get; set;} //余命(Max_Left: 単位1時間、2年で24hours x 365days x 2years = 17,520)
public int Life {get; set;} //生命力(Max_Life: 半年分で24hours x 180days = 4320)
public int Power {get; private set;} //攻撃力(Lifeによる)
public int Defense {get; private set;} //防御力(LifeとLeft<経験>による)
public int Fertility {get; private set;}//生殖力(Leftによる) //識別系
public int ID {get; set;} //Cellのゼロベースの固有番号
public int Tribe {get; set;} //種族(ピンク:0、ブルー:1、グリーン:2、モノ(死亡):3の4色) //運動系
public int Dir {get; set;} //Cellの移動方向(↑:0、↗:1、→:2、↘:3、↓:4、↙:5、←:6、↖:7)