MikelThief/EPFU-Penguins-Galore

Consequences of surrounding the board - needs fixing

Closed this issue · 3 comments

MovePeng.c contains code:

if(CheckMove(idRow, 3, Spaces, Row, Col, NumOfCols, FishArray, AllPengs, PengArray)) {
FishArray[Row][Col] = 0;

wchich takes size of FishArray WITH 0-column and 0-row.

It should be Row+1 and Col+1, am I right?

No, Row and Col are initialized as

Row = PengArray[idRow][1];
Col = PengArray[idRow][2];

So Row, Col are the same as penguin's original X and Y coordinates before moving. If CheckMove returns 1 (move can be done) then FishArray[Row][Col] = 0 sets the original hexagon to 0. The zeros around the map shouldn't mess up the coordinates because it's only possible to put a penguin on a tile with 1. It just means that the "actual" board starts from 1,1 instead of 0,0.

But idRow seems to be a redundant variable with the current system because actually idRow == ID-1 (So WhichPenguin() is also redundant)... Or it's just a lot of checking that could be done with a simple operation.

Okay, then issue is closed. Code will need to be cleaned in future. Wchichpeng may be needed for game ending.