User Tools

Site Tools


lab_5

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

lab_5 [2018/05/18 11:09]
hutch [Overall Grading]
lab_5 [2018/10/09 07:38] (current)
hutch
Line 53: Line 53:
  
 Notes: ​ Notes: ​
-  * For the pseudocode shown below, **choice** is a global variable that will hold the move computed by minimax. Minimax must return at least a score because that is how you build the move-score table recursively. However, minimax must also compute the move because it is associated with the score. So, when doing the max calculation for example, you find the index of the highest score in the list and then save the move associated with that score in **choice**. **choice** will be overwritten many times as minimax executes but that is OK. The only move you care about is the move associated with the max score at the first call of minimax. That will also be the last time that **choice** is written so it will contain the move you care about - the move associated with the highest score (assuming that you are the player).+  * For the pseudocode shown below, **choice** is a global variable that will hold the move computed by minimax. Minimax must return at least a score because that is how you build the move-score table recursively. However, minimax must also compute the move because it is associated with the score. So, when doing the max calculation for example, you find the index of the highest score in the list and then save the move associated with that score in **choice**. **choice** will be overwritten many times as minimax executes but that is OK. The only move you care about is the move associated with the max score at the first call of minimax. That will also be the last time that **choice** is written so it will contain the move you care about - the move associated with the highest score (assuming that you are '​X'​).
   * move can be implemented as a struct containing a row and a column.   * move can be implemented as a struct containing a row and a column.
   * You can store your moves and scores in two arrays: a moves array and a scores array. Use one index for both.   * You can store your moves and scores in two arrays: a moves array and a scores array. Use one index for both.
Line 185: Line 185:
  
 === Requirements === === Requirements ===
-  - You will provide two files''​minimax.h''​ and ''​minimax.c''​. The contents of minimax.h must be exactly what is provided below.+  - You will write one file: ''​minimax.c''​. The contents of minimax.h must be exactly what is provided below.
   - You must provide the functions listed below via the .h file. You must use these data-structures,​ #define, etc., for the listed functions. Please implement helper functions in the .c file (not advertised in the .h file) to make your code modular and easier to read and to debug.   - You must provide the functions listed below via the .h file. You must use these data-structures,​ #define, etc., for the listed functions. Please implement helper functions in the .c file (not advertised in the .h file) to make your code modular and easier to read and to debug.
   - You must test your minimax algorithm by writing at least 10 additional test-boards (see provided test code below). The TA will check for this.   - You must test your minimax algorithm by writing at least 10 additional test-boards (see provided test code below). The TA will check for this.
  
  
-<code>+<file C minimax.h>
 #include <​stdint.h>​ #include <​stdint.h>​
 // Defines the boundaries of the tic-tac-toe board. // Defines the boundaries of the tic-tac-toe board.
Line 234: Line 234:
 // 1. If the computer is playing as X, you will call this function with current_player_is_x = true. // 1. If the computer is playing as X, you will call this function with current_player_is_x = true.
 // 2. If the computer is playing as O, you will call this function with current_player_is_x = false. // 2. If the computer is playing as O, you will call this function with current_player_is_x = false.
-// minimax_computeNextMove directly passes the current_player_is_x argument into the minimax() function.+// minimax_computeNextMove directly passes the current_player_is_x argument into the minimax() (helper) function.
 // To assign values to the row and column arguments, you must use the following syntax in the body of the function: // To assign values to the row and column arguments, you must use the following syntax in the body of the function:
 // *row = move_row; *column = move_column;​ (for example). // *row = move_row; *column = move_column;​ (for example).
Line 255: Line 255:
 // Init the board to all empty squares. // Init the board to all empty squares.
 void minimax_initBoard(minimax_board_t* board); void minimax_initBoard(minimax_board_t* board);
-</code>+</file>
 === Pass-Off === === Pass-Off ===
 To pass the algorithm milestone, you need to demonstrate your minimax program providing the correct answer for several provided boards and **for 10 additional boards** that you must write. After adding your test boards to the test-code below, test your minimax program using the program shown below. To pass the algorithm milestone, you need to demonstrate your minimax program providing the correct answer for several provided boards and **for 10 additional boards** that you must write. After adding your test boards to the test-code below, test your minimax program using the program shown below.
Line 346: Line 346:
 The tic-tac-toe package will consist of two files: ''​ticTacToeDisplay.c''​ and ''​ticTacToeDisplay.h.''​ You must implement at least these functions and make them available in the ''​ticTacToeDisplay.h''​ file: The tic-tac-toe package will consist of two files: ''​ticTacToeDisplay.c''​ and ''​ticTacToeDisplay.h.''​ You must implement at least these functions and make them available in the ''​ticTacToeDisplay.h''​ file:
  
-<code C>+<file ticTacToeDisplay.h>
 #include <​stdint.h>​ #include <​stdint.h>​
 #include <​stdbool.h>​ #include <​stdbool.h>​
Line 374: Line 374:
 void ticTacToeDisplay_drawBoardLines();​ void ticTacToeDisplay_drawBoardLines();​
  
-</code>+</file>
  
 === Notes === === Notes ===
lab_5.1526663374.txt.gz ยท Last modified: 2018/05/18 11:09 by hutch