U E D R , A S I H C RSS

ALittle Ai Seminar/Namsang

~cpp
from Player import Player

class Namsang(Player):
    def __init__(self, aStone, aBoard):
        Player.__init__(self, aStone, aBoard)
	self.priority = [[100,0,50,10,10,50,0,100],
	      [0,0,40,15,15,40,0,0],
	      [50,40,50,10,10,50,40,50],
	      [10,15,10,0,0,10,15,10],
	      [10,15,10,0,0,10,15,10],
	      [50,40,50,10,10,50,40,50],
	      [0,0,40,15,15,40,0,0],
	      [100,0,50,10,10,50,0,100]]

    def name(self): return "Namsang"

    def execute(self):
        posList = self.getPutableList()

	maxValue = -1
	maxPosX = -1
	maxPosY = -1

	for i in range(len(posList)):
		posx, posy = posList[i]
		if maxValue < self.priority[posx][posy] :
			maxValue = self.priority[posx][posy]
			maxPosX = posx
			maxPosY = posy
        return self.put(maxPosX, maxPosY)
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:21
Processing time 0.0069 sec