void Path::CheckChain(){ //check if at least one enemy dot inside const int max_y=MaxY(); const int min_y=MinY(); const int max_x=MaxX(); const int min_x=MinX(); try{//excpeption handler to quit from loop quickly for(int cy=min_y; cy<=max_y; cy++){ for(int cx=min_x; cx<=max_x; cx++){ if( (cx>MinXInRow(cy) ) && (cx<MaxXInRow(cy) ) && (cy>MinYInColumn(cx)) && (cy<MaxYInColumn(cx)) && (field->GetState(Coordinates(cx, cy)) == EXISTS) //if dot isn't captured && (field->GetColor(Coordinates(cx, cy)) == -clr)){ //if color of dot inside is enemy color enemy_point_inside=true; throw 1; } } } } catch(int i){ return; } }
/************************************************************************* * Function name: pushNeighbours * The Input: guess coords * The output: - * The Function operation: saves all the neighbour coordinates of this guess * to be guessed later (to reveal the hit ship) *************************************************************************/ void ComputerPlayer::pushNeighbours(Coordinates& guess) { // Go down Coordinates candidate = Coordinates(guess.getX() + 1, guess.getY()); if (isNewGuess(candidate) && candidate.getX() < BOARD_SIZE) { futureHits.push(candidate); } // Go right candidate = Coordinates(guess.getX(), guess.getY() + 1); if (isNewGuess(candidate) && candidate.getY() < BOARD_SIZE) { futureHits.push(candidate); } // Go up candidate = Coordinates(guess.getX() - 1, guess.getY()); if (isNewGuess(candidate) && candidate.getX() > 0) { futureHits.push(candidate); } // Go left candidate = Coordinates(guess.getX(), guess.getY() - 1); if (isNewGuess(candidate) && candidate.getY() > 0) { futureHits.push(candidate); } }
Coordinates Coordinates::screenToIso(Coordinates screen, int tileW, int tileH){ Coordinates iso = Coordinates(); int X0 = screen.x - (ApplicationPreferencesManager::getIntegerPreference("OriginX",0) - ApplicationPreferencesManager::getIntegerPreference("IsoDeltaX", 0)); int Y0 = screen.y - (ApplicationPreferencesManager::getIntegerPreference("OriginY",0) - ApplicationPreferencesManager::getIntegerPreference("IsoDeltaY", 0)); int X = Y0 + (X0 / 2); int Y = Y0 - (X0 / 2); iso.x = X / tileH; iso.y = Y / tileH; int centerX = ApplicationPreferencesManager::getIntegerPreference("width", DEFAULT_WIDTH)/2; int centerY = ApplicationPreferencesManager::getIntegerPreference("height", DEFAULT_WIDTH)/2; int oriX = ApplicationPreferencesManager::getIntegerPreference("OriginX", DEFAULT_WIDTH); int oriY = ApplicationPreferencesManager::getIntegerPreference("OriginY", DEFAULT_WIDTH); ApplicationPreferencesManager::setIntegerPreference("MapDeltaX",iso.x); ApplicationPreferencesManager::setIntegerPreference("MapDeltaY",iso.y); if(centerX > screenClamp.x) ApplicationPreferencesManager::setIntegerPreference("OriginX",oriX - (screen.x - centerX)); else ApplicationPreferencesManager::setIntegerPreference("OriginX",oriX + (centerX - screen.x)); if(centerY > screenClamp.y) ApplicationPreferencesManager::setIntegerPreference("OriginY",oriY + (centerY - screen.y)); else ApplicationPreferencesManager::setIntegerPreference("OriginY",oriY - (screen.y - centerY)); return(iso); }
void GeneticAlgorithm::mutation(Army *ind, int degree) { int unitID = rand()%ind->nUnits(); Unit *unit = ind->getUnitAtIndex(unitID); int tacticID = rand()%unit->getTacticSize(); Tactic *tactic = unit->getTacticAt(tacticID); int newType = unit->getType(); switch(degree) { case MUTATION_UNIT_TYPE:{ //Mutate a unit type mutateUnitType(ind, unitID, newType); } break; case MUTATION_UNIT_TACTIC: //Mutate a unit tactic mutateTactic(tactic, rand()%4); break; case MUTATION_UNIT_POSITION: //Mutate a unit position unit->setBluePrintCoord( Coordinates(rand()%COMBAT_AREA_WIDTH + 150, rand()%COMBAT_AREA_HEIGHT + 50) ); break; default: break; } GoldCap(ind); }
bool FieldView::on_button_press_event(GdkEventButton* event){ //we get aproximatly coordinats of cell //here we add 0.1463 to avoid some infelicity const double xm = (event->x) / CELL_SIZE / GetScaleX(); const double ym = (event->y) / CELL_SIZE / GetScaleY(); //we find fractional part of coordinats, then it will help us to round coordinats const double xdiff = xm - abs(xm); const double ydiff = ym - abs(ym); int xc, yc; //here we round our coordinats if(xdiff <= 0.25) xc = abs(xm) - 1; else if(xdiff >= 0.75) xc = abs(xm); else xc = -1; if(ydiff <= 0.25) yc = abs(ym) - 1; else if(ydiff >= 0.75) yc = abs(ym); else yc = -1; //when xc or yc are equal to -1 it means that signal mustn't be handled if((xc >= 0) && (yc >= 0)) ctrl->MakeMove(Coordinates(xc, yc)); //emit signal return true; }
void GameState::controlLoop(SDL_Event * e) { switch (e->type){ case SDL_KEYDOWN: break; case SDL_KEYUP: break; case SDL_MOUSEMOTION: break; case SDL_MOUSEBUTTONDOWN: int x,y; if(SDL_BUTTON(SDL_GetMouseState(&x, &y)) == SDL_BUTTON_LEFT){ std::cout<<x<<","<<y<<std::endl; Coordinates newCoor = Coordinates(x,y); newCoor = newCoor.screenToIso( newCoor, ApplicationPreferencesManager::getIntegerPreference("tileWidth", DEFAULT_WIDTH), ApplicationPreferencesManager::getIntegerPreference("tileHeight", DEFAULT_HEIGHT) ); std::cout<<newCoor.x<<","<<newCoor.y<<"\n"<<std::endl; int isoDeltaX = ApplicationPreferencesManager::getIntegerPreference("MapDeltaX",0) - ApplicationPreferencesManager::getIntegerPreference("MapDeltaY",0); int isoDeltaY = (ApplicationPreferencesManager::getIntegerPreference("MapDeltaY",0) + ApplicationPreferencesManager::getIntegerPreference("MapDeltaX",0))/2; ApplicationPreferencesManager::setIntegerPreference("IsoDeltaX",isoDeltaX); ApplicationPreferencesManager::setIntegerPreference("IsoDeltaY",isoDeltaY); std::cout<<"Delta"<<std::endl; std::cout<<ApplicationPreferencesManager::getIntegerPreference("MapDeltaX",0)<<","<<ApplicationPreferencesManager::getIntegerPreference("MapDeltaY",0)<<std::endl; std::cout<<ApplicationPreferencesManager::getIntegerPreference("IsoDeltaX",0)<<","<<ApplicationPreferencesManager::getIntegerPreference("IsoDeltaY",0)<<std::endl; } break; case SDL_MOUSEBUTTONUP: break; default: break; } }
bool IGCParser::readCRecord(const char *line, int len) { qreal lat, lon; if (len < 18) return false; if (!readLat(line + 1, lat)) { _errorString = "Invalid latitude"; return false; } if (!readLon(line + 9, lon)) { _errorString = "Invalid longitude"; return false; } if (!(lat == 0 && lon == 0)) { QByteArray ba(line + 18, len - 19); Waypoint w(Coordinates(lon, lat)); w.setName(QString(ba.trimmed())); _routes.last().append(w); } return true; }
std::vector< std::string > BoggleSolver::giveMeWords() const { int x=0,y=0; std::set< std::string > result; std::set< std::string > otherResult; std::vector<std::string> res; for(std::vector<std::vector<char> >::const_iterator it = grid.begin(); it != grid.end();++it) { x=0; for(std::vector<char>::const_iterator itChar = (*it).begin(); itChar != (*it).end();++itChar) { Coordinates c = Coordinates(x,y); std::set< Coordinates > alreadyUsed; alreadyUsed.clear(); otherResult = giveMeWords("",c,alreadyUsed); result.insert( otherResult.begin(), otherResult.end() ); x++; } y++; } res.insert( res.end(), result.begin(), result.end() ); std::sort(res.begin(), res.end(),f); return res; }
Coordinates Coordinates::ParseConfig( std::string const & iCoordinatesName, boost::property_tree::ptree const & iPtree) { uint64_t aX = iPtree.get< uint64_t >(iCoordinatesName + ".x"); uint64_t aY = iPtree.get< uint64_t >(iCoordinatesName + ".y"); return Coordinates(aX, aY); }
Enemy::Enemy() { this->MoveTo(Coordinates(0, 0)); this->item = Item(); attack += item.GetAttack(); accuracy += item.GetAccuracy(); defense += item.GetDefense(); }
void AltitudeMap::init(unsigned int length, unsigned int width, unsigned int height) { index = 0; bound.length = length; bound.width = width; bound.height = height; // Size vector Coordinates newCoord = Coordinates(); coord.assign(bound.length * bound.width, newCoord); // Fill vector with 0 height -- Could use iterators here for (unsigned int row = 0; row < bound.length; row++) { for (unsigned int col = 0; col < bound.width; col++) { coord[row * bound.length + col] = Coordinates(row, col); } } }
/** * @see insert(double x, double y, const ElementType& newObject) */ iterator insert(double x, double y, ElementType&& val) { if (coordinatesAreOk(x, y)) { return insert(StoredObject( LocationCode<maxLevels>(tr.forward(Coordinates(x, y))), std::move(val))); } return iterator(); }
/************************************************************************* * Function name: getRandomGuess * The Input: - * The output: guess coordinates * The Function operation: generates random guess *************************************************************************/ Coordinates* ComputerPlayer::getRandomGuess() { int x, y; // Randomize x and y until we get new guess do { x = rand() % 10; y = rand() % 10; } while (!isNewGuess(Coordinates(x, y))); return new Coordinates(x, y); }
bool FieldView::DrawAllDots(){ bool result(true); //simply accept DrawDot() for every available dot for(int xc = 0; xc < width; xc++) for(int yc = 0; yc < height; yc++) if(!DrawDot(Coordinates(xc, yc))) result = false; return result; }
/** * Removes from the QuadTree container all elements that match given coordinates. They are then * destroyed. * * @param x X-axis coordinate of the element to be removed. * @param y Y-axis coordinate of the element to be removed. */ void erase(double x, double y) { // TODO: relocate elements to node->parent() if node and its siblings count is lower or equal than capacity. if (coordinatesAreOk(x, y)) { LocationCode<maxLevels> code(tr.forward(Coordinates(x, y))); TreeNode* node = getNode(code); node->erase(code); } }
/************************************************************************* * Function name: strategicMove * The Input: - * The output: guess coordinates * The Function operation: generates strategic guess *************************************************************************/ Coordinates* ComputerPlayer::strategicMove() { /* Running in diagonals. * first - 3 right ones, then 3 left ones. * after that (if the enemy survived) - random moves. */ if (!hasMoreIdeas) { return getRandomGuess(); } do { // Running in diagonals right if (movingDiagRight) { smartX++; smartY++; // The first (major) diagonal is over if (smartX == BOARD_SIZE && smartY == BOARD_SIZE) { smartX = 0; smartY = BOARD_SIZE / 2; // The first small diagonal is over } else if (smartY == BOARD_SIZE) { smartX = BOARD_SIZE / 2; smartY = 0; // The second small diagonal is over } else if (smartX == BOARD_SIZE) { movingDiagRight = false; smartX = 0; smartY = BOARD_SIZE - 1; } // Running diagonally left } else { smartX++; smartY--; // The first (major) diagonal is over if (smartX == BOARD_SIZE && smartY == 0) { smartX = 0; smartY = (BOARD_SIZE / 2) + 1; // The first small diagonal is over } else if (smartY == 0) { smartX = (BOARD_SIZE / 2) - 2; smartY = BOARD_SIZE - 1; // The second small diagonal is over } else if (smartX == BOARD_SIZE) { hasMoreIdeas = false; return getRandomGuess(); } } // If this guess was already made - continue } while (!isNewGuess(Coordinates(smartX, smartY))); return new Coordinates(smartX, smartY); }
/** * Return the bounds of a range that includes all the elements that are near specified (x, y). * * @param x X-axis coordinate of val. * @param y Y-axis coordinate of val. * @return Pair of iterators that point to the first and the last of the elements that are * near the (x, y) point. If any of given x or y is outside of a QuadTree range (i.e. * x >= startX + width or y >= startY + width), pair of end() is returned. */ std::pair<iterator, iterator> near(double x, double y) { if (coordinatesAreOk(x, y)) { TreeNode* node = getExistingNode( LocationCode<maxLevels>(tr.forward(Coordinates(x, y)))); return std::pair<iterator, iterator>( iterator(node, 0), ++iterator(node, node->count())); } return std::pair<iterator, iterator>(end(), end()); }
void TIM1_UP_IRQHandler(void)//routina diakophs gia diakoph pou prokaleitai apo upcounting tou timer 1 { TIM_Cmd(TIM1,DISABLE);//apenergopoihsh tou timer Coordinates();//synarthsh pou pairnei ta dedomena apo to accelerometro kai ta apothikeuei se pinakes TIM_ClearFlag(TIM1,TIM_FLAG_Update); //kanei clear to flag ths diakophs TIM_Cmd(TIM1,ENABLE);//energopoihsh tou timer TIM_SetCounter (TIM1,0x00); //3anarxizei to upcounting apo to 0 }
void Display::updateDisplay(Entities &entities){ al_clear_to_color(al_map_rgba(0, 0, 0, 255)); std::list<Entity*> entitiesTemp = entities.getEntities(); for (std::list<Entity*>::iterator it = entitiesTemp.begin(); it != entitiesTemp.end(); it++){ (*it)->draw(); } displayText(score, Coordinates(80, 10), font2); al_flip_display(); }
Coordinates Coordinates::isoToScreen(Coordinates iso, int tileW, int tileH){ Coordinates screen = Coordinates(); screen.x = ApplicationPreferencesManager::getIntegerPreference("OriginX",0) - (iso.y * tileW/2) + (iso.x * tileW/2) - (tileW/2); screen.y = ApplicationPreferencesManager::getIntegerPreference("OriginY",0) + (iso.y * tileH/2) + (iso.x * tileH/2); int isoDeltaX = ApplicationPreferencesManager::getIntegerPreference("MapDeltaX",0) - ApplicationPreferencesManager::getIntegerPreference("MapDeltaY",0); int isoDeltaY = (ApplicationPreferencesManager::getIntegerPreference("MapDeltaY",0) + ApplicationPreferencesManager::getIntegerPreference("MapDeltaX",0))/2; ApplicationPreferencesManager::setIntegerPreference("IsoDeltaX",isoDeltaX); ApplicationPreferencesManager::setIntegerPreference("IsoDeltaY",isoDeltaY); return(screen); }
Coordinates operator()(osmium::Location location) const { Coordinates c {location.lon(), location.lat()}; if (m_epsg != 4326) { c = transform(m_crs_wgs84, m_crs_user, Coordinates(deg_to_rad(location.lon()), deg_to_rad(location.lat()))); if (m_crs_user.is_latlong()) { c.x = rad_to_deg(c.x); c.y = rad_to_deg(c.y); } } return c; }
void Text::update(){ float x1,x2,y1,y2; const float _height = gxFont->getHeight(text); const float _width = gxFont->getWidth(text); // Gauche, droite, centre if (flags & FTGX_JUSTIFY_LEFT){ x1 = 0; x2 = _width; } else if (flags & FTGX_JUSTIFY_RIGHT){ x1 = -_width; x2 = 0; } else { // Par défaut FTGX_JUSTIFY_CENTER x1 = -_width/2; x2 = _width/2; } // Haut, bas, milieu if (flags & FTGX_ALIGN_TOP){ y1 = 0; y2 = _height; } else if (flags & FTGX_ALIGN_MIDDLE){ y1 = -_height/2; y2 = _height/2; } else { // Par défaut FTGX_ALIGN_BOTTOM y1 = -_height; y2 = 0; } vertices[0] = Coordinates(x1,y1); vertices[1] = Coordinates(x2,y1); vertices[2] = Coordinates(x2,y2); vertices[3] = Coordinates(x1,y2); }
integer Cas2Shuttle(CASblock & buffer, ShuttlePar & block){ /* Reading M1950 coordinates and velocities from CAs */ const int foot_cm=30.48; double Coo_M1950[3], Vel_M1950[3], q[4], Greenw_Phi, Vel_angle; polar Geo,Solar; Euler Euler_LVLH; Coo_M1950[0]=CASvalue(buffer,(4490),8) * foot_cm; Coo_M1950[1]=CASvalue(buffer,(4508),8) * foot_cm; Coo_M1950[2]=CASvalue(buffer,(4526),8) * foot_cm; Vel_M1950[0]=CASvalue(buffer,(4687),8) * foot_cm; Vel_M1950[1]=CASvalue(buffer,(4701),8) * foot_cm; Vel_M1950[2]=CASvalue(buffer,(4715),8) * foot_cm; q[0]=CASvalue(buffer,(3291),8); q[1]=CASvalue(buffer,(3305),8); q[2]=CASvalue(buffer,(3319),8); q[3]=CASvalue(buffer,(3333),8); double times= CAStime(buffer,10); time_t utime = time_t(times+0.5) + Year1998; // check record if((Radius(Coo_M1950)<=.1) || (Radius(Vel_M1950)<=.1) || (times<=0))return 0; // convert here Coordinates(Coo_M1950,Vel_M1950,q,utime,&Geo,&Vel_angle,&Euler_LVLH,&Solar,&Greenw_Phi); if(!td2f(Geo.Teta))return -1; if(!td2f(Geo.Phi))return -1; if(!td2f(Geo.R))return -1; if(!td2f(Greenw_Phi))return -1; if(!td2f(Euler_LVLH.Yaw))return -1; if(!td2f(Euler_LVLH.Pitch))return -1; if(!td2f(Euler_LVLH.Yaw))return -1; if(!td2f(Vel_angle))return -1; if(!td2f(Solar.R))return -1; if(!td2f(Solar.Phi))return -1; if(!td2f(Solar.Teta))return -1; block.StationTheta=d2f(Geo.Teta); block.StationPhi=d2f(Geo.Phi); block.StationR=d2f(Geo.R); block.GrMedPhi=d2f(Greenw_Phi); block.StationYaw=d2f(Euler_LVLH.Yaw); block.StationPitch=d2f(Euler_LVLH.Pitch); block.StationRoll=d2f( Euler_LVLH.Roll); block.StationSpeed=d2f( Vel_angle); block.SunR=d2f(Solar.R); block.SunPhi=d2f(Solar.Phi); block.SunTheta=d2f(Solar.Teta); //cout <<" "<<ClockTune(utime)<<" "<<ctime(&utime)<<endl; block.Time=utime-ClockTune(utime); }
bool Bishop::MayIGoHere(Coordinates position, Coordinates prev_position, QPointer<Player> friends, QPointer<Player>& enemies, bool CheckForCheck/* = true*/) { if ((prev_position.y() - prev_position.x() != position.y() - position.x()) && (prev_position.y() + prev_position.x() != position.y() + position.x())) return false; QPointer<Piece> pieceForDelete; for (int x = position.x(), y = position.y(); x != prev_position.x(), y != prev_position.y(); (position.x() < prev_position.x())?++x:--x, (position.y() < prev_position.y())?++y:--y) { if (!(friends->GetAnotherPiece(Coordinates(x, y), this).isNull())) return false; QPointer<Piece> piece = enemies->GetPiece(Coordinates(x, y)); if (!piece.isNull()) { if ((x == position.x()) && (y == position.y())) pieceForDelete = piece; else { pieceForDelete.clear(); return false; } } } if (CheckForCheck) { if (enemies->MaySomebodyGoHere(friends->GetKing(), friends, pieceForDelete)) { pieceForDelete.clear(); return false; } } if (!pieceForDelete.isNull() && CheckForCheck) enemies->RemovePiece(pieceForDelete); pieceForDelete.clear(); return true; }
bool IGCParser::readBRecord(const char *line, int len) { qreal lat, lon, ele; QTime time; if (len < 35) return false; if (!readTimestamp(line + 1, time)) { _errorString = "Invalid timestamp"; return false; } if (!readLat(line + 7, lat)) { _errorString = "Invalid latitude"; return false; } if (!readLon(line + 15, lon)) { _errorString = "Invalid longitude"; return false; } if (!readAltitude(line + 24, ele)) { _errorString = "Invalid altitude"; return false; } if (time < _time) _date = _date.addDays(1); _time = time; Trackpoint t(Coordinates(lon, lat)); t.setTimestamp(QDateTime(_date, _time, Qt::UTC)); t.setElevation(ele); _tracks.last().append(t); return true; }
void Character::Move( DIRECTION dir ) { if ( !m_isDead ) { // Check to see if moving in that direction will cause a collision. // If not, the move the character. bork::Vector2f newCoords = m_coordinates; switch( dir ) { case UP: newCoords.y = newCoords.y - m_speed; break; case DOWN: newCoords.y = newCoords.y + m_speed; break; case LEFT: newCoords.x = newCoords.x - m_speed; break; case RIGHT: newCoords.x = newCoords.x + m_speed; break; default: break; } if ( !bork::LevelManager::CheckCollision( newCoords, m_dimensions ) && !CharacterManager::CheckCollision( newCoords, m_dimensions, m_sId ) ) { // TODO: Reference to CharacterManager, circular dependency :( Coordinates( newCoords ); } } }
const Coordinates Vector::operator+( const Coordinates &coordinates) const { return Coordinates(x_ + coordinates.x_, y_ + coordinates.y_); }
const Coordinates Coordinates::operator-(const Vector& vector) const { return Coordinates(x_ - vector.x_, y_ - vector.y_); }
void GameState::displayLoop(SDL_Surface * surface) { Item item1 = Item(1,"Obj1",false,1,Coordinates(0,0),Resource()); Item item01 = Item(6,"Obj01",false,1,Coordinates(0,1),Resource()); Item item10 = Item(7,"Obj10",false,1,Coordinates(1,0),Resource()); Item item11 = Item(8,"Obj11",false,1,Coordinates(1,1),Resource()); Item item02 = Item(9,"Obj02",false,1,Coordinates(0,2),Resource()); Item item20 = Item(10,"Obj20",false,1,Coordinates(2,0),Resource()); Item item22 = Item(11,"Obj22",false,1,Coordinates(2,2),Resource()); Item item2 = Item(2,"Obj2",false,1,Coordinates(9,9),Resource()); Item item3 = Item(3,"Obj3",false,1,Coordinates(9,0),Resource()); Item item4 = Item(4,"Obj4",false,1,Coordinates(0,9),Resource()); Item item5 = Item(5,"Obj5",false,1,Coordinates(4,4),Resource()); std::vector<Item> items; Scene mainScene = Scene(1,items ,LocalPlayer()); mainScene.addItem(item1); mainScene.addItem(item2); mainScene.addItem(item3); mainScene.addItem(item4); mainScene.addItem(item5); mainScene.addItem(item10); mainScene.addItem(item01); mainScene.addItem(item11); mainScene.addItem(item20); mainScene.addItem(item02); mainScene.addItem(item22); mainScene.render(surface); }
/** * Override the Render method to draw the battleships on the screen */ void CliGridRenderer::RenderGame(battleships::Fleet *fOne, battleships::Fleet *fTwo, std::vector<Coordinates> *pOneShots, std::vector<Coordinates> *pTwoShots) { std::cout << std::endl << std::endl; // AI board for (int x = 0; x < 11; x++) { // First Column so std::cout << std::setfill('0') << std::setw(2) << x; for (int y = 0; y < 11; y++) { if (x == 0) { std::cout << " " << letters[y] << " "; } else { // We go y,x because of the order in which the for loops are // Or at least that seems to work when we're playing the game, so we're rolling with it if (fTwo->IsShipAtPosition(Coordinates(y, x)) && ShotsAtPosition(pOneShots, Coordinates(y,x))) { // output X if this shot was a hit std::cout << " X "; } else if(ShotsAtPosition(pOneShots, Coordinates(y, x))) { // output # if this shot was a miss std::cout << " # "; } else { // Output ~ if there hasn't been an attempted shot here - we don't want the player // knowing where their enemy's ships are! std::cout << " ~ "; } } } // New line for next row std::cout << std::endl; } // Split the boards std::cout << std::endl << std::endl; // Player board for (int x = 0; x < 11; x++) { // First Column so output row numbers std::cout << std::setfill('0') << std::setw(2) << x; for (int y = 0; y < 11; y++) { // First row so output column letters if (x == 0) { std::cout << " " << letters[y] << " "; } else { if (fOne->IsShipAtPosition(Coordinates(x, y))) { // If there's a ship here, output a O to indicate it std::cout << " O "; } else { // Otherwise output wavy sea lines std::cout << " ~ "; } } } // New line for next row std::cout << std::endl; } }