Artificial intelligence production in computer games

zhaozj2021-02-08  242

Computer games have greatly improved hardware execution efficiency and display resolution, and many computer games that have many impossible or very difficult or very difficult-to-realization have been successfully completed. Although the presentation of computer games is diversified, but the theme of our discussion today, artificial intelligence has almost unpryunated relationships. In the role playing game, the programmer and the planner need to accurately create a so-called "monster" in the computer, so that the half-orc people are seriously injured and know how to escape, the Master knows how to show the attack . It is currently possible to immediately think of two games with artificial intelligence. There are two types: First, the so-called war / strategy simulation game, two is a chess game. The specific gravity of artificial intelligence is different, and there are different in different game types. Some computer games are not marigned with high artificial intelligence. Otherwise no one is buying; some is almost embarrassing to make players can't feel any artificial intelligence. Guided thinking about AI is the most easy to make, and it is also the main direction of early game Ai development is the rule orientation or called hypothesis. In some simple computer games, programmers can do not difficult to convert rules in the game with settings into a rule, and then write them into computer programs. Let us play a role playing game as an example. Most of the plans to set the so-called computer monsters, the settings are usually the following: The last "attribute" of the health of the validity attack power, the last "attribute" is one of the items I like to increase during setting. Through this attribute setting, I can set the monster into "fear of death", or set the soldiers to "deceiving". With the information we have mastered, the outline in the battle system is born: Rule one if (health <10) // is dead dead? {If (attribute == greed is afraid of death) Result = try to escape if IF (There is any item or spell that restores your life) results = use or display related items or spells} Rules IF (Against Aggressive && Is sufficient mana) {Results = Show attack aerodynamic} from the above series of " If - "" rule setting, the most basic AI is established. Saying such a method can only establish basic AI is actually not correct. As long as there is sufficient and accurate rules, this way still has a certain level of performance. The biggest advantage of rules orientation is easy to learn. Without the premise of the theoretical concept of the Olympics, there is still a large number of uses. Therefore, many old players often don't touch the enemy's attack strategy, mobile methods, and so on. Introduction, I believe that friends who have come into contact with computer language or self-study have heard a famous procedure, which is a well-known program. Using a well-word game as a introductory textbook that discusses AI, I personally feel the most appropriate example. Maybe someone still doesn't know how to play in the well. As long as any party, first, first, first, first, first, first line. We can also derive the field here in the previously talked.

No one of our lines of us, there is still an empty // I am about to become a line, the result = the space IF Any one line has an enemy two sons && Die still empty / / prevents the enemy from making a first line = This space If any one of the IF, I have a single child, and the other two grids are still empty // is made into two sons, and I have a single computer book, and I also see some well-known game games in a single computer book. Example. Different, I can't see any rule-oriented shadow. But after careful analysis of the program code, I got a great inspiration. It turns out that AI can be made without so many rules. It is used by the method in the computer AI course: the great ministerial method. I only explain the concept of this law here. Continue to take a well-known game as an example, the computer will take a certain place, followed by a hypothetical manner, of course, must assume that the other party is the best position, otherwise everything is meaningless. In the process of assumed the other party, naturally need to suppress our next step in response, so that it is until the full bureau game.

Under the bottom of the program fragment: Bestmove (int LAsttie; int Lastmove; int subv; / * firstmove; int subv; / * first, check for a TIE * / IF (ISTIE ()) {* v = 0; RETURN (0);}; / * if not a TIE, TRY Each Potential Move * / for (* v = -1, lasttie = Lastmove = -1, i = 0; i <9; i ) {/ * If this isn't a possible, skip it * / if (Board [i]! = 0) Continue; / * make the move. * / Lastmove = i; Board [i] = p; / * DID IT WIN? * / If (Haswon (P)) * v = 1; Else {/ * if not, Find Out How Good The Other Side Can Do * / Bestmove (-P, & SUBV); / * fy can only lose, this is STILL A WIN. * / IF (SUBV == - 1) * v = 1; / * OR, IF IT's A TIE, Remember It. * / else IF (SUBV == 0) { * v = 0; LastTie = I;};}; / * Take back the move. * / board [i] = 0; / * f We found a win, return IMMEDITELY (CAN't do any better tha Tat) * / If (* v == 1) RETURN (i); / * if We Didn't Find ANY WINS, RETURN A TIE MOVE. * / IF (* v == 0) Return (Lasttie); / * if there 't Even any Ties, Return a loosing move. * / else return (lastmove);}; Some of the foreign forums have held 256 bytes of game design competitions. There are a lot of works, one of which is just a well-known game. The author used more than two hundred lines in the district, and the same work is exactly the same as the above program, and the visible skills are indeed.

In addition, I also hope that similar activities can be launched in China. By the way, in such a chance limit, there is almost no other choice in addition to assembly language. .386c code segment cs: code, DS: CODEG 100H TICTAC Proc Far Start: Push CS Pop DS MOV AX, 0B800H; Clear Screen MOV ES, AX; XOR DI, DI; MOV CX, 7D0H; MOV AX , 0F20H; REP Stosw; XOR CX, CX; MOV DL, 5 LOC_1: Call Printboard Loc_2: MOV AH, 8; Waiting button INT 21h Movzx BX, Al Sub Bl, 31h; if not 1..9 jc LOC_2; Enter CMP BL, 8 JA LOC_2 CMP DATA_1 [BX], Al JNE LOC_2 MOV BYTE PTR DATA_1 [BX], 'X' DEC DL JZ Short Loc_3 MOV Al, 'O' Call Bestmove Mov [Si], Al Call Iswin; Judgment Whether to win JNC LOC_1 LOC_3 : Call PrintBoard MoV AX, 4C00H INT 21H DATA_1 DB '12' DATA_2 DB '3456789'

data_3 db 0 tictac endp printBoard proc near mov si, offset data_1 mov di, 548h mov cl, 3 locloop_4: movsb add di, 5 movsb add di, 5 movsb add di, 133h loop locloop_4 retn printBoard endp isWin proc near mov bx, 1 MOV BP, 3 Call Sub_3; Check whether the horizontal is completed Inc BX Inc BX DEC BP DEC BP CALL SUB_3; Check if the longitudinal direction completes Call Sub_4;

Check the oblique handle CLC Retn Iswin Endp Loc_5: STC RETN SUB_3 Proc Near MOV AH, 3 MOV SI, OFFSET DATA_1 LOC_6: MOV DI, SI CALL SUB_5 Add Si, BP Dec AH JNZ LOC_6 RETN SUB_3 ENDP SUB_4 Proc Near MOV DI, Offset Data_1 Inc BX Call Sub_5 MOV DI, Offset Data_2 Dec BX Dec BX Call Sub_5 Retn SUB_4 ENDP SUB_5 Proc Near Mov Cl, 3 Locloop_7: CMP [DI], Al Jne Short Loc_Ret_8 Add Di, BX Loop Locloop_7 Add SP, 4 JMP Short Loc_5 Loc_Ret_8:

RETN SUB_5 ENDP BESTMOVE PROC NEAR MOV BX, 31FEH MOV CL, 9 MOV DI, OFFSET DATA_1 LOCLOOP_9: CMP [Di], BH; #EMPTY? JNE Short Loc_12; #no, skip mov [di], al pusha call iswin; # CY: WIN POPA; JNC Short Loc_10; MOV BL, 1 MOV SI, DI MOV [DI], BH RETN LOC_10: Pusha XOR Al, 17h; Good! Toggle 'O' / 'X'

转载请注明原文地址:https://www.9cbs.com/read-1386.html

New Post(0)