#!/usr/bin/ruby class ElAITask def initialize() end # Desire() is a method that returns how much this task wants to run right now. 0 is not at all, 1 is completely. # Weighting to judge between various tasks is done in ElAIManager -- as far as each task is concerned, their max desires are all normalized to 1. # This method should be overridden in each sub-class of ElAITask! def desire() return 0 end # Execute() is what is called when the AIManager holds its election and votes this task into "office" to run for a term (which is to be one game turn or less). # However, once a task is elected, it is technically Dictator For Life -- all of the other tasks just *hope* that it resigns after one turn or less. # In clearer language, DO NOT WRITE A VERSION OF EXECUTE() THAT WILL TAKE LONGER THAN ONE GAME TURN TO FINISH. Failing to do so could get the Nethack character killed. # If you need to accomplish a task that takes longer than one turn to finish, then write your execute() function such that successive consecutive calls will complete whatever is necessary. # This method should be overridden in each sub-class of ElAITask! def execute() end end if __FILE__ == $0 require "../utils/assert.rb" print "unit test succeeded\n" end