Changeset 8756 for trunk/MagicSoft/Mars/mtools
- Timestamp:
- 10/13/07 19:56:29 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mtools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mtools/MagicReversi.cc
r8755 r8756 481 481 } 482 482 483 Int_t MagicReversi::GetDirection(Int_t src, Int_t dst) const484 {485 const MGeomPix &pix1=(*fGeomCam)[dst];486 const MGeomPix &pix2=(*fGeomCam)[src];487 488 const Double_t x1 = pix1.GetX();489 const Double_t y1 = pix1.GetY();490 491 const Double_t x2 = pix2.GetX();492 const Double_t y2 = pix2.GetY();493 494 if (x1>=x2 && y1>y2) return kRightTop;495 if (x1>=x2 && y1<y2) return kRightBottom;496 if (x1<=x2 && y1>y2) return kLeftTop;497 if (x1<=x2 && y1<y2) return kLeftBottom;498 if (x1>x2) return kRight;499 if (x1<x2) return kLeft;500 501 return -1;502 }503 504 Int_t MagicReversi::GetNeighbor(Int_t idx, Int_t dir) const505 {506 MGeomPix &pix=(*fGeomCam)[idx];507 508 //509 // search for the neighbor in the given direction510 //511 int i;512 for (i=0; i<pix.GetNumNeighbors(); i++)513 if (GetDirection(idx, pix.GetNeighbor(i))==dir)514 return pix.GetNeighbor(i);515 516 return -1;517 }518 519 483 Bool_t MagicReversi::Flip(Int_t origidx, Bool_t flip) 520 484 { … … 523 487 int test[6] = {0,0,0,0,0,0}; 524 488 525 for (int dir= kRightTop; dir<=kLeftTop; dir++)489 for (int dir=MGeomPix::kRightTop; dir<=MGeomPix::kLeftTop; dir++) 526 490 { 527 491 Int_t idx = origidx; … … 530 494 while (1) 531 495 { 532 idx = GetNeighbor(idx, dir);496 idx = fGeomCam->GetNeighbor(idx, dir); 533 497 if (idx<0 || (*this)[idx].GetFillColor()==kEmpty) 534 498 break; … … 547 511 int cnt = 0; 548 512 549 for (int dir= kRightTop; dir<=kLeftTop; dir++)513 for (int dir=MGeomPix::kRightTop; dir<=MGeomPix::kLeftTop; dir++) 550 514 { 551 515 Int_t idx = origidx; … … 557 521 for (int i=0; i<test[dir]; i++) 558 522 { 559 idx = GetNeighbor(idx, dir);523 idx = fGeomCam->GetNeighbor(idx, dir); 560 524 561 525 fUsrPts[(*this)[idx].GetFillColor()-kRed]--; -
trunk/MagicSoft/Mars/mtools/MagicReversi.h
r8755 r8756 19 19 { 20 20 private: 21 enum {22 kRightTop,23 kRight,24 kRightBottom,25 kLeftBottom,26 kLeft,27 kLeftTop28 };29 // static const Int_t fColorBombs[7]; // colors for the hexagons30 31 21 MGeomCam *fGeomCam; // pointer to camera geometry 32 22 … … 73 63 74 64 Bool_t Flip(Int_t idx, Bool_t flip); 75 Int_t GetDirection(Int_t src, Int_t dst) const;76 Int_t GetNeighbor(Int_t idx, Int_t dir) const;77 65 Bool_t CheckMoves(); 78 66
Note:
See TracChangeset
for help on using the changeset viewer.