Fuzzy and GP Bot Contents Fuzzy BOT GP
Fuzzy and GP Bot
Contents • Fuzzy BOT • GP BOT • Competition Unreal Tournament 2 / 34
Fuzzy control application on a Traffic Road 퍼지 교통제어 inputs Fuzzy Logic Control Inputs={Arrival, Queue} Output={Extension} output
Fuzzy control Traffic simulator N Front detector W E Arrival : Green 신호에 진입한 차량 수 N(7대), S(8대)=15대 Rea r de tec tor Queue : Red 신호에 대기하는 차량 수 W(6대), E(5대)=11대 S
Fuzzy control 추론 Primitive time(기본주기) : 18초, A=10, Q=20 Extension time : Primitive time 이외의 연장 시간 f 1 : A=10 & Q=20 f 2 : A=20 & Q=5 f 3 : A=0 & Q=0 then E=0초 E=10초 E=? 초
Fuzzy control 1. Fuzzy input variables & their membership functions zero 0 1 2 zero 0 1 light 3 4 normal 5 short 2 3 6 heavy 7 medium 4 5 6 8 zero 9 0 10 1 long 7 8 9 10 light 2 3 4 normal 5 6 heavy 7 8 9 10
Fuzzy control 2. Fuzzy control rules(rule의 개수 4*4=16) Extension
Fuzzy control <규칙설명> R 1 : if Arrival = Z and Queue = Z then Extension = Z(Zero) R 2 : if Arrival = Z and Queue = S then Extension = Z R 3 : if Arrival = Z and Queue = M then Extension = Z R 4 : if Arrival = Z and Queue = L then Extension = Z R 5 : if Arrival = S and Queue = Z then Extension = S(Short) R 6 : if Arrival = S and Queue = S then Extension = Z R 7 : if Arrival = S and Queue = M then Extension = Z R 8 : if Arrival = S and Queue = L then Extension = Z R 9 : if Arrival = M and Queue = Z then Extension = M(Medium) R 10 : if Arrival = M and Queue = S then Extension = S R 11 : if Arrival = M and Queue = M then Extension = Z R 12 : if Arrival = M and Queue = L then Extension = Z R 13 : if Arrival = L and Queue = Z then Extension = L(Long) R 14 : if Arrival = L and Queue = S then Extension = M R 15 : if Arrival = L and Queue = M then Extension = S R 16 : if Arrival = L and Queue = L then Extension = Z
Fuzzy control <계산식> u[i] * u(i, Extension) Extension = -----------u[i] 16 u[i] = ∑ min( Ri-Arrival, Ri-Queue) i =1 u(i, Extension) = the extension_unit of i-th Rule Linguistic Label of Extension
Fuzzy control Ex) Arrival = 7 이고 Queue = 5 일 때 Extension = ? R 1 : if Arrival(Zero) = 0 and Queue(Zero) = 0 then Extension(Zero) = 0초 min(0, 0) = 0 R 2 : if Arrival(Zero) = 0 and Queue(Short) = 0. 2 then Extension(Zero) = 0초 R 3 : if Arrival(Zero) = 0 and Queue(Medium) = 0. 8 then Extension(Zero) = 0초 R 4 : if Arrival(Zero) = 0 and Queue(Long) = 0 then Extension(Zero) = 0초 R 5 : if Arrival(Short) = 0 and Queue(Zero) = 0 then Extension(Short) = 3초 R 6 : if Arrival(Short) = 0 and Queue(Short) = 0. 2 then Extension(Zero) = 0초 R 7 : if Arrival(Short) = 0 and Queue(Medium) = 0. 8 then Extension(Zero) = 0초 R 8 : if Arrival(Short) = 0 and Queue(Long) = 0 then Extension(Zero) = 0초 R 9 : if Arrival(Medium) = 0. 7 and Queue(Zero) = 0 then Extension(Medium) = 6초 R 10 : if Arrival(Medium) = 0. 7 and Queue(Short) = 0. 2 then Extension(Short) = 3초 min(0. 7, 0. 2) = 0. 2 R 11 : if Arrival(Medium) = 0. 7 and Queue(Medium) = 0. 8 then Extension(Zero) = 0초 R 12 : if Arrival(Medium) = 0. 7 and Queue(Long) = 0 then Extension(Zero) = 0초 R 13 : if Arrival(Long) = 0. 4 and Queue(Zero) = 0 then Extension(Long) = 9초 R 14 : if Arrival(Long) = 0. 4 and Queue(Short) = 0. 2 then Extension(Medium) = 6초 R 15 : if Arrival(Long) = 0. 4 and Queue(Medium) = 0. 8 then Extension(Short) = 3초 R 16 : if Arrival(Long) = 0. 4 and Queue(Long) = 0 then Extension(Zero) = 0초
Fuzzy control numerator Extension = -------denominator numerator = 0*0+0*3+ 0*0+0*6+ 0. 2*3+ … denominator = 0+ 0+ 0+0. 2+ 0. 7+ 0+ 0+ 0. 2+ 0. 4+ 0 0. 2*3 + 0. 7*0 + 0. 2*6 + 0. 4*3 Extension = ------------0. 2 + 0. 7 + 0. 2 + 0. 4 = 2(sec)
Fuzzy Bot • Fuzzy relation – How much the bot want to do, have or use something – Based on the current state of the world and the state of the bot – Each item has a fuzzy relation • Shows how much the bot wants to have a item – Based on variables that represent which items the bot has in its possession • How much of each item the bot has • How much health the bot has • How much armor the bot has etc – Evaluate the fuzzy relation for each item • Choose the right weapon during combat 26 / 34
Fuzzy Bot • Fuzzy relation – The bot uses are stored using a tree-like structure • The leaves of this tree store fuzzy values • Plain text using a C-like syntax 27 / 34
Fuzzy Bot • Pros – Easy to understand – Easily be created logical reasoning and predicting common situations – Easily be modified and adjust • Cons – The structure grows rather large and become difficult to read when expressing some of the more complex relation 28 / 34
Fuzzy Bot 29 / 34
Genetic Programming • GP applies the approach of the genetic algorithm to the space of possible computer programs • Computer programs are the lingua franca for expressing the solutions to a wide variety of problems • A wide variety of seemingly different problems from many different fields can be reformulated as a search for a computer program to solve the problem. 30 / 34
GP - Main Point • Genetic programming now routinely delivers high-return humancompetitive machine intelligence. • Genetic programming is an automated invention machine. • Genetic programming has delivered a progression of qualitatively more substantial results in synchrony with five approximately order-ofmagnitude increases in the expenditure of computer time. 31 / 34
A Computer Program int foo (int time) { int temp 1, temp 2; if (time > 10) temp 1 = 3; else temp 1 = 4; temp 2 = temp 1 + 2; return (temp 2); } 32 / 34
Program Tree • (+ 1 2 (IF (> TIME 10) 3 4)) 33 / 34
Create Random Programs • Available functions – F = {+, -, *, %, IFLTE} • Available terminals – T = {X, Y, Random-Constants} • The random programs are: – Of different sizes and shapes – Syntactically valid – Executable 34 / 34
GP Genetic Operation • Reproduction • Mutation • Crossover (sexual recombination) • Architecture-altering operations 35 / 34
Crossover • Select 2 parents probabilistically based on fitness • Randomly pick a number from 1 to NUMBER-OF-POINTS for 1 st parent • Independently randomly pick a number for 2 nd parent • The result is a syntactically valid executable program • Put the offspring into the next generation of the population • Identify the subtrees rooted at the two picked points 36 / 34
Crossover 37 / 34
Mutation • Select 1 parent probabilistically based on fitness • Pick point from 1 to NUMBER-OF-POINTS • Delete subtree at the picked point • Grow new subtree at the mutation point in same way as generated trees for initial random population (generation 0) • The result is a syntactically valid executable program • Put the offspring into the next generation of the population 38 / 34
Mutation 39 / 34
Behavior Tree • Top-down – Computation starts at the root node – The root selects only one of its children for execution – This repeats for each selected internal node until a leaf is selected • Bottom-up – Computation starts at leaves – Parent node chooses among all proposed action and passes the winning action up – This repeats until the root is reached 40 / 34
ASM(action select mechanism) • ASM architecture – Behavior functions • Primary behavior functions – Atomic behavior(attack. Player(Enemy)) • Secondary behavior functions – More complex behavior – Sensory functions • Their return value is typically a floating-point number normalized to <0, 1> – Distance to a player, bot’s health, etc • Game specific data type – Function nearest. Enemy returns handle to the nearest player from the opposite team – Math functions • +, -, ×, ÷, sin, max, constant 41 / 34
42 / 34
• Behavior tree of the best individual from generation 80 43 / 34
Competition – Unreal Tournament • Turing Test 44 / 34
- Slides: 46