from
AI for a game called chomp
by Abhilash Harpale
this program uses the minimax algorithm for playing chomp.open the file create_tree for instrutions.
|
| output=next(current_state,j,m,n)
|
%Copywrite Abhilash Harpale (c) 2009.
%This function generates the next state.
function output=next(current_state,j,m,n)
state=floor((current_state-1)/n)+1;
state=[state;(current_state-(n*floor((current_state-1)/n)))];
j2=floor((j-1)/n)+1;
j2=[j2;(j-(n*floor((j-1)/n)))];
output=[];
for k=1:size(current_state,2)
if(j2(1,1)<state(1,k) | j2(2,1)>state(2,k))
output=[output state(:,k)];
end
end
output=n*(output(1,:)-1)+output(2,:);
end
|
|
Contact us