Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
23 kB
2
Indexable
Never
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <set>
#include <vector>
using namespace std;

//----------state.hpp----------//

typedef bitset<15> Row;
typedef array<Row,15> Min_min_B;
typedef array<Min_min_B,3> The_Board;
const int SIZE = 15;
int player;
array<std::array<int, SIZE>, SIZE> board;

void start();

enum SPOT_STATE {
    EMPTY = 0,
    BLACK = 1,
    WHITE = 2
};

struct Point {
  int x, y;
	Point() : Point(0, 0) {}
	Point(float x, float y) : x(x), y(y) {}
	bool operator==(const Point& rhs) const {
		return x == rhs.x && y == rhs.y;
	}
	bool operator!=(const Point& rhs) const {
		return !operator==(rhs);
	}
	Point operator+(const Point& rhs) const {
		return Point(x + rhs.x, y + rhs.y);
	}
	Point operator-(const Point& rhs) const {
		return Point(x - rhs.x, y - rhs.y);
	}
};
std::vector<Point> to_move;

const int Beside[8][2]{
    {1,1},{-1,-1},
    {1,-1},{-1,1},
    {1,0},{-1,0},
    {0,1},{0,-1}
};

class Thing{
    public:
        Thing(){};
        Thing(The_Board map,int people);
        Thing* The_nextone(Point mov);
        vector<Point> behavior;
        int values();
    private:
        int player;
        The_Board map;
        vector<Point> The_behavior();
};

//----------minimax.hpp----------//

class Minimax{
    public:
        static Point moving(Thing *status,int th);
};

//----------minimax.cpp----------//

Point Minimax::moving(Thing* status,int th){
    Point origin=Point(15,15);
    int value=INT_MIN;

    for(Point e:status->behavior){
        if(-status->values() > value){
            origin=e;
            value=status->values();
        }
    }

    return origin;
};

//----------state.cpp----------//

void start(){
    for(int i=0;i<15;i++){
        for(int j=0;j<15;j++){
            to_move.push_back(Point(i,j));
        }
    }
}

