first polynomial attempt

master
gitJustin86 5 years ago
parent 7804775b99
commit eb3a05ac61

@ -1,15 +1,15 @@
#CC=g++-4.2
#
#a.out: main.o SerialComm.o
# g++ main.o SerialComm.o -lboost_system -lboost_filesystem -lboost_serialization -lpthread -std=c++11
#
#main.o: main.cpp
# g++ -c -std=c++11 main.cpp
#
#SerialComm.o: SerialComm.cpp SerialComm.hpp
# g++ -c -std=c++11 SerialComm.cpp
chess.out: functions.o
g++ chess.o functions.o -std=c++11
chess.o: chess.cpp
g++ -c -std=c++11 chess.cpp
functions.o: functions.cpp functions.h
g++ -c -std=c++11 functions.cpp
default: build
build:
g++ -o chess.out chess.cpp -std=c++11
#build:
# g++ -o chess.out chess.cpp -std=c++11

@ -2,6 +2,7 @@
#include <stdio.h>
#include <string>
#include "constants.h"
#include "functions.h"
// See constants.h for CHESS_CHARS, and DEFAULT_BOARD
@ -15,4 +16,7 @@ int main(){
}
cout << endl;
}
cout << "poly test" << endl;
cout << "(1," << poly_knight_offset_x(1) << ")" << endl;
}

@ -4,6 +4,7 @@
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <math.h>
// TODO implement functions.h functions.
// NOTE tests will NOT run unless you implement these functions.
@ -41,6 +42,18 @@ std::vector<Position> get_possible_moves(Position pn, std::array<PieceType, 64>
return pns;
}
int poly_knight_offset_x(int x) {
return -2.1500176772557799*pow(10,2)*pow(x,0) +
+5.0175460279545990*pow(10,2)*pow(x,1) +
-4.3971301635198080*pow(10,2)*pow(x,2) +
+1.9251081929895420*pow(10,2)*pow(x,3) +
-4.6354931502296793*pow(10,1)*pow(x,4) +
+6.2293079395174518*pow(10,0)*pow(x,5) +
-4.3751543665888198*pow(10,1)*pow(x,6) +
+1.2500918807028260*pow(10,2)*pow(x,7) +
-2.2939912578846349*pow(10,8)*pow(x,8);
}
std::vector<Position> get_all_moves(Position pn, std::array<PieceType, 64> board){
PieceType pt = board[pn];
std::vector<Position> pns;

@ -1,6 +1,13 @@
#include "constants.h"
#include <utility>
#include <vector>
#include <math.h>
// x offset for knight
int poly_knight_offset_x(int x);
// y offset for knight
int poly_knight_offset_y(int y);
// Convert pair of x y coordinates to Position enum member.
// If pr contains values above 7, or below 0 it will fail with an InvalidArgument exception.

Loading…
Cancel
Save