So I guess everyone played an mmorpg at least one time.
What about those times when you want things to go a little faster or win more faster in an mmorpg.
Let's take a particular case :hobowars.
It's a game in wich you battle other hobos for money,
respect etc...
probably a nice way to kill some time
A part of the game offers a hobo the possibility to explore
the city ,giving him an imaginary square grid of the city and some directions(have a look
at a picture of how the http://www.hobowars.com/images/hbw-06.jpg),
and he can go in the directions he wants and along the way
find different items,food,money or cans wich he can sell at
the can depo for money
There are 200 turns so it's allot of clicking to do
and maybe it gets boring to need to click that much

So maybe we could fix that.
The following code is commented and shows how one can achieve that by automatically "exploring" the city:
use strict; use warnings; use WWW::Mechanize; my $m = WWW::Mechanize->new(); $m->get('http://www.hobowars.com'); $m->submit_form( form_name =>'loginForm', fields => { username => '', password => '', }, button =>'submit', ); $m->follow_link(url_regex=> qr/cmd\=explore/i); $m->follow_link(url_regex=> qr/cmd\=explore\&do\=/i); my $turns_left = 1; my $turns_used = 0; my @turn_cmds = ( { direction=>'left' ,times=>50, }, { direction=>'down' ,times=>50, }, { direction=>'right' ,times=>50, }, { direction=>'up' ,times=>50, }, );#this array records all the commands and they will made in the o +rder the array stores #this is just an example about how you can consume your 200 turn +s/day my $turn_cmd=0; #this is the indev of the current command wich is run right now while($turns_left) {#while we still have turns to use $turns_used++; ($turns_left) = $m->content =~ /left: (\d+)/; my ($X,$Y) = $m->content =~ /(\d+) , (\d+)<\/font><\/strong><\/div +><\/td>/; #get the current position in the game grid my $directions = {}; for ( grep { $_->url =~ /do\=move.*dir=/ } $m->links ) { #for each + direction link on the page my ($x,$y) = $_->url_abs =~ /x=(\d+)\&y=(\d+)/; #current posit +ion in the grid my $key = ""; #<-- here we will construct the name of the dire +ction depending on xdiff and ydiff # wich show us wich way each direction goes my $xdiff=$X-$x; my $ydiff=$Y-$y; $key.="left" if $xdiff == 1; $key.="right" if $xdiff == -1; $key.="up" if $ydiff == 1; $key.="down" if $ydiff == -1; #warn "Xdiff:$xdiff , Ydiff:$ydiff ,key:$key"; $directions->{$key} = $_->url_abs; #put the absolute url in th +at direction }; warn "[TURNS LEFT]:$turns_left"; warn "[TURNS USED]:$turns_used"; warn "[X]=$X [Y]=$Y"; $m->get($directions->{$turn_cmds[$turn_cmd]->{direction} }); warn "[TURN MADE] , DIRECTION: ".$turn_cmds[$turn_cmd]->{direction +}." TIMES: ".$turn_cmds[$turn_cmd]->{times} ; if($turn_cmds[$turn_cmd]->{times}--==0) { $turn_cmd++;#if we finished the current command then go to the + next command }; }
EDIT: Fixed the links,thanks zentara and Gavin.

In reply to elegantly cheating mmorpgs using perl by spx2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.