int continuous_5(Min_min_B map){
    for(int i=0;i<11;i++){
        if((map[i] & map[i+1] & map[i+2] & map[i+3] & map[i+4]).any())
            return 1;
        if((map[i] & map[i+1]>>1 & map[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4).any())
            return 1;
        if((map[i] & map[i+1]<<1 & map[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4).any())
            return 1;
        
        for(int j=0;j<15;j++){
            if(((map[j]>>i)&=0b11111) ==0b11111)
                return 1;
        }
    }
    return 0;
}

int continuous_4(Min_min_B map,Min_min_B nobody){
    for(int i=0;i<10;i++){
        if((nobody[i] & map[i+1] & map[i+2] & map[i+3] & map[i+4] & nobody[i+5]).any())
            return 1;
        if((nobody[i] & map[i+1]>>1 & map[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((nobody[i] & map[i+1]<<1 & map[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;
        
        for(int j=0;j<15;j++){
            if(((map[j]>>i)&=0b011110) ==0b011110 && ((nobody[j]>>i)&=0b100001) ==0b100001)
                return 1;
        }
    }
    return 0;
}

int die_4(Min_min_B map,Min_min_B nobody,Min_min_B other){
    for(int i=0;i<11;i++){
        if((map[i] & nobody[i+1] & map[i+2] & map[i+3] & map[i+4]).any())
            return 1;
        if((map[i] & nobody[i+1]>>1 & map[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4).any())
            return 1;
        if((map[i] & nobody[i+1]<<1 & map[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4).any())
            return 1;

        if((map[i] & map[i+1] & map[i+2] & nobody[i+3] & map[i+4]).any())
            return 1;
        if((map[i] & map[i+1]>>1 & map[i+2]>>2 & nobody[i+3]>>3 & map[i+4]>>4).any())
            return 1;
        if((map[i] & map[i+1]<<1 & map[i+2]<<2 & nobody[i+3]<<3 & map[i+4]<<4).any())
            return 1;

        if((nobody[i] & map[i+1] & map[i+2] & map[i+3] & map[i+4] & other[i+5]).any())
            return 1;
        if((nobody[i] & map[i+1]>>1 & map[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4 & other[i+5]>>5).any())
            return 1;
        if((nobody[i] & map[i+1]<<1 & map[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4 & other[i+5]<<5).any())
            return 1;

        if((other[i] & map[i+1] & map[i+2] & map[i+3] & map[i+4] & nobody[i+5]).any())
            return 1;
        if((other[i] & map[i+1]>>1 & map[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((other[i] & map[i+1]<<1 & map[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;

        if((map[i] & map[i+1] & nobody[i+2] & map[i+3] & map[i+4]).any())
            return 1;
        if((map[i] & map[i+1]>>1 & nobody[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4).any())
            return 1;
        if((map[i] & map[i+1]<<1 & nobody[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4).any())
            return 1;
        
        for(int j=0;j<15;j++){
            if(((map[j]>>i)&=0b10111) ==0b10111 && ((nobody[j]>>i)&=0b01000) ==0b01000)
                return 1;
            if(((map[j]>>i)&=0b11101) ==0b11101 && ((nobody[j]>>i)&=0b00010) ==0b00010)
                return 1;
            if(((map[j]>>i)&=0b011110) ==0b011110 && ((nobody[j]>>i)&=0b100000) ==0b100000 && ((other[j]>>i)&=0b000001) ==0b000001)
                return 1;
            if(((map[j]>>i)&=0b011110) ==0b011110 && ((nobody[j]>>i)&=0b000001) ==0b000001 && ((other[j]>>i)&=0b100000) ==0b100000)
                return 1;
            if(((map[j]>>i)&=0b10111) ==0b10111 && ((nobody[j]>>i)&=0b01000) ==0b01000)
                return 1;
            if(((map[j]>>i)&=0b11011) ==0b11011 && ((nobody[j]>>i)&=0b00100) ==0b00100)
                return 1;
        }
    }
    return 0;
}

int live_3(Min_min_B map,Min_min_B nobody){
    for(int i=0;i<11;i++){
        if((nobody[i] & map[i+1] & map[i+2] & map[i+3] & nobody[i+4]).any())
            return 1;
        if((nobody[i] & map[i+1]>>1 & map[i+2]>>2 & map[i+3]>>3 & nobody[i+4]>>4).any())
            return 1;
        if((nobody[i] & map[i+1]<<1 & map[i+2]<<2 & map[i+3]<<3 & nobody[i+4]<<4).any())
            return 1;

        if((nobody[i] & map[i+1] & nobody[i+2] & map[i+3] & map[i+4] & nobody[i+5]).any())
            return 1;
        if((nobody[i] & map[i+1]>>1 & nobody[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((nobody[i] & map[i+1]<<1 & nobody[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;

        if((nobody[i] & map[i+1] & map[i+2] & nobody[i+3] & map[i+4] & nobody[i+5]).any())
            return 1;
        if((nobody[i] & map[i+1]>>1 & map[i+2]>>2 & nobody[i+3]>>3 & map[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((nobody[i] & map[i+1]<<1 & map[i+2]<<2 & nobody[i+3]<<3 & map[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;

        for(int j=0;j<15;j++){
            if(((map[j]>>i)&=0b01110) ==0b01110 && ((nobody[j]>>i)&=0b10001) ==0b10001)
                return 1;
            if(((map[j]>>i)&=0b010110) ==0b010110 && ((nobody[j]>>i)&=0b101001) ==0b101001)
                return 1;
            if(((map[j]>>i)&=0b011010) ==0b011010 && ((nobody[j]>>i)&=0b100101) ==0b100101)
                return 1;
        }
    }
    return 0;
}

int sleep_3(Min_min_B map,Min_min_B nobody,Min_min_B other){
    for(int i=0;i<11;i++){
        //..OOOX
        if((nobody[i] & nobody[i+1] & map[i+2] & map[i+3] & map[i+4] & other[i+5]).any())
            return 1;
        if((nobody[i] & nobody[i+1]>>1 & map[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4 & other[i+5]>>5).any())
            return 1;
        if((nobody[i] & nobody[i+1]<<1 & map[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4 & other[i+5]<<5).any())
            return 1;
        //XOO..
        if((other[i] & map[i+1] & map[i+2] & map[i+3] & nobody[i+4] & nobody[i+5]).any())
            return 1;
        if((other[i] & map[i+1]>>1 & map[i+2]>>2 & map[i+3]>>3 & nobody[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((other[i] & map[i+1]<<1 & map[i+2]<<2 & map[i+3]<<3 & nobody[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;
        //.O.OOX
        if((nobody[i] & map[i+1] & nobody[i+2] & map[i+3] & map[i+4] & other[i+5]).any())
            return 1;
        if((nobody[i] & map[i+1]>>1 & nobody[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4 & other[i+5]>>5).any())
            return 1;
        if((nobody[i] & map[i+1]<<1 & nobody[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4 & other[i+5]<<5).any())
            return 1;
        //XOO.O.
        if((other[i] & map[i+1] & map[i+2] & nobody[i+3] & map[i+4] & nobody[i+5]).any())
            return 1;
        if((other[i] & map[i+1]>>1 & map[i+2]>>2 & nobody[i+3]>>3 & map[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((other[i] & map[i+1]<<1 & map[i+2]<<2 & nobody[i+3]<<3 & map[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;
        //.OO.OX
        if((other[i] & map[i+1] & nobody[i+2] & map[i+3] & map[i+4] & nobody[i+5]).any())
            return 1;
        if((other[i] & map[i+1]>>1 & nobody[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((other[i] & map[i+1]<<1 & nobody[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;
        //XO.OO.
        if((other[i] & map[i+1] & nobody[i+2] & map[i+3] & map[i+4] & nobody[i+5]).any())
            return 1;
        if((other[i] & map[i+1]>>1 & nobody[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((other[i] & map[i+1]<<1 & nobody[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;
        //O..OO
        if((map[i] & nobody[i+1] & nobody[i+2] & map[i+3] & map[i+4]).any())
            return 1;
        if((map[i] & nobody[i+1]>>1 & nobody[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4).any())
            return 1;
        if((map[i] & nobody[i+1]<<1 & nobody[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4).any())
            return 1;
        //OO..O
        if((map[i] & map[i+1] & nobody[i+2] & nobody[i+3] & map[i+4]).any())
            return 1;
        if((map[i] & map[i+1]>>1 & nobody[i+2]>>2 & nobody[i+3]>>3 & map[i+4]>>4).any())
            return 1;
        if((map[i] & map[i+1]<<1 & nobody[i+2]<<2 & nobody[i+3]<<3 & map[i+4]<<4).any())
            return 1;
        //O.O.O
        if((map[i] & nobody[i+1] & map[i+2] & nobody[i+3] & map[i+4]).any())
            return 1;
        if((map[i] & nobody[i+1]>>1 & map[i+2]>>2 & nobody[i+3]>>3 & map[i+4]>>4).any())
            return 1;
        if((map[i] & nobody[i+1]<<1 & map[i+2]<<2 & nobody[i+3]<<3 & map[i+4]<<4).any())
            return 1;
        //X.OOO.X
        if((other[i] & nobody[i+1] & map[i+2] & map[i+3] & map[i+4] & nobody[i+5] & other[i+6]).any())
            return 1;
        if((other[i] & nobody[i+1]>>1 & map[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4 & nobody[i+5]>>5 & other[i+6]>>6).any())
            return 1;
        if((other[i] & nobody[i+1]<<1 & map[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4 & nobody[i+5]<<5 & other[i+6]<<6).any())
            return 1;

        for(int j=0;j<15;j++){
            if(((map[j]>>i)&=0b001110) ==0b001110 && ((nobody[j]>>i)&=0b110000) ==0b110000 && ((other[j]>>i)&=0b000001) ==0b000001)
                return 1;
            if(((map[j]>>i)&=0b011100) ==0b011100 && ((nobody[j]>>i)&=0b000011) ==0b000011 && ((other[j]>>i)&=0b100000) ==0b100000)
                return 1;
            if(((map[j]>>i)&=0b010110) ==0b010110 && ((nobody[j]>>i)&=0b101000) ==0b101000 && ((other[j]>>i)&=0b000001) ==0b000001)
                return 1;
            if(((map[j]>>i)&=0b011010) ==0b011010 && ((nobody[j]>>i)&=0b000101) ==0b000101 && ((other[j]>>i)&=0b100000) ==0b100000)
                return 1;
            if(((map[j]>>i)&=0b011010) ==0b011010 && ((nobody[j]>>i)&=0b100100) ==0b100100 && ((other[j]>>i)&=0b000001) ==0b000001)
                return 1;
            if(((map[j]>>i)&=0b010110) ==0b010110 && ((nobody[j]>>i)&=0b001001) ==0b001001 && ((other[j]>>i)&=0b100000) ==0b100000)
                return 1;
            if(((map[j]>>i)&=0b10011) ==0b10011 && ((nobody[j]>>i)&=0b01100) ==0b01100)
                return 1;
            if(((map[j]>>i)&=0b11001) ==0b11001 && ((nobody[j]>>i)&=0b00110) ==0b00110)
                return 1;
            if(((map[j]>>i)&=0b10101) ==0b10101 && ((nobody[j]>>i)&=0b01010) ==0b01010)
                return 1;
            if(((map[j]>>i)&=0b0011100) ==0b0011100 && ((nobody[j]>>i)&=0b0100010) ==0b0100010 && ((other[j]>>i)&=0b1000001) ==0b1000001)
                return 1;
        }
    }
    return 0;
}

int live_2(Min_min_B map,Min_min_B nobody){
    for(int i=0;i<11;i++){
        //..OO..
        if((nobody[i] & nobody[i+1] & map[i+2] & map[i+3] & nobody[i+4] & nobody[i+5]).any())
            return 1;
        if((nobody[i] & nobody[i+1]>>1 & map[i+2]>>2 & map[i+3]>>3 & nobody[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((nobody[i] & nobody[i+1]<<1 & map[i+2]<<2 & map[i+3]<<3 & nobody[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;
        //.O.O.
        if((nobody[i] & map[i+1] & nobody[i+2] & map[i+3] & nobody[i+4]).any())
            return 1;
        if((nobody[i] & map[i+1]>>1 & nobody[i+2]>>2 & map[i+3]>>3 & nobody[i+4]>>4).any())
            return 1;
        if((nobody[i] & map[i+1]<<1 & nobody[i+2]<<2 & map[i+3]<<3 & nobody[i+4]<<4).any())
            return 1;
        //.O..O
        if((nobody[i] & map[i+1] & nobody[i+2] & nobody[i+3] & map[i+4]).any())
            return 1;
        if((nobody[i] & map[i+1]>>1 & nobody[i+2]>>2 & nobody[i+3]>>3 & map[i+4]>>4).any())
            return 1;
        if((nobody[i] & map[i+1]<<1 & nobody[i+2]<<2 & nobody[i+3]<<3 & map[i+4]<<4).any())
            return 1;
        //O..O.
        if((map[i] & nobody[i+1] & nobody[i+2] & map[i+3] & nobody[i+4]).any())
            return 1;
        if((map[i] & nobody[i+1]>>1 & nobody[i+2]>>2 & map[i+3]>>3 & nobody[i+4]>>4).any())
            return 1;
        if((map[i] & nobody[i+1]<<1 & nobody[i+2]<<2 & map[i+3]<<3 & nobody[i+4]<<4).any())
            return 1;


        for(int j=0;j<15;j++){
            if(((map[j]>>i)&=0b001100) ==0b001100 && ((nobody[j]>>i)&=0b110011) ==0b110011)
                return 1;
            if(((map[j]>>i)&=0b01010) ==0b01010 && ((nobody[j]>>i)&=0b10101) ==0b10101)
                return 1;
            if(((map[j]>>i)&=0b01001) ==0b01001 && ((nobody[j]>>i)&=0b10110) ==0b10110)
                return 1;
            if(((map[j]>>i)&=0b10010) ==0b10010 && ((nobody[j]>>i)&=0b01101) ==0b01101)
                return 1;
        }
    }
    return 0;
}

int sleep_2(Min_min_B map,Min_min_B nobody,Min_min_B other){
    for(int i=0;i<11;i++){
        //...OOX
        if((nobody[i] & nobody[i+1] & nobody[i+2] & map[i+3] & map[i+4] & other[i+5]).any())
            return 1;
        if((nobody[i] & nobody[i+1]>>1 & nobody[i+2]>>2 & map[i+3]>>3 & map[i+4]>>4 & other[i+5]>>5).any())
            return 1;
        if((nobody[i] & nobody[i+1]<<1 & nobody[i+2]<<2 & map[i+3]<<3 & map[i+4]<<4 & other[i+5]<<5).any())
            return 1;
        //XOO...
        if((other[i] & map[i+1] & map[i+2] & nobody[i+3] & nobody[i+4] & nobody[i+5]).any())
            return 1;
        if((other[i] & map[i+1]>>1 & map[i+2]>>2 & nobody[i+3]>>3 & nobody[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((other[i] & map[i+1]<<1 & map[i+2]<<2 & nobody[i+3]<<3 & nobody[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;
        //..O.OX
        if((nobody[i] & nobody[i+1] & map[i+2] & nobody[i+3] & map[i+4] & other[i+5]).any())
            return 1;
        if((nobody[i] & nobody[i+1]>>1 & map[i+2]>>2 & nobody[i+3]>>3 & map[i+4]>>4 & other[i+5]>>5).any())
            return 1;
        if((nobody[i] & nobody[i+1]<<1 & map[i+2]<<2 & nobody[i+3]<<3 & map[i+4]<<4 & other[i+5]<<5).any())
            return 1;
        //XO.O..
        if((other[i] & map[i+1] & nobody[i+2] & map[i+3] & nobody[i+4] & nobody[i+5]).any())
            return 1;
        if((other[i] & map[i+1]>>1 & nobody[i+2]>>2 & map[i+3]>>3 & nobody[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((other[i] & map[i+1]<<1 & nobody[i+2]<<2 & map[i+3]<<3 & nobody[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;
        //.O..OX
        if((nobody[i] & map[i+1] & nobody[i+2] & nobody[i+3] & map[i+4] & other[i+5]).any())
            return 1;
        if((nobody[i] & map[i+1]>>1 & nobody[i+2]>>2 & nobody[i+3]>>3 & map[i+4]>>4 & other[i+5]>>5).any())
            return 1;
        if((nobody[i] & map[i+1]<<1 & nobody[i+2]<<2 & nobody[i+3]<<3 & map[i+4]<<4 & other[i+5]<<5).any())
            return 1;
        //XO..O.
        if((other[i] & map[i+1] & nobody[i+2] & nobody[i+3] & map[i+4] & nobody[i+5]).any())
            return 1;
        if((other[i] & map[i+1]>>1 & nobody[i+2]>>2 & nobody[i+3]>>3 & map[i+4]>>4 & nobody[i+5]>>5).any())
            return 1;
        if((other[i] & map[i+1]<<1 & nobody[i+2]<<2 & nobody[i+3]<<3 & map[i+4]<<4 & nobody[i+5]<<5).any())
            return 1;
        //O...O
        if((map[i] & nobody[i+1] & nobody[i+2] & nobody[i+3] & map[i+4]).any())
            return 1;
        if((map[i] & nobody[i+1]>>1 & nobody[i+2]>>2 & nobody[i+3]>>3 & map[i+4]>>4).any())
            return 1;
        if((map[i] & nobody[i+1]<<1 & nobody[i+2]<<2 & nobody[i+3]<<3 & map[i+4]<<4).any())
            return 1;

        for(int j=0;j<15;j++){
            if(((map[j]>>i)&=0b000110) ==0b000110 && ((nobody[j]>>i)&=0b111000) ==0b111000 && ((other[j]>>i)&=0b000001) ==0b000001)
                return 1;
            if(((map[j]>>i)&=0b011000) ==0b011000 && ((nobody[j]>>i)&=0b000111) ==0b000111 && ((other[j]>>i)&=0b100000) ==0b100000)
                return 1;
            if(((map[j]>>i)&=0b001010) ==0b001010 && ((nobody[j]>>i)&=0b110100) ==0b110100 && ((other[j]>>i)&=0b000001) ==0b000001)
                return 1;
            if(((map[j]>>i)&=0b010100) ==0b010100 && ((nobody[j]>>i)&=0b001011) ==0b001011 && ((other[j]>>i)&=0b100000) ==0b100000)
                return 1;
            if(((map[j]>>i)&=0b010010) ==0b010010 && ((nobody[j]>>i)&=0b101100) ==0b101100 && ((other[j]>>i)&=0b000001) ==0b000001)
                return 1;
            if(((map[j]>>i)&=0b010010) ==0b010010 && ((nobody[j]>>i)&=0b001101) ==0b001101 && ((other[j]>>i)&=0b100000) ==0b100000)
                return 1;
            if(((map[j]>>i)&=0b10001) ==0b10001 && ((nobody[j]>>i)&=0b01110) ==0b01110)
                return 1;
        }
    }
    return 0;
}

int Thing::values(){
    Min_min_B my_map=map[this->player];
    Min_min_B other_map=map[3-this->player];
    Min_min_B nobody=map[0];
    int values=0;
    int reduce=0;
    int v=0;

    if(continuous_5(my_map)) values=99999999;
    if(continuous_4(my_map,nobody)) values+=9999999;
    if(die_4(my_map,nobody,other_map)) values+=200;//200.100
    if(live_3(my_map,nobody)) values+=230;//230.120
    if(sleep_3(my_map,nobody,other_map)) values+=90;
    if(live_2(my_map,nobody)) values+=30;
    if(sleep_2(my_map,nobody,other_map)) values+=5;

    if(continuous_5(other_map)) reduce+=99999999;
    if(continuous_4(other_map,nobody)) reduce+=9999999;
    if(die_4(other_map,nobody,my_map)) reduce+=100;//200.100
    if(live_3(other_map,nobody)) reduce+=120;//120
    if(sleep_3(other_map,nobody,my_map)) reduce+=90;
    if(live_2(other_map,nobody)) reduce+=30;
    if(sleep_2(other_map,nobody,my_map)) reduce+=5;

    return (values-reduce);
}

Thing::Thing(The_Board board,int player): map(board),player(player){
    behavior=this->The_behavior();
}

vector<Point> Thing::The_behavior(){
    vector<Point> moves;
    Min_min_B have_inside;
    int flag=0;

    for(auto e:to_move){
        if(!map[0][e.x][e.y]){
            flag=1;         //確定棋盤上是有棋的
            for(auto beside:Beside){
                int new_x=e.x+beside[0];
                int new_y=e.y+beside[1];
                if(new_x>=0 && new_y>=0 &&  new_x<15 && new_y<15 && !have_inside[new_x][new_y] && map[0][new_x][new_y]){
                    have_inside[new_x][new_y]=1;
                    moves.push_back(Point(new_x,new_y));
                }
            }
        }
    }

    //都沒有棋棋~第一顆棋放中間
    if(!flag) moves.push_back(Point(7,7));

    return moves;    
}

Thing* Thing::The_nextone(Point mov){
    vector<Point> moves;
    Min_min_B have_inside;

    for(Point e:this->behavior){
        if(e!=mov){
            have_inside[mov.x][mov.y]=1;
            moves.push_back(mov);
        }
    }
 
    for(auto beside:Beside){
        int new_x=mov.x+beside[0];
        int new_y=mov.y+beside[1];
        if(new_x>=0 && new_y>=0 &&  new_x<15 && new_y<15 && !have_inside[new_x][new_y] && map[0][new_x][new_y]){
            have_inside[new_x][new_y]=1;
            moves.push_back(Point(new_x,new_y));
        }
    }

    Thing *nextone= new Thing();
    nextone->map=this->map;
    nextone->player=3-this->player;
    nextone->map[3-nextone->player][mov.x][mov.y]=1;
    nextone->map[0][mov.x][mov.y]=1;
    nextone->behavior=moves;

    return nextone;
}

//----------origin.cpp----------//

Thing o_one;
void read_board(std::ifstream& fin) {
    The_Board board;
    int player;
    fin >> player;
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            board[0][i][j]=board[1][i][j]=board[2][i][j]=0;
            int cat;
            fin>>cat;
            board[cat][i][j]=1;
        }
    }

    o_one=Thing(board,player);
}

void write_valid_spot(std::ofstream& fout) {

    while(true) {
        auto new_one=Minimax::moving(&o_one,1);
        if (new_one.x!=15 && new_one.y!=15) {
            fout << new_one.x << " " << new_one.y << endl;
            // Remember to flush the output to ensure the last action is written to file.
            fout.flush();
        }
    }
}

int main(int, char** argv) {
    ifstream fin(argv[1]);
    ofstream fout(argv[2]);
    start();
    read_board(fin);
    write_valid_spot(fout);
    fin.close();
    fout.close();
    return 0;
}