コード例 #1
0
ファイル: Game.cpp プロジェクト: YuanmingShi/ucd-csci2312-pa4
    void Game::addStrategic(const Position &position, Strategy *s) {
        int index = position.y + (position.x * __width);
        if (position.y >= __width || position.x >= __height) throw OutOfBoundsEx(__width, __height, position.x, position.y);
        if (__grid[index]) throw PositionNonemptyEx(position.x, position.y);

        __grid[index] = new Strategic(*this, position, STARTING_AGENT_ENERGY, s);
    }
コード例 #2
0
ファイル: Game.cpp プロジェクト: YuanmingShi/ucd-csci2312-pa4
    void Game::addStrategic(unsigned x, unsigned y, Strategy *s) {
        int index = y + (x * __width);
        if (y >= __width || x >= __height) throw OutOfBoundsEx(__width, __height, x, y);
        if (__grid[index]) throw PositionNonemptyEx(x, y);

        __grid[index] = new Strategic(*this, Position(x, y), STARTING_AGENT_ENERGY, s);
    }
コード例 #3
0
ファイル: Game.cpp プロジェクト: YuanmingShi/ucd-csci2312-pa4
    void Game::addSimple(const Position &position, double energy) { // used for testing only
        int index = position.y + (position.x * __width);
        if (position.y >= __width || position.x >= __height) throw OutOfBoundsEx(__width, __height, position.x, position.y);
        if (__grid[index]) throw PositionNonemptyEx(position.x, position.y);

        __grid[index] = new Simple(*this, position, energy);
    }
コード例 #4
0
ファイル: Game.cpp プロジェクト: YuanmingShi/ucd-csci2312-pa4
    void Game::addSimple(unsigned y, unsigned x, double energy) {
        int index = y + (x * __width);
        if (y >= __width || x >= __height) throw OutOfBoundsEx(__width, __height, x, y);
        if (__grid[index]) throw PositionNonemptyEx(x, y);

        __grid[index] = new Simple(*this, Position(x, y), energy);
    }
コード例 #5
0
ファイル: Game.cpp プロジェクト: YuanmingShi/ucd-csci2312-pa4
    void Game::addAdvantage(unsigned x, unsigned y) {
        int index = y + (x * __width);
        if (y >= __width || x >= __height) throw OutOfBoundsEx(__width, __height, x, y);
        if (__grid[index]) throw PositionNonemptyEx(x, y);

        __grid[index] = new Advantage(*this, Position(x, y), STARTING_RESOURCE_CAPACITY);
    }
コード例 #6
0
ファイル: Game.cpp プロジェクト: YuanmingShi/ucd-csci2312-pa4
    void Game::addAdvantage(const Position &position) {
        int index = position.y + (position.x * __width);
        if (position.y >= __width || position.x >= __height) throw OutOfBoundsEx(__width, __height, position.x, position.y);
        if (__grid[index]) throw PositionNonemptyEx(position.x, position.y);

        __grid[index] = new Advantage(*this, position, STARTING_RESOURCE_CAPACITY);
    }
コード例 #7
0
 void Game::addFood(const Position &position) {
     int location = position.y + (position.x * __width);
     if (position.x < 0 || position.x >= __height || position.y < 0 || position.y >= __width)
         throw OutOfBoundsEx(__width, __height, position.x, position.y);
     if (__grid[location])
         throw PositionNonemptyEx(position.x, position.y);
     __grid[location] = new Food(*this, position,STARTING_RESOURCE_CAPACITY);
 }
コード例 #8
0
ファイル: Game.cpp プロジェクト: SamridKC/ucd-csci2312-pa4
 void Game::addAdvantage(unsigned x, unsigned y) {
     if (y >= __width || x >= __height) {
         throw OutOfBoundsEx(__width, __height, x, y);
     }
     if (__grid[(x *__width)+y]) {
         throw PositionNonemptyEx(x, y);
     }
     __grid[(x *__width)+y] = new Advantage(*this, Position(x, y), STARTING_RESOURCE_CAPACITY);
 }
