⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 squirmgrid.h

📁 本程序模拟细胞的自我繁殖
💻 H
字号:
// SquirmGrid.h

#include "SquirmCell.h"
#include "SquirmCellSlot.h"
#include "SquirmChemistry.h"

class SquirmGrid {

public:

    SquirmGrid();
    ~SquirmGrid();

    void Create(float x,float y);

    void Draw(CDC* pDC,float scale);

    void InitSimple(int n);

    void DoTimeStep();
    unsigned long GetIterations() { return this->iterations; }

    // return a text string describing what's at this point (eg. "e8")
    //CString GetReport(CPoint p,int scale);

    C2dVector GetSize() { return this->size; }

	void GetAllWithinRadius(C2dVector loc,float r,SquirmCellList &dest);

    static int RandomN(int n);

    bool Valid(C2dVector p) { return(p.x>=0.0F && p.y>=0.0F && 
		p.x<=this->size.x && p.y<=this->size.y); }

	void PutCell(SquirmCell *cell);
	void RemoveCell(SquirmCell *cell);

    CString ProbeAt(float x,float y,float scale);

protected:

    /*float force1(float r2);
    float force2(float r2);
    float force3(float r2);*/

    float spring_force(float r2);
    float compute_force(float r2,float range,float magnitude);

	SquirmCellSlot* GetSlot(C2dVector p);

    SquirmCell* CreateNewCell(float x,float y,char type,int state)
	{
		return CreateNewCell(C2dVector(x,y),type,state);
	}

    SquirmCell* CreateNewCell(C2dVector loc,char type,int state);

    SquirmCell* CreateRandomCell();
    SquirmCell* CreateRandomCellOfType(char type);
    //void MoveCell(SquirmCell *cell,float tx,float ty);

    float RandomX();
    float RandomY();

    void RecomputeVelocitiesAndReact();
    void MoveCells();
    void EdgeEffect();

    void DoFlood();
	//void DoSwap();

    SquirmCellSlot **cell_grid;
    CTypedPtrList<CPtrList,SquirmCell*> cell_list;

    SquirmChemistry chemistry;

    C2dVector size;
    bool created;

    unsigned long iterations;

    bool do_flood;
    int FLOOD_PERIOD;
    int flood_sector;

	bool do_cosmic;
	unsigned long cosmic_cases; // eg. 10000 means a 1 in 10000 chance

	bool do_swap;
	int SWAP_PERIOD;

    int initial_population;

    FILE *output,*output2;
    bool do_output;

	float slot_size;
	int slots_X,slots_Y;

    SquirmCell *probe;

    void InitSearchArea(int cx,int cy,int search_slots,SquirmCellList*& central_cells,
        SquirmCellList &nearby);

    int OFFSET;

};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -