-
Notifications
You must be signed in to change notification settings - Fork 0
barakdiker123/ex12
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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
About
lmplementation of 4 in a row
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published