コード例 #9
0
ファイル: Game.cpp プロジェクト: SamridKC/ucd-csci2312-pa4
 void Game::addAdvantage(const Position &position) {
     if (position.y >= __width || position.x >= __height) {
         throw OutOfBoundsEx(__width, __height, position.x, position.y);
     }
     if (__grid[(position.x *__width)+position.y]) {
         throw PositionNonemptyEx(position.x, position.y);
     }
     __grid[(position.x *__width)+position.y] = new Advantage(*this, position, STARTING_RESOURCE_CAPACITY);
 }
コード例 #10
0
ファイル: Game.cpp プロジェクト: SamridKC/ucd-csci2312-pa4
 void Game::addStrategic(const Position &position, Strategy *s) {
     if (position.y >= __width || position.x >= __height) {
         throw OutOfBoundsEx(__width, __height, position.x, position.y);
     }
     if (__grid[(position.x * __width)+position.y]) {
         throw PositionNonemptyEx(position.x, position.y);
     }
     __grid[(position.x * __width)+position.y] = new Strategic(*this, position, STARTING_AGENT_ENERGY, s);
 }
コード例 #11
0
ファイル: Game.cpp プロジェクト: SamridKC/ucd-csci2312-pa4
 void Game::addSimple(unsigned y, unsigned x, double energy) {
     if (y >= __width || x >= __height) {
         throw OutOfBoundsEx(__width, __height, x, y);
     }
     if (__grid[(x*__width)+y]) {
         throw PositionNonemptyEx(x, y);
     }
     __grid[(x*__width)+y] = new Simple(*this, Position(x, y), energy);
 }
コード例 #12
0
ファイル: Game.cpp プロジェクト: SamridKC/ucd-csci2312-pa4
 void Game::addSimple(unsigned x, unsigned y) {
     if (y >= __width || x >= __height) {
         throw OutOfBoundsEx(__width, __height, x, y);
     }
     if (__grid[(x*__width)+y]) {
         throw PositionNonemptyEx(x, y);
     }
     __grid[(x*__width)+y] = new Simple(*this, Position(x, y), STARTING_AGENT_ENERGY);
 }
コード例 #13
0
ファイル: Game.cpp プロジェクト: SamridKC/ucd-csci2312-pa4
 void Game::addSimple(const Position &position, double energy) {
     if (position.y >= __width || position.x >= __height) {
         throw OutOfBoundsEx(__width, __height, position.x, position.y);
     }
     if (__grid[(position.x * __width)+position.y]) {
         throw PositionNonemptyEx(position.x, position.y);
     }
     __grid[(position.x * __width)+position.y] = new Simple(*this, position, energy);
 }
コード例 #14
0
 void Game::addAdvantage(unsigned x, unsigned y) {
     Position pos(x,y);
     int location = y +(x *__width);
     if (x < 0 || x >= __height || y < 0 || y >= __width)
         throw OutOfBoundsEx(__width, __height, x, y);
     if (__grid[location])
         throw PositionNonemptyEx(x, y);
     __grid[location] = new Advantage(*this, pos, STARTING_RESOURCE_CAPACITY);
 }
コード例 #15
0
 void Game::addStrategic(unsigned x, unsigned y, Strategy *s) {
     Position pos(x,y);
     int location = y + (x * __width);
     if (x < 0 || x >= __height || y < 0 || y >= __width)
         throw OutOfBoundsEx(__width, __height, x, y);
     if (__grid[location])
         throw PositionNonemptyEx(x, y);
     __grid[location] = new Strategic(*this, pos, STARTING_AGENT_ENERGY,s);
 }
