Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <vector>
- using namespace std;
- enum PlayerType { D, C };
- class Cell {
- public:
- PlayerType type;
- double score;
- Cell () : type(C), score(0) {};
- Cell (PlayerType _type) : type(_type), score(0) {};
- double InterractWith (Cell member) {
- if (member.type == C) {
- if (type == C)
- score += 1;
- else
- score += 1.8;
- }
- }
- };
- // x = ( (i + x) + size ) % size
- // y = ( ((i/size) + y) + size ) % size
- void CalculateScores (vector<Cell> grid) {
- int size = sqrt(grid.size());
- for (int i = 0; i < grid.size(); i++) {
- for (int x = -1; x < 2; x++) {
- for (int y = -1; y < 2; y++) {
- int memberX = ( (i + x) + size ) % size;
- int memberY = ( ((i/size) + y) + size ) % size;
- grid.at(i).IntarractWith( grid.at(memberX + memberY*size) );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement