⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node17.html

📁 robocup3d littlegreenbats_howtorobocop-0.1.tar.gz
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!--Converted with LaTeX2HTML 2002-2-1 (1.71)original version by:  Nikos Drakos, CBLU, University of Leeds* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from:  Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>HumanoidAgent</TITLE><META NAME="description" CONTENT="HumanoidAgent"><META NAME="keywords" CONTENT="howtorobocop"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="STYLESHEET" HREF="howtorobocop.css"><LINK REL="next" HREF="node18.html"><LINK REL="previous" HREF="node16.html"><LINK REL="up" HREF="node13.html"><LINK REL="next" HREF="node18.html"></HEAD><BODY ><DIV CLASS="navigation"><!--Navigation Panel--><A NAME="tex2html284"  HREF="node18.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html280"  HREF="node13.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html274"  HREF="node16.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html282"  HREF="node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="/usr/share/latex2html/icons/contents.png"></A>  <BR><B> Next:</B> <A NAME="tex2html285"  HREF="node18.html">Behavior</A><B> Up:</B> <A NAME="tex2html281"  HREF="node13.html">Tutorial</A><B> Previous:</B> <A NAME="tex2html275"  HREF="node16.html">Cerebellum</A> &nbsp; <B>  <A NAME="tex2html283"  HREF="node1.html">Contents</A></B> <BR><BR></DIV><!--End of Navigation Panel--><H1><A NAME="SECTION00640000000000000000"></A><A NAME="secHumanoidAgent"></A><BR>HumanoidAgent</H1><P>As said above, this section will show how to quickly set up an agent that connects to the server, reads and parses messages that come from it and has a think cycle in which you can easily send actions back. This is done by using the <TT>HumanoidAgent</TT> class. It combines the classes described in the previous sections and creates an easy interface for new agents. To use it, you should create a class that inherits from it:<P><BR><IMG WIDTH="567" HEIGHT="163" ALIGN="BOTTOM" BORDER="0" SRC="img9.png" ALT="\begin{program}\begin{verbatim}class MyAgent : public bats::HumanoidAgent{......ng teamName): bats::HumanoidAgent(teamName){}};\end{verbatim}\end{program}"><BR><P>As you see, the constructor of the <TT>HumanoidAgent</TT> class expects a team name. You can also give it a host name and port to use to connect to and a uniform number. By default the latter is set to 0, meaning that the server picks a free uniform number. To run the agent, all you have to do is make a new object of your agent class and call the <TT>run()</TT> method on it:<P><BR><IMG WIDTH="567" HEIGHT="124" ALIGN="BOTTOM" BORDER="0" SRC="img10.png" ALT="\begin{program}\begin{verbatim}int main(){MyAgent agent(''MyTeam'');agent.run();}\end{verbatim}\end{program}"><BR><P>This runs the initialization code of the <TT>HumanoidAgent</TT>, which connects it to the server, sends the needed initialization message, and calls the <TT>init()</TT> method. Overload this method if your agent needs its own initialization code. After this, an infinite loop is started that updates the <TT>WorldModel</TT> and calls the <TT>think()</TT> method at each time step. If you want your agent to actually do something, overload this last method.<P><DIV CLASS="navigation"><HR><!--Navigation Panel--><A NAME="tex2html284"  HREF="node18.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html280"  HREF="node13.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html274"  HREF="node16.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html282"  HREF="node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="/usr/share/latex2html/icons/contents.png"></A>  <BR><B> Next:</B> <A NAME="tex2html285"  HREF="node18.html">Behavior</A><B> Up:</B> <A NAME="tex2html281"  HREF="node13.html">Tutorial</A><B> Previous:</B> <A NAME="tex2html275"  HREF="node16.html">Cerebellum</A> &nbsp; <B>  <A NAME="tex2html283"  HREF="node1.html">Contents</A></B> </DIV><!--End of Navigation Panel--><ADDRESS>Bram2007-11-18</ADDRESS></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -