1 00:00:06,110 --> 00:00:08,580 Having a formal description of a game is one thing. 2 00:00:08,580 --> 00:00:09,960 Being able to use that description to 3 00:00:09,960 --> 00:00:12,450 play the game effectively is something else entirely. 4 00:00:13,620 --> 00:00:16,370 In this lesson, we discuss strategies for building general game 5 00:00:16,370 --> 00:00:18,979 players and some of the difficulties that need to be handled. 6 00:00:21,660 --> 00:00:24,610 Since game descriptions are written in logic, it's obviously necessary 7 00:00:24,610 --> 00:00:27,270 for a game player to do some amount of automated reasoning. 8 00:00:28,400 --> 00:00:29,740 Now, there are two extremes here. 9 00:00:29,740 --> 00:00:31,850 One possibility is for the game player 10 00:00:31,850 --> 00:00:34,700 to process the description interpretively throughout a game. 11 00:00:36,230 --> 00:00:39,260 The second possibility is for a player to use the description to 12 00:00:39,260 --> 00:00:43,310 devise a specialized program and then use that program to play the game. 13 00:00:44,360 --> 00:00:46,240 This is effectively automatic programming. 14 00:00:47,540 --> 00:00:50,420 In this lesson, we're going to discuss the first possibility and leave it 15 00:00:50,420 --> 00:00:55,450 to you to think about the second possibil, bility and various hybrid approaches. 16 00:00:55,450 --> 00:00:57,800 We discuss this second approach later in the course. 17 00:01:00,740 --> 00:01:02,010 We begin the lesson by talking about 18 00:01:02,010 --> 00:01:04,260 some infrastructure that frames the problem more precisely. 19 00:01:04,260 --> 00:01:07,627 We then consider a couple of search free uses 20 00:01:07,627 --> 00:01:14,027 of this instra, infrastructure, namely legal players and random players. 21 00:01:14,027 --> 00:01:19,923 In lessons five through eight, we look at complete search strategies which are 22 00:01:19,923 --> 00:01:25,995 appropriate for small game trees and incomplete search strategies which are 23 00:01:25,995 --> 00:01:28,469 necessary for large game trees. 24 00:01:28,469 --> 00:01:32,489 In lessons nine through 12, we examine some game playing techniques based on 25 00:01:32,489 --> 00:01:34,589 the properties of states rather than 26 00:01:34,589 --> 00:01:37,494 properties of states rather than monolithic states. 27 00:01:37,494 --> 00:01:43,174 And finally, in lessons 13 through 16, we show ways that game descriptions can 28 00:01:43,174 --> 00:01:45,814 be used to deduce general properties of 29 00:01:45,814 --> 00:01:49,824 games without enumerating states or properties of those. 30 00:01:49,824 --> 00:01:51,303 Game players typically implement 31 00:01:51,303 --> 00:01:52,660 it as a web service. 32 00:01:52,660 --> 00:01:54,620 As soon as it begins running, the player enters 33 00:01:54,620 --> 00:01:57,872 a loop, listening for messages from the game manager. 34 00:01:57,872 --> 00:02:01,830 Upon receipt of a message, the player calls 35 00:02:01,830 --> 00:02:05,860 an appropriate handler for that type of message. 36 00:02:05,860 --> 00:02:09,790 When the handler is finished, player sends the return value to the game manager. 37 00:02:11,660 --> 00:02:13,840 Given this architecture, building a game player 38 00:02:13,840 --> 00:02:16,350 means writing event handlers for the different types 39 00:02:16,350 --> 00:02:19,770 of messages in the GGP communication protocol. 40 00:02:22,190 --> 00:02:25,220 There's typically one handler for each type of message. 41 00:02:25,220 --> 00:02:28,440 Info, start, play, stop and abort. 42 00:02:28,440 --> 00:02:31,110 So, that means writing five event handlers. 43 00:02:33,860 --> 00:02:35,520 In order to make the implementation of 44 00:02:35,520 --> 00:02:38,440 these message handlers a little easier, the GGP 45 00:02:38,440 --> 00:02:40,190 a code base available in the course 46 00:02:40,190 --> 00:02:43,270 website contains definitions for the subroutines shown here. 47 00:02:44,910 --> 00:02:47,500 there's subroutines for computing the key components of a game. 48 00:02:48,500 --> 00:02:52,480 For example, findrules produces a list of role find 49 00:02:52,480 --> 00:02:55,160 findroles, produces a list of roles in the game. 50 00:02:55,160 --> 00:02:58,890 Findinits gives a list of sentences true in the initial state. 51 00:02:58,890 --> 00:03:03,190 There are also some utility routines to make our job easier. 52 00:03:03,190 --> 00:03:05,970 For example, doesify takes a list of roles and 53 00:03:05,970 --> 00:03:08,210 a list of actions as argument, produces a list of 54 00:03:08,210 --> 00:03:11,330 sentences stating that each role specified in the roles 55 00:03:11,330 --> 00:03:15,720 argument executes the corresponding action specified in the actions argument. 56 00:03:15,720 --> 00:03:17,590 And then undoesify reverses this process. 57 00:03:17,590 --> 00:03:20,040 You'll see how that plays into the definitions a little later. 58 00:03:20,040 --> 00:03:20,540 Now, 59 00:03:23,300 --> 00:03:25,640 your job in building a player as I mentioned earlier is to 60 00:03:25,640 --> 00:03:30,930 use the subroutines provided to write the handlers called by the message handler. 61 00:03:30,930 --> 00:03:32,480 In these next two segments, we're going to look 62 00:03:32,480 --> 00:03:34,620 at a couple of simple approaches for doing this. 63 00:03:35,910 --> 00:03:38,860 Now, we're going to present the definitions in JavaScript. 64 00:03:38,860 --> 00:03:40,230 Yeah, you can use these yourself if 65 00:03:40,230 --> 00:03:42,550 you're building your player directly in JavaScript or 66 00:03:42,550 --> 00:03:43,900 you can adjust them as appropriate to 67 00:03:43,900 --> 00:03:46,250 implement in a Java based version for example. 68 00:03:47,280 --> 00:03:48,420 Alternatively, 69 00:03:48,420 --> 00:03:49,830 you can click the appropriate box in the 70 00:03:49,830 --> 00:03:54,140 parametric player to select from among different approaches. 71 00:03:54,140 --> 00:03:57,330 In the slider case you don't need to type in any code at all, but you'd look 72 00:03:57,330 --> 00:03:58,800 at the code that we present so that you 73 00:03:58,800 --> 00:04:01,010 know what's going on when you make your selections. 74 00:04:01,010 --> 00:04:05,330 [SOUND]