Учебный Проект. Релиз 7. Класс Computer0: различия между версиями
Материал из wikiru.visual-prolog.com
м (Новая: {{Ползунок7}} <vip> /****************************************** Copyright (c) 2007. Elena Efimova predicate SuccessfullStep implementation Copyright (c) 2007. Prolog Development...) |
м |
||
(не показаны 2 промежуточные версии этого же участника) | |||
Строка 1: | Строка 1: | ||
{{ | {{Учебный Проект. Релиз 7}} | ||
<vip> | <vip> | ||
/****************************************** | /****************************************************** | ||
Copyright (c) | Copyright (c) Victor Yukhtenko | ||
Copyright (c) Elena Efimova | |||
predicate SuccessfullStep implementation | predicate SuccessfullStep implementation | ||
Class computer0 | Class computer0 | ||
******************************************/ | *******************************************************/ | ||
class computer0:player | class computer0:player | ||
open core | open core | ||
predicates | predicates | ||
getPlayerDescriptor:(game::language_D)->string Descriptor. | getPlayerDescriptor:(game::language_D)->string Descriptor. | ||
Строка 26: | Строка 25: | ||
PolyLineBraneObj=polylineStrategy0::new(), | PolyLineBraneObj=polylineStrategy0::new(), | ||
setpolylineStrategy(PolyLineBraneObj). | setpolylineStrategy(PolyLineBraneObj). | ||
clauses | clauses | ||
getPlayerDescriptor(game::en)=polylineStrategy0::playerDescriptorEn_C. | getPlayerDescriptor(game::en)=polylineStrategy0::playerDescriptorEn_C. | ||
Строка 42: | Строка 41: | ||
constants | constants | ||
playerDescriptorEn_C="Computer0: Unlimited Depth. Despair move - | playerDescriptorEn_C="Computer0: Unlimited Depth. Despair move - first possible in the list". | ||
playerDescriptorRu_C="Computer0: Неограниченный поиск. Ход отчаяния - по возможному правилу". | playerDescriptorRu_C="Computer0: Неограниченный поиск. Ход отчаяния - по возможному правилу". | ||
Строка 71: | Строка 70: | ||
genericComputer_V:stepCandidate(PolyLine, _PolyLine1,SomeMove), | genericComputer_V:stepCandidate(PolyLine, _PolyLine1,SomeMove), | ||
!. | !. | ||
predicates | predicates | ||
successfulStep1:(juniourJudge::cell* PolyLine)->juniourJudge::cell determ. | successfulStep1:(juniourJudge::cell* PolyLine)->juniourJudge::cell determ. | ||
Строка 95: | Строка 94: | ||
end implement polylineStrategy0 | end implement polylineStrategy0 | ||
</vip> | </vip> | ||
Текущая версия на 17:21, 28 марта 2011
Учебный Проект. Релиз 7 |
---|
/****************************************************** Copyright (c) Victor Yukhtenko Copyright (c) Elena Efimova predicate SuccessfullStep implementation Class computer0 *******************************************************/ class computer0:player open core predicates getPlayerDescriptor:(game::language_D)->string Descriptor. end class computer0 implement computer0 inherits genericComputer open core clauses new():- PolyLineBraneObj=polylineStrategy0::new(), setpolylineStrategy(PolyLineBraneObj). clauses getPlayerDescriptor(game::en)=polylineStrategy0::playerDescriptorEn_C. getPlayerDescriptor(game::ru)=polylineStrategy0::playerDescriptorRu_C. end implement computer0 /****************************************** Class polylineStrategy0 ******************************************/ class polylineStrategy0:polylineStrategy open core predicates classInfo : core::classInfo. constants playerDescriptorEn_C="Computer0: Unlimited Depth. Despair move - first possible in the list". playerDescriptorRu_C="Computer0: Неограниченный поиск. Ход отчаяния - по возможному правилу". end class polylineStrategy0 implement polylineStrategy0 open core, exception constants className = "polylineStrategy0". classVersion = "1.0". clauses classInfo(className, classVersion). facts genericComputer_V:genericComputer:=erroneous. clauses setGenericComputer(GenericComputerObj):- genericComputer_V:=GenericComputerObj. clauses successfulStep(PolyLine)=BestMove:- BestMove=successfulStep1(PolyLine), !. successfulStep(PolyLine)=SomeMove:- genericComputer_V:stepCandidate(PolyLine, _PolyLine1,SomeMove), !. predicates successfulStep1:(juniourJudge::cell* PolyLine)->juniourJudge::cell determ. clauses successfulStep1(PolyLine)=BestMove:- genericComputer_V:stepCandidate(PolyLine, _PolyLine1,BestMove), list::isMember(BestMove, PolyLine), !. successfulStep1(PolyLine)=Cell:- genericComputer_V:stepCandidate(PolyLine, PolyLine1,Cell), not(_=successfulStep1(PolyLine1)), !. clauses randomStep()=Cell:- findAll(NewCell,genericComputer_V:stepCandidate(juniourJudge::polyline_P,_Polyline1, NewCell),CellCandidateListWithDuplicates), CellCandidateList=list::removeDuplicates(CellCandidateListWithDuplicates), not(CellCandidateList=[]), NoOfVariants=list::length(CellCandidateList), ChoiceNo=math::random(NoOfVariants-1), Cell=list::nth(ChoiceNo+1,CellCandidateList). end implement polylineStrategy0