Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
COMP 2710 Software Construction Project 1 – Design: Scoreboard and Puzzles Data Structures Function Prototypes Dr. Xiao Qin Auburn University http://www.eng.auburn.edu/~xqin [email protected] Exercise 1 • Design a data structure for a scoreboard • Using a singly linked list to construct a group of records 1-2 • Design a data structure for a scoreboard • Using a singly linked list to construct a group of records struct score_node { string name; int score; //unsigned score_node* next; //next_score_node }; typedef score_node* score_node_ptr; typedef unsigned short u_short; 1-3 Exercise 2 • Create a scoreboard variable • Initialize the scoreboard variable 1-4 • Create a scoreboard variable • Initialize the scoreboard variable struct score_board { u_short num_of_scores; score_node_ptr first_score_node; }; score_board game_scoreboard = {0; NULL}; 1-5 Exercise 3 • Design function prototypes to access scoreboard • What are function names? • What are function parameter lists? 1-6 • Design function prototypes to access scoreboard • What are function names? • What are functions’ parameter lists? void view_scores(score_board s_board); int load_scores(score_board & s_board); int load_scores(score_board & s_board, const char filename[]); int save_scores(score_board s_board); int save_scores(score_board s_board, const char filename[]); 1-7 Exercise 4 • Design a data structure for player • What are the elements of a player? 1-8 • Design a data structure for player • What are the elements of a player? struct player { u_int money; u_int time; u_int intel; int score; }; 1-9 Exercise 5: • • • • Design a data structure for puzzles What are the elements of a puzzle? How to model penalty/reward of each puzzle? Keep in mind penalty/reward is related to attributes (i.e., MONEY, TIME, INTEL) 1-10 • Design a data structure for puzzles • How to model penalty/reward of each puzzle? enum attribute_t {MONEY, TIME, INTEL}; enum action_t {PENALTY, REWARD}; struct action { action_t action_type; attribute_t attr_type; u_short points; }; struct puzzle { string question; string key; action action_array[MAX_ACTION_NUM]; //2 u_short num_of_actions; }; 1-11 Exercise 6 • Design a data structure for encounter • What are differences between a puzzle and an encounter? • How to extend or modify the puzzle data structure to design the encounter data structure? 1-12 • Design a data structure for encounter • What are differences between a puzzle and an encounter? 1-13 Exercise 7 • Design function prototypes to manage puzzle • Can you outline a data flow diagram for the module that manages puzzles? • Data Structure: – How to manage puzzles in form of a puzzle list? • Function Prototypes: – What are the function names? – What are parameter lists? 1-14 • Design function prototypes to manage puzzle 1-15