[Kde-games-devel] Review Request 114845: [knavalbattle] utilties for the several ships patch
Roney Gomes
roney477 at gmail.com
Thu Jan 16 12:20:36 UTC 2014
> On Jan. 15, 2014, 11:52 a.m., Roney Gomes wrote:
> > src/battlefield.cpp, line 213
> > <https://git.reviewboard.kde.org/r/114845/diff/2/?file=229803#file229803line213>
> >
> > I see here that you're testing for both horizontal and vertical availability, which -- once again -- could also be split into smaller methods. One for each case.
> >
> > You also decided to check horizontal availability first. Any reason for this or the order doesn't matter at all?
> >
> > How the AI would know in which direction it should place the new ship?
>
> Jaime Torres Amate wrote:
> Q: Any reason for this or the order doesn't matter at all?
> A: the order doesn't matter at all. Both horizontal and vertical must be checked. A ship can not be placed if there is not enough horizontal nor vertical space.
>
> The method, as it is now, can be divided in two smaller methods (one for vertical and one for horizontal) reading two times the matrix. Or it can be done in one pass with an additional column(or row) array. The second way should be faster.
>
> Roney Gomes wrote:
> Although it is faster, the matrix isn't so big to cause any sensible variation in performance. The code is OK, I'm not asking you to change it. I'm just pointing out that I prefer code that's easy to read, and thus maintain, than optimized code whose performance improvements are not significant.
>
> Jaime Torres Amate wrote:
> I'll change it. You are right. Even with a 50x50 board, the board fits in a 1Kib cpu cache.
> Also I missed the delete[] (using different programming languages so often)
> But I need some git help. There will be (in any case) two commits in the multipleShips branch for this patch.
> I cherry-pick those 2 commits into master (I know how to do it)? Merge the two commits into master (more or less, reading Albert instructions)? Create one patch and commit it directly into master (I know how to do it)?
>
>
The simpler approach is to commit to the new branch then merge with master (considering the current state of things, it'll be a fast-forward merge). However, I ask you to merge only when the multiple ships feature is ready.
Work on your branch as usual, commit and push as you progress but merge only when everything is done. I may take care of merging case you find any problems.
- Roney
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/114845/#review47433
-----------------------------------------------------------
On Jan. 15, 2014, 6:49 p.m., Jaime Torres Amate wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/114845/
> -----------------------------------------------------------
>
> (Updated Jan. 15, 2014, 6:49 p.m.)
>
>
> Review request for KDE Games and Roney Gomes.
>
>
> Repository: knavalbattle
>
>
> Description
> -------
>
> These are the tools I use to check if a ship can be placed in the board or if the user/AI should start again.
> Also, it serves me to split a big patch into smaller pieces.
> How it is done:
> * Pass the parameter allow adjacent ships also to the BattleField.
> * Implement a bool canAddShipOfSize(size). When a ship of size size can not be placed, then the AI or the player should start again (what I'm working on) or an Undo.
> * Implement a clear() to be able to start again
> * In the battleField also add another hidden board with the cells having only two status (free, busy) to be able to know the availability of the cells. It is easier for me in this way than the other way (sending a signal to clear the ship borders when the shooting starts).
>
>
> Diffs
> -----
>
> src/battlefield.h b2f30bc
> src/battlefield.cpp 6467d8c
> src/sea.h 4af50b7
> src/sea.cpp 38ab8b5
>
> Diff: https://git.reviewboard.kde.org/r/114845/diff/
>
>
> Testing
> -------
>
> It detects the blocked boards (played much more games than I wanted to implement the restart placing ships).
>
>
> Thanks,
>
> Jaime Torres Amate
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-games-devel/attachments/20140116/b1469bfd/attachment.html>
More information about the kde-games-devel
mailing list