-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchessMPI.cpp
More file actions
57 lines (49 loc) · 1.47 KB
/
chessMPI.cpp
File metadata and controls
57 lines (49 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <string.h>
#include <cstddef>
#include "cGame.h"
#include "pieceSquareTables.h"
int worldSize, rank;
MPI_Datatype customType;
int main(int argc, char **argv)
{
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &worldSize);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
//creating a custom MPI type for the mpiBoardState struct defined in cBoardState.h
int blockLength = 75;
MPI_Aint displacement = 0;
MPI_Datatype type = MPI_INT;
MPI_Type_create_struct(1, &blockLength, &displacement, &type, &customType);
MPI_Type_commit(&customType);
if(argc == 1)
{
if(rank == 0)
std::cout << "Entering Player vs Player mode" << std::endl;
cGame::fGetGame()->fRun(PVP);
}
else if(argc == 2)
{
if(strcmp(argv[1], "pva") == 0)
{
if(rank == 0)
std::cout << "Entering Player vs AI mode" << std::endl;
cGame::fGetGame()->fRun(PVA);
}
else if(strcmp(argv[1], "ava") == 0)
{
if(rank == 0)
std::cout << "Entering AI vs AI mode\n" << std::endl;
cGame::fGetGame()->fRun(AVA);
}
else
if(rank == 0)
std::cout << "usage: " << argv[0] << "<optional args>\n <optional args> = pva , ava.\n pva = Player vs AI. ava = AI vs AI\n" << std::endl;
}
else
if(rank == 0)
std::cout << "usage: " << argv[0] << "<optional args>\n <optional args> = pva , ava.\n pva = Player vs AI. ava = AI vs AI\n" << std::endl;
cGame::fEndGame();
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
return 0;
}