Guest User

Untitled

a guest
Feb 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. Breakpoint 1, SimGrid::put (this=0x7fffffffe170, agent=0x7b7cd0, cell=0x7fffe928b390) at core/simgrid.cpp:20
  2. 20      assert(cell != NULL && agent != NULL && cell->sim() == this && cell->agent() == NULL);
  3. (gdb) p *cell
  4. Cannot access memory at address 0x7fffe928b390
  5.  
  6.  
  7.  
  8. Billes sim;
  9. sim.add(50000);
  10.  
  11.  
  12. void Billes::add(unsigned int n){
  13.     for(unsigned int i = 0 ; i < n ; i++)      
  14.         put(new Bille(), emptyCell());
  15. }
  16.  
  17. SimGrid::SimGrid(unsigned int xlen, unsigned int ylen){
  18.     m_xlen = xlen;
  19.     m_ylen = ylen;
  20.     for(unsigned int x = 0 ; x < m_xlen ; x++){
  21.         for(unsigned y = 0 ; y < m_ylen ; y++){
  22.             m_cells.push_back(Cell(this, x, y));
  23.             m_emptyCells.push_back(cell(x, y));
  24.         }
  25.     }
  26. }
  27.  
  28. void SimGrid::put(GridAgent *agent, Cell *cell){
  29.     assert(cell != NULL && agent != NULL && cell->sim() == this && cell->agent() == NULL);
  30.     cell->agent(agent);
  31.     agent->cell(cell);
  32.     for(unsigned int i = 0 ; i < m_emptyCells.size() ; i++){
  33.         if(m_emptyCells[i] == cell){
  34.             m_emptyCells.erase(m_emptyCells.begin() + i);
  35.             break;
  36.         }
  37.     }
  38.     addAgent(agent);
  39. }
  40.  
  41. Cell *SimGrid::emptyCell(){ return m_emptyCells.at(lrand48() % m_emptyCells.size()); }
Add Comment
Please, Sign In to add comment