{"id":318,"date":"2018-05-30T12:02:46","date_gmt":"2018-05-30T12:02:46","guid":{"rendered":"http:\/\/163.180.4.222\/lab\/?p=318"},"modified":"2018-05-30T12:02:46","modified_gmt":"2018-05-30T12:02:46","slug":"%ec%bb%b4%ed%93%a8%ed%84%b0-%ea%b4%80%eb%a0%a8-%ed%8c%8c%ec%9d%b4%ec%8d%ac%ec%9c%bc%eb%a1%9c-%ec%9e%91%ec%84%b1%ed%95%9c-%ec%9d%b8%ea%b3%b5%ec%a7%80%eb%8a%a5-%ea%b2%8c%ec%9e%84-%ed%8c%8c%ec%9d%bc","status":"publish","type":"post","link":"https:\/\/biochemistry.khu.ac.kr\/lab\/?p=318","title":{"rendered":"\ucef4\ud4e8\ud130 \uad00\ub828 &#8211; \ud30c\uc774\uc36c\uc73c\ub85c \uc791\uc131\ud55c \uc778\uacf5\uc9c0\ub2a5 \uac8c\uc784 \ud30c\uc77c"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\ucf54\uc778 \uac8c\uc784\u00a0<\/strong>&#8212; \ub9c8\uc9c0\ub9c9 \ucf54\uc778\uc744 \ube7c\ub294 \uc790\uac00 \uc9c0\ub294 \uac8c\uc784<\/p>\n<p>&nbsp;<\/p>\n<div>\n<div>\n<div>\n<div>\n<p># This is a variant of the Game of Bones recipe given in the easyAI library<\/p>\n<p>from easyAI import TwoPlayersGame, id_solve, Human_Player, AI_Player<br \/>\nfrom easyAI.AI import TT<\/p>\n<p>class LastCoinStanding(TwoPlayersGame):<br \/>\n(space)def __init__(self, players):<\/p>\n<p># Define the players. Necessary parameter.<br \/>\n(space)(space)self.players = players<\/p>\n<p># Define who starts the game. Necessary parameter.<br \/>\n(space)(space)self.nplayer = 1<\/p>\n<p># Overall number of coins in the pile<br \/>\n(space)(space)self.num_coins = 25<\/p>\n<p># Define max number of coins per move<br \/>\n(space)(space)self.max_coins = 4<\/p>\n<p># Define possible moves<br \/>\n(space)def possible_moves(self):<br \/>\n(space)(space)return [str(x) for x in range(1, self.max_coins + 1)]<\/p>\n<p># Remove coins<br \/>\n(space)def make_move(self, move):<br \/>\n(space)(space)self.num_coins -= int(move)<\/p>\n<p># Did the opponent take the last coin?<br \/>\n(space)def win(self):<br \/>\n(space)(space)return self.num_coins &lt;= 0<\/p>\n<p># Stop the game when somebody wins<br \/>\n(space)def is_over(self):<br \/>\n(space)(space)return self.win()<\/p>\n<p># Compute score<br \/>\n(space)def scoring(self):<br \/>\n(space)(space)return 100 if self.win() else 0<\/p>\n<p># Show number of coins remaining in the pile<br \/>\n(space)def show(self):<br \/>\n(space)(space)print(self.num_coins, &#8216;coins left in the pile&#8217;)<\/p>\n<p>if __name__ == &#8220;__main__&#8221;:<\/p>\n<p># Define the transposition table<br \/>\n(space)tt = TT()<\/p>\n<p># Define the method<br \/>\n(space)LastCoinStanding.ttentry = lambda self: self.num_coins<\/p>\n<p># Solve the game<br \/>\n(space)result, depth, move = id_solve(LastCoinStanding,<br \/>\n(space)(space)range(2, 20), win_score=100, tt=tt)<br \/>\n(space)print(result, depth, move)<\/p>\n<p># Start the game<br \/>\n(space)game = LastCoinStanding([AI_Player(tt), Human_Player()])<br \/>\n(space)game.play()<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Tic Tac Toe \uac8c\uc784\u00a0<\/strong>&#8212; \uc77c\uc885\uc758 \uc0bc\ubaa9 \uac8c\uc784<\/p>\n<p>&nbsp;<\/p>\n<p># This is a variant of the Tic Tac Toe recipe given in the easyAI library<\/p>\n<p>from easyAI import TwoPlayersGame, AI_Player, Negamax<br \/>\nfrom easyAI.Player import Human_Player<\/p>\n<p>class GameController(TwoPlayersGame):<br \/>\n(space)def __init__(self, players):<\/p>\n<p># Define the players<br \/>\n(space)(space)self.players = players<\/p>\n<p># Define who starts the game<br \/>\n(space)(space)self.nplayer = 1<\/p>\n<p># Define the board<br \/>\n(space)(space)self.board = [0] * 9<\/p>\n<p># Define possible moves<br \/>\n(space)def possible_moves(self):<br \/>\n(space)(space)return [a + 1 for a, b in enumerate(self.board) if b == 0]<\/p>\n<p># Make a move<br \/>\n(space)def make_move(self, move):<br \/>\n(space)(space)self.board[int(move) &#8211; 1] = self.nplayer<\/p>\n<p># Does the opponent have three in a line?<br \/>\n(space)def loss_condition(self):<br \/>\n(space)(space)possible_combinations = [[1,2,3], [4,5,6], [7,8,9],\u00a0[1,4,7], [2,5,8], [3,6,9], [1,5,9], [3,5,7]]<\/p>\n<p>(space)(space)return any([all([(self.board[i-1] == self.nopponent)<br \/>\n(space)(space)(space)for i in combination]) for combination in possible_combinations])<\/p>\n<p># Check if the game is over<br \/>\n(space)def is_over(self):<br \/>\n(space)(space)return (self.possible_moves() == []) or self.loss_condition()<\/p>\n<p># Show current position<br \/>\n(space)def show(self):<br \/>\n(space)(space)print(&#8216;\\n&#8217;+&#8217;\\n&#8217;.join([&#8216; &#8216;.join([[&#8216;.&#8217;, &#8216;O&#8217;, &#8216;X&#8217;][self.board[3*j + i]]<br \/>\n(space)(space)(space)for i in range(3)]) for j in range(3)]))<\/p>\n<p># Compute the score<br \/>\n(space)def scoring(self):<br \/>\n(space)(space)return -100 if self.loss_condition() else 0<\/p>\n<p>if __name__ == &#8220;__main__&#8221;:<\/p>\n<p># Define the algorithm<br \/>\n(space)algorithm = Negamax(7)<\/p>\n<p># Start the game<br \/>\n(space)GameController([Human_Player(), AI_Player(algorithm)]).play()<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; &nbsp; \ucf54\uc778 \uac8c\uc784\u00a0&#8212; \ub9c8\uc9c0\ub9c9 \ucf54\uc778\uc744 \ube7c\ub294 \uc790\uac00 \uc9c0\ub294 \uac8c\uc784 &nbsp; # This is a variant of the Game of Bones recipe given in<a href=\"https:\/\/biochemistry.khu.ac.kr\/lab\/?p=318\" class=\"more-link\">(more&#8230;)<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[35,29],"tags":[9,3],"class_list":["post-318","post","type-post","status-publish","format-standard","hentry","category-lets-do-computer-science","category-lets-do-science","tag-lets-do-computer-science","tag-lets-do-science"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":316,"url":"https:\/\/biochemistry.khu.ac.kr\/lab\/?p=316","url_meta":{"origin":318,"position":0},"title":"\ucef4\ud4e8\ud130 \uad00\ub828 &#8211; \ud30c\uc774\uc36c\uc73c\ub85c \uc791\uc131\ud55c tree (\ud558\uc704 \ub514\ub809\ud1a0\ub9ac \uad6c\uc870\ub97c \ubcf4\uc5ec\uc90c) \ud30c\uc77c","author":"biochemistry","date":"May 30, 2018","format":false,"excerpt":"\u00a0 \u00a0 \u00a0 import glob, os.path ndir = nfile = 0 def traverse(dir, depth): (space)global ndir, nfile (space)for obj in glob.glob(dir + '\/*'): (space)(space)if depth == 0: (space)(space)(space)prefix = '|--' (space)(space)else: (space)(space)(space)prefix = '|' + ' ' * depth + '|--' (space)(space)if os.path.isdir(obj): (space)(space)(space)ndir += 1 (space)(space)(space)print(prefix + os.path.basename(obj)) (space)(space)(space)traverse(obj,\u2026","rel":"","context":"In &quot;Let's Do Computer Science!&quot;","block_context":{"text":"Let's Do Computer Science!","link":"https:\/\/biochemistry.khu.ac.kr\/lab\/?cat=35"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1342,"url":"https:\/\/biochemistry.khu.ac.kr\/lab\/?p=1342","url_meta":{"origin":318,"position":1},"title":"\ud310\ub3c4\ub77c \uc0c1\uc790 \uc5f0 \uc54c\ud30c\uace0 \uac1c\ubc1c\uc790, \ub370\ubbf8\uc2a4 \ud5c8\uc0ac\ube44\uc2a4","author":"biochemistry","date":"August 13, 2018","format":false,"excerpt":"\u00a0 \u00a0 (\uc6d0\ubb38) \u00a0 \u00a0 '\ub525 \ub7ec\ub2dd' \ubc29\uc2dd\uc774 \uc778\uacf5\uc9c0\ub2a5 \ub300\uc138\ub85c\u2026\uc778\ub958 \uc2e0\uae30\uc220 \ucd5c\uc804\uc120\uc5d0 \uc120 \ubc1c\uba85\uac00 \u00a0 \u00a0 \uc778\uacf5\uc9c0\ub2a5. \uc774\uc81c\ub294 \ub108\ubb34 \ub9ce\uc774 \ub098\uc640\uc11c \uc9c0\uaca8\uc6b4 \uac10\uc774 \uc788\ub294 \uc8fc\uc81c\uc778\ub370\uc694. IT \ud68c\uc0ac\uc5d0 \ub2e4\ub2c8\ub294 \uc785\uc7a5\uc5d0\uc11c \uc778\uacf5\uc9c0\ub2a5 \uc774\uc57c\uae30\ub294 \uc624\ud788\ub824 \ub298\uc5b4\ub09c \ub290\ub08c\uc785\ub2c8\ub2e4. \ub124\uc774\ubc84, \uce74\uce74\uc624 \ub4f1\uc744 \ud544\ub450\ub85c \uc778\uacf5\uc9c0\ub2a5\uc5d0 \ub300\ud55c \ud22c\uc790\uac00 \uc804\ubc29\uc704\uc801\uc73c\ub85c \ub298\uace0 \uc788\uc2b5\ub2c8\ub2e4. \uc778\uacf5\uc9c0\ub2a5\uc758 \ubd90\uc744 \ub9cc\ub4e0 \uc0ac\ub78c. \uc54c\ud30c\uace0\uc758 \uac1c\ubc1c\uc790\u2026","rel":"","context":"In &quot;Essays on Science&quot;","block_context":{"text":"Essays on Science","link":"https:\/\/biochemistry.khu.ac.kr\/lab\/?cat=32"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.bizhankook.com\/upload\/bk\/article\/201808\/thumb\/15990-32410-sampleM.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3241,"url":"https:\/\/biochemistry.khu.ac.kr\/lab\/?p=3241","url_meta":{"origin":318,"position":2},"title":"Walk the line (QUANTUM TECHNOLOGY)","author":"biochemistry","date":"April 8, 2019","format":false,"excerpt":"\u00a0 \u00a0 Qubits made from semiconductor quantum dots are a potential platform for future quantum computing. Although quantum gates with high fidelity have been demonstrated, the coupling of such qubits over distances, for example for use in quantum registers, remains a challenge. Mills et al. now show how they can\u2026","rel":"","context":"In &quot;Let's Do Chemistry!&quot;","block_context":{"text":"Let's Do Chemistry!","link":"https:\/\/biochemistry.khu.ac.kr\/lab\/?cat=34"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3300,"url":"https:\/\/biochemistry.khu.ac.kr\/lab\/?p=3300","url_meta":{"origin":318,"position":3},"title":"The NASA Twins Study: A multidimensional analysis of a year-long human spaceflight","author":"biochemistry","date":"April 14, 2019","format":false,"excerpt":"\u00a0 \u00a0 What to expect after a year in space \u00a0 Space is the final frontier for understanding how extreme environments affect human physiology. Following twin astronauts, one of which spent a year-long mission on the International Space Station, Garrett-Bakelman\u00a0et al.\u00a0examined molecular and physiological traits that may be affected by\u2026","rel":"","context":"In &quot;Let's Do Biology!&quot;","block_context":{"text":"Let's Do Biology!","link":"https:\/\/biochemistry.khu.ac.kr\/lab\/?cat=33"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3106,"url":"https:\/\/biochemistry.khu.ac.kr\/lab\/?p=3106","url_meta":{"origin":318,"position":4},"title":"\uac8c\uc784\uc758 \uc81c\uc655 \uc54c\ud30c\uc81c\ub85c\uc758 \ub4f1\uc7a5","author":"biochemistry","date":"March 31, 2019","format":false,"excerpt":"\u00a0 \u00a0 \uc0ac\uc774\uc5b8\uc2a4 \uc81c\uacf5 \u00a0 \uad6d\uc81c\ud559\uc220\uc9c0 \u2018\uc0ac\uc774\uc5b8\uc2a4\u2019\ub294 7\uc77c \uc815\uc721\uba74\uccb4 \uc704 3\uac1c \uba74\uc5d0 \ubc14\ub451\uacfc \uccb4\uc2a4, \ud55c\uad6d\uc758 \uc7a5\uae30\uc640 \ub2ee\uc740 \uc77c\ubcf8\uc758 \uc1fc\uae30 \uac8c\uc784\uc774 \ub3d9\uc2dc\uc5d0 \uc9c4\ud589 \uc911\uc778 \ubaa8\uc2b5\uc744 \ud45c\uc9c0\uc5d0 \uc2e4\uc5c8\ub2e4. \ub3c5\ud559\uc73c\ub85c \uc774 \uc138 \uac00\uc9c0 \uac8c\uc784\uc744 \uc12d\ub835\ud574 \ucd5c\uac15\uc758 \uc790\ub9ac\uc5d0 \uc624\ub978 \uad6c\uae00\uc758 \uc0c8 \uc778\uacf5\uc9c0\ub2a5(AI) \uc54c\ud30c\uc81c\ub85c\uc758 \ub4f1\uc7a5\uc744 \uc54c\ub9b0 \uac83\uc774\ub2e4. \uad6c\uae00\uc758 \ub525\ub9c8\uc778\ub4dc \uc5f0\uad6c\uc9c4\uc774 \uc0c8\ub85c \ub0b4\ub193\uc740 \uc54c\ud30c\uc81c\ub85c\ub294 2016\ub144 \ub4f1\uc7a5\ud574\u2026","rel":"","context":"In &quot;Let's Do Computer Science!&quot;","block_context":{"text":"Let's Do Computer Science!","link":"https:\/\/biochemistry.khu.ac.kr\/lab\/?cat=35"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1189,"url":"https:\/\/biochemistry.khu.ac.kr\/lab\/?p=1189","url_meta":{"origin":318,"position":5},"title":"All together now\u2026fly!","author":"biochemistry","date":"July 20, 2018","format":false,"excerpt":"\u00a0 \u00a0 (\uc6d0\ubb38: \uc5ec\uae30\ub97c \ud074\ub9ad\ud558\uc138\uc694~) \u00a0 Science\u00a0\u00a020 Jul 2018: Vol. 361, Issue 6399, pp. 240 DOI: 10.1126\/science.361.6399.240-a \u00a0 \u00a0 \u00a0Open in new tab Long-exposure photo of a flight with multiple drones CREDIT: ZSOLT B\u00c9ZSENYI \u00a0 \u00a0 Can the quick, responsive grace of a flock of birds or school of fish\u2026","rel":"","context":"In &quot;Let's Do Computer Science!&quot;","block_context":{"text":"Let's Do Computer Science!","link":"https:\/\/biochemistry.khu.ac.kr\/lab\/?cat=35"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":false,"jetpack_shortlink":"https:\/\/wp.me\/p9Xo1j-58","_links":{"self":[{"href":"https:\/\/biochemistry.khu.ac.kr\/lab\/index.php?rest_route=\/wp\/v2\/posts\/318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/biochemistry.khu.ac.kr\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/biochemistry.khu.ac.kr\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/biochemistry.khu.ac.kr\/lab\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/biochemistry.khu.ac.kr\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=318"}],"version-history":[{"count":0,"href":"https:\/\/biochemistry.khu.ac.kr\/lab\/index.php?rest_route=\/wp\/v2\/posts\/318\/revisions"}],"wp:attachment":[{"href":"https:\/\/biochemistry.khu.ac.kr\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/biochemistry.khu.ac.kr\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/biochemistry.khu.ac.kr\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}