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

📄 agent.h

📁 实现Agent,绕墙走的功能,实现了图形化界面.点中按钮<AddWall>或<AddBlock>,使其处于按下状态,然后就可以在左边的矩形区域内通过点击鼠标左键设定墙或障碍物.
💻 H
字号:
#ifndef AGENT_JTWU_H
#define AGENT_JTWU_H

class Position {
public:
   int row;
   int col;
   Position() { row=0; col=0; }
   Position(int rw, int cl) { row=rw; col=cl; }
   Position(const Position & copy) { row=copy.row; col=copy.col; }
   operator = (const Position & copy) { row=copy.row; col=copy.col; }
   bool operator == (const Position & cmp) 
   { return ( (row==cmp.row) && (col==cmp.col) ); }
   Position East();
   Position South();
   Position West();
   Position North();
};
Position Position::East() { Position newpos(row, col+1); return newpos; }
Position Position::South() { Position newpos(row+1, col); return newpos; }
Position Position::West() { Position newpos(row, col-1); return newpos; }
Position Position::North() { Position newpos(row-1, col); return newpos; }

class Agent {
public:
   Agent() {;}
   Agent(int row, int col) { m_curpos.row = row; m_curpos.col = col; }
   Agent(const Position & pos);
   void GotoNewPosition( const Position & newpos );
   Position GetCurrentPosition();
   bool operator == (Agent cmp) { return (cmp.m_curpos == m_curpos);}
private:
   Position  m_curpos;
};

Agent::Agent(const Position & pos) { m_curpos = pos; }
void Agent::GotoNewPosition( const Position & newpos ) { m_curpos = newpos; }
Position Agent::GetCurrentPosition() { return m_curpos; }

#endif //:~AGENT_JTWU_H

⌨️ 快捷键说明

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