-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
140 lines (108 loc) · 3.39 KB
/
README
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
barakdiker
313538225
noa.babliki
206090409
=====================================
ex.12 connect four
=====================================
=====================================
Description
=====================================
This is a game of connect four!
In order to play, please choose how you want to play:
human or AI, for player 1 or player 2.
Than, please choose a color for each player.
If you chose human player, please press the column in
The board you want to insert your checker to.
AI will play automaticaly.
Your goal in to have 4 checkers in a row, in your color.
When the game is over, it will ask you if you wanna play again,
and than play a short animation. after the animation, the
game will start again
If you choose to quit, the game will play the short
animation and quit.
Enjoy!
=====================================
AI bonus
=====================================
The AI engine is based on dictionary which evaluate each move
by giving each move a score
if the score is high ,it means that the move is good
=====================================
Criteria AI 1
=====================================
The evaluation is based on couple characteristics
1)counts the possible 4 in a next move point :
Assume 1:
"1" to Move
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
- 0 0 0 0 0
The - point has 3 possible winning : slant column and row
Assume 2:
"2" to Move
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
- 0 1 0 0 0
In this position player "2" in the - point
has only 2 possible winning options that why
Assume 1 > Assume 2
meaning assume 1 has better score in this regard
Assume 3:
"2" to Move
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 - 0 0 0
move -> - has 3 possible wins in rows
also 1 in slant
and 1 in column
that's why he'll receive 5 points
and that's why -> Assume 3 > Assume 2 > Assume 1
=====================================
Criteria AI 2
=====================================
I did the exact same thing as "Criteria AI 1"
with a new change it gives an evaluation for 3 instead of 4
=====================================
Criteria AI 3
=====================================
If player moves and this move make the opponent winning in 1 move
Than the computer really hate this move
=====================================
No GUI
=====================================
Game Play Interface:
In order to play the game with no GUI
you should use the following commands
make_move(num_of_column int)
get_current_player()
get_player_at(x int, y int)
Easy sample No GUI:
g = Game()
g.make_move(0)
# This simple function checks who needs to play
if g.get_current_player() == Game.WHITE:
print("It's White turn to play")
if g.get_current_player() == Game.BLACK:
print("It's Black turn to play")
#
g.make_move(1)
g.make_move(0)
g.make_move(1)
g.make_move(0)
if g.get_player_at(1, 0) == Game.WHITE:
print("White is occupying (1,0) point")
if g.get_player_at(1, 0) == Game.BLACK:
print("Black is occupying (1,0) point")
if g.get_player_at(0, 0) is None:
print("no body is occupying (1,0) point")
# Prints the board
print(g.board)
#
References:
The reason we decide to go with array is the following website->
list vs array (numpy)
https://webcourses.ucf.edu/courses/1249560/pages/python-lists-vs-numpy-arrays-what-is-the-difference