コード例 #16
0
 void Game::addSimple(const Position &position, double energy) {
     //exception for out of bounds
     int location = position.y + (position.x * __width);
     if(position.x < 0 || position.x >= __height || position.y < 0 || position.y >= __width){
         throw OutOfBoundsEx(__width,__height,position.x,position.y);
     }
     if(__grid[location])
         throw PositionNonemptyEx(position.x,position.y);
     __grid[location] = new Simple(*this, position,energy);
 }
コード例 #17
0
ファイル: Game.cpp プロジェクト: brummetj/ucd-csci2312-pa4
void Game::addSimple(unsigned x, unsigned y)
    {
        int place = y + x * __width;
        if (y >= __width || x >= __height)
            throw OutOfBoundsEx(__width, __height, x, y);
        
        if (__grid[place])
            throw PositionNonemptyEx(x, y);
        
        __grid[place] = new Simple(*this, Position(x, y), STARTING_AGENT_ENERGY);
    }
コード例 #18
0
ファイル: Game.cpp プロジェクト: EvanDague/ucd-csci2312-pa3
    void Game::addStrategic(const Position &position, Strategy *s/* = new DefaultAgentStrategy()*/){
        Strategic *newStrat = new Strategic(*this, position, STARTING_AGENT_ENERGY,s);
        
        if((position.y*__width + position.x)>__grid.size() || position.x > __width)
            throw OutOfBoundsEx(__width,__height,position.x,position.y);

        if((__grid[position.y*__width + position.x])!=nullptr)
            throw PositionNonemptyEx(position.x,position.y);
        
        __grid[position.y*__width + position.x] = newStrat;
    }
コード例 #19
0
ファイル: Game.cpp プロジェクト: EvanDague/ucd-csci2312-pa3
    void Game::addAdvantage(const Position &position){
        Advantage *newAdvantage = new Advantage(*this, position, STARTING_RESOURCE_CAPACITY);
        
        if((position.y*__width + position.x)>__grid.size() || position.x > __width)
            throw OutOfBoundsEx(__width,__height,position.x,position.y);

        if((__grid[position.y*__width + position.x])!=nullptr)
            throw PositionNonemptyEx(position.x,position.y);
        
        __grid[position.y*__width + position.x] = newAdvantage;
    }
コード例 #20
0
ファイル: Game.cpp プロジェクト: travinh/ucd-csci2312-pa4
    void Game::addAdvantage(unsigned int x, unsigned int y)
    {
        int i = x * __width + y;
        if(y >= __width || x>=__height)
             throw OutOfBoundsEx(__height, __width, x, y);

         if(__grid[i])
             throw PositionNonemptyEx(x, y);

         __grid[i] = new Advantage(*this, Position(x,y), Game::STARTING_RESOURCE_CAPACITY);
    }
コード例 #21
0
ファイル: Game.cpp プロジェクト: EvanDague/ucd-csci2312-pa3
    void Game::addSimple(const Position &position, double energy){
        Simple *newSimple = new Simple(*this, position, STARTING_AGENT_ENERGY);
        
        if((position.y*__width + position.x)>__grid.size() || position.x > __width)
            throw OutOfBoundsEx(__width,__height,position.x,position.y);

        if((__grid[position.y*__width + position.x])!=nullptr)
            throw PositionNonemptyEx(position.x,position.y);
        
        __grid[position.y*__width + position.x] = newSimple;
    }
コード例 #22
0
ファイル: Game.cpp プロジェクト: travinh/ucd-csci2312-pa4
    void Game::addSimple(unsigned int x, unsigned int y)
    {    int i = x * __width + y;

         if( y >= __width ||  x >= __height)
             throw OutOfBoundsEx(__height, __width, x, y);

         if(__grid[i])
             throw PositionNonemptyEx(x, y);

         __grid[i] = new Simple(*this, Position(x,y), Game::STARTING_AGENT_ENERGY);
    }
コード例 #23
0
    void Game::addSimple(unsigned x, unsigned y, double energy) {
        //exception for out of bounds

        Position pos(x,y);
        int location = y + (x * __width);
        if (x < 0 || x >= __height || y < 0 || y >= __width)
            throw OutOfBoundsEx(__width, __height, x, y);
        if (__grid[location])
            throw PositionNonemptyEx(x, y);
        __grid[location] = new Simple(*this, pos,energy);
    }
