Hello!! At Kyle’s suggestion on discord, I wrapped the “selfplaying” actor class in a module and then import it into main.mo, which will have the function of creating the initial instance of the “selfplaying” actor. Which got me pretty close to a solution, or at least to better identifying the problem. The error I got after that is the one discussed in this thread:
At first glance I understand that for some reason the compilation process prevents the possibility of making recursive calls of this type from being open, perhaps as a prevention of problems related to an erroneous implementation. I’m digressing. Here are the codes of both files with which I wanted to test this creational pattern.
autogen.mo
import Cycles "mo:base/ExperimentalCycles";
import Principal "mo:base/Principal";
module {
public shared ({ caller = super }) actor class Counter(_owner : Principal, _init : Int) {
stable var count = _init;
public func incCount() : async () { count += 1 };
public func decCount() : async () { count -= 1 };
public shared ({ caller }) func mkNewCounter(_fee : Nat) : async Principal {
Cycles.add(_fee);
let client = await Counter(caller, count);
Principal.fromActor(client);
};
};
};
main.mo
import autogen "autogen";
actor {
public shared ({caller}) func create(): async autogen.Counter{
await autogen.Counter(caller, 0);
};
};