コード例 #24
0
ファイル: Game.cpp プロジェクト: brummetj/ucd-csci2312-pa4
void Game::addFood(unsigned x, unsigned y)
    {
        int place = y + x * __width;
        
        if (y >= __width || x >= __height)
            throw OutOfBoundsEx(__width, __height, x, y);
        
        if (__grid[place])
            throw PositionNonemptyEx(x, y);
        
        __grid[place] = new Food(*this, Position(x, y), STARTING_RESOURCE_CAPACITY);
    }
コード例 #25
0
ファイル: Game.cpp プロジェクト: brummetj/ucd-csci2312-pa4
void Game::addFood(const Position &position)
    {
        int place = position.y + position.x * __width;
        
        if (position.y >= __width || position.x >= __height)
            throw OutOfBoundsEx(__width, __height, position.x, position.y);
        
        if (__grid[place])
            throw PositionNonemptyEx(position.x, position.y);
        
        __grid[place] = new Food(*this, position, STARTING_RESOURCE_CAPACITY);
    }
コード例 #26
0
ファイル: Game.cpp プロジェクト: brummetj/ucd-csci2312-pa4
//grid population methods
void Game::addSimple(const Position &position)
    {
        int place = position.y + position.x * __width;
        
        if (position.y >= __width || position.x >= __height)
            throw OutOfBoundsEx(__width, __height, position.x, position.y);
        
        if (__grid[place])
            throw PositionNonemptyEx(position.x, position.y);
        
        __grid[place] = new Simple(*this, position, STARTING_AGENT_ENERGY);
    }
コード例 #27
0
ファイル: Game.cpp プロジェクト: travinh/ucd-csci2312-pa4
    void Game::addAdvantage(const Position &p)
    {
        int i = p.x * __width + p.y;

        if(p.y >__width || p.x >= __height)
             throw OutOfBoundsEx(__height, __width, p.x, p.y);

         if(__grid[i])
             throw PositionNonemptyEx(p.x, p.y);

         __grid[i] = new Advantage(*this, p, Game::STARTING_RESOURCE_CAPACITY);
    }
コード例 #28
0
ファイル: Game.cpp プロジェクト: travinh/ucd-csci2312-pa4
    void Game::addStrategic(const Position &p, Strategy *s)
    {
         int i = p.x * __width + p.y;

         if(p.y >__width || p.x >= __height)
             throw OutOfBoundsEx(__height, __width, p.x, p.y);

         if(__grid[i])
             throw PositionNonemptyEx(p.x, p.y);

         __grid[i] = new Strategic(*this, p, Game::STARTING_AGENT_ENERGY, s);
    }
コード例 #29
0
ファイル: Game.cpp プロジェクト: hoangk/ucd-csci2312-pa4
    // grid population methods
    void Game::addSimple(const Position &position) {

        if ((position.x*__width + position.y) > __grid.size()) {
            throw OutOfBoundsEx(__width, __height, position.x, position.y);
        }
        if (__grid[position.x * __width + position.y] != nullptr) {
            throw PositionNonemptyEx(position.x, position.y);
        }

        __grid[position.x * __width + position.y] = new Simple(*this, position,STARTING_AGENT_ENERGY);

    }
コード例 #30
0
ファイル: Game.cpp プロジェクト: brummetj/ucd-csci2312-pa4
void Game::addSimple(const Position &position, double energy)
    {
        
        int place = position.y + position.x * __width;
        
        if (position.y >= __width || position.x >= __height)
            throw OutOfBoundsEx(__width, __height, position.x, position.y);
        
        if (__grid[place])
            throw PositionNonemptyEx(position.x, position.y);
        
        __grid[place] = new Simple(*this, position, energy);
    }