SRL Archive - Other Scripts

Simba + Evony


EGM

2010-12-23 17:40:21

I've been learning Simba and playing Evony and after being told that there was NO WAY to create a bot with zero setup, I created a simple "proof of concept" to show how the Rally Spot, Barracks, and Feasting Hall (or Inn – it can't pick between the two yet) screen coords could be tested for independent of browser and monitor attributes for each city.

While it's not a bot, and probably not complete, I'm hoping it will jumpstart a discussion on getting Simba to work on Evony.

– EGM

Train

2010-12-23 18:06:45

I used to play this game a bit, I thought it was a bit pointless. But a bot for it…? I'll look at what you have done. :)

Dynamite

2010-12-23 18:13:10

Could you post in tags please.
I never trust attachments

Train

2010-12-23 18:14:21

From: The Man
Could you post in tags please.
I never trust attachments


It's perfectly safe.

i luffs yeww

2010-12-23 18:16:37

Building DDTMs.simba -

function SetBlueDDTM: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..1] of TDTMPointDef;
TempTDTM: TDTM;
begin
dtmMainPoint.x := 18;
dtmMainPoint.y := 24;
dtmMainPoint.AreaSize := 2;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := 10223633;
dtmMainPoint.Tolerance := 2;

dtmSubPoints[0].x := 18;
dtmSubPoints[0].y := 24;
dtmSubPoints[0].AreaSize := 2;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := 10223633;
dtmSubPoints[0].Tolerance := 2;

dtmSubPoints[1].x := 21;
dtmSubPoints[1].y := 22;
dtmSubPoints[1].AreaSize := 2;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := 16777215;
dtmSubPoints[1].Tolerance := 2;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddSDTM(TempTDTM);
end;

function SetRedDDTM: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..1] of TDTMPointDef;
TempTDTM: TDTM;
begin
dtmMainPoint.x := 14;
dtmMainPoint.y := 7;
dtmMainPoint.AreaSize := 2;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := 229;
dtmMainPoint.Tolerance := 2;

dtmSubPoints[0].x := 14;
dtmSubPoints[0].y := 7;
dtmSubPoints[0].AreaSize := 2;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := 229;
dtmSubPoints[0].Tolerance := 2;

dtmSubPoints[1].x := 12;
dtmSubPoints[1].y := 10;
dtmSubPoints[1].AreaSize := 2;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := 16777215;
dtmSubPoints[1].Tolerance := 2;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddSDTM(TempTDTM);
end;

function SetGreenDDTM: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..1] of TDTMPointDef;
TempTDTM: TDTM;
begin
dtmMainPoint.x := 17;
dtmMainPoint.y := 15;
dtmMainPoint.AreaSize := 2;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := 102217;
dtmMainPoint.Tolerance := 2;

dtmSubPoints[0].x := 17;
dtmSubPoints[0].y := 15;
dtmSubPoints[0].AreaSize := 2;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := 102217;
dtmSubPoints[0].Tolerance := 2;

dtmSubPoints[1].x := 17;
dtmSubPoints[1].y := 17;
dtmSubPoints[1].AreaSize := 2;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := 16777215;
dtmSubPoints[1].Tolerance := 2;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddSDTM(TempTDTM);
end;

FindBuildingsTest_v2.simba -

program FindBuildingsTest;
{-------------------------------------------------------------------------------
FindBuildingsTest v2 -- "proof of concept" example to locate Feasting Hall,
Rally Spot, and Barracks buildings using Dynamic Deformable Template Models (or
DDTM's)

Instructions:
1. Drag the target icon from the button bar above onto the flash player client
in your browser.

2. Select 'Town' in Evony.

3. Make sure the building levels are showing and no windows are open.

What is it doing? Searches within a box for a DTM, which is a point described by
a color a certain distance from another point also described by a color. DTMs
can have as many points as necessary. Each point was given a tolerance of 2 for
both size and color, giving a bit of flexability to the model.

Tested on Google Chrome browser with a client size of 1215 x 709 px.

Next step is to modify DDTM routines to use percentages. (All three were created
using DDTM_editor and left as-is, which comes with the SRL resource library
download and is also available seperately.)

Changes:
v2
+ Added a loop to look for Feasting Hall/Inn, Rally Spot, and Barracks in all
cities instead of just the one on the screen. Selects each city starting at the
top, and stops when encounters a blank tile.

! Moved point conversion and DTM functions to seperate files as includes to make
the main block easier to read.

+ Added a compiler instruction to make turning on/off debugging simple.

+ Added additional comments throughout for readability.

+ Added a section for constants to allow tweaking when necessary.
-------------------------------------------------------------------------------}

//Compiler instructions
//{$define debug} //Uncomment for add'l debugging info to be added to output

//Global constants
const
LOAD_WAIT = 2000; //Pause in mS for city to switch and image to reload.

//City Test
CT_COLOR = 10209771;
CT_TOLERANCE = 2;
CT_THRESHOLD = 1;

//Global types
type
TDTMPointDef = TSDTMPointDef;
TDTMPointDefArray = TSDTMPointDefArray;
TDTM = TSDTM;

//Global variables
var
cw, ch : integer; //Client width and height
TownBox : TBox; //Town search bounds
CitiesBox : TBox; //Cities selector area
BlueDDTM, RedDDTM, GreenDDTM : integer; //Template to search for
fx, fy : integer; //Results
i, xs, ys, xe, ye : integer;

{$I Point Conversions.simba}
{$I Building DDTMs.simba}

procedure Init;
begin
GetClientDimensions(cw, ch);
with TownBox do
begin
X1 := PercentToScreenX(5.26748971193416);
Y1 := PercentToScreenY(17.636684303351);
X2 := PercentToScreenX(65.3497942386831);
Y2 := PercentToScreenY(70.8289241622575);
end;
with CitiesBox do
begin
X1 := PercentToScreenX(73.1687242798353);
Y1 := PercentToScreenY(36.8253968253968);
X2 := PercentToScreenX(79.2592592592592);
Y2 := PercentToScreenY(98.342151675485);
end;
BlueDDTM := SetBlueDDTM;
RedDDTM := SetRedDDTM;
GreenDDTM := SetGreenDDTM;
i := 0;
end;

begin
Init; //Run initialization procedure above
ClearDebug; //Clear old from debug window below
ActivateClient; //Make client window active window
with CitiesBox do
begin
xs := X1 + 10;
xe := X2 - 10;
ys := Y1 + ((Y2 - Y1) / 10 * i) + 10;
ye := ys + ((Y2 - Y1) / 10) - 10;
while CountColorTolerance(CT_COLOR, xs, ys, xe, ye, CT_TOLERANCE) < CT_THRESHOLD do
begin
{$ifdef debug}
writeln(format('Search box = (%d, %d, %d, %d), Result = %d',
[xs, ys, xe, ye,
CountColorTolerance(CT_COLOR, xs, ys, xe, ye, CT_TOLERANCE)]));
{$endif}
MoveMouse(xs, ys);
ClickMouse(xs, ys, Mouse_Left);
Sleep(LOAD_WAIT);

//Write # of city, starting at the top.
writeln(format('-+ City #%2d', [i + 1]));

//Search the town for Feasting Hall, Rally Spot, and Barracks
// if successful, return the screen coordinates
// otherwise so something else
with TownBox do
begin
//Line below is how it would look without 'with TownBox' statement
//if FindDTM(BlueDDTM, fx, fy, TownBox.X1, TownBox.Y1, TownBox.X2, TownBox.Y2) then
if FindDTM(BlueDDTM, fx, fy, X1, Y1, X2, Y2) then
writeln(format(' +- Feasting Hall (or perhaps Inn) found at (%d, %d)', [fx, fy]))
else
writeln(' +- No result for Feasting Hall(or Inn).');

if FindDTM(RedDDTM, fx, fy, X1, Y1, X2, Y2) then
writeln(format(' +- Rally Spot found at (%d, %d)', [fx, fy]))
else
writeln(' +- No result for Rally Spot.');

if FindDTM(GreenDDTM, fx, fy, X1, Y1, X2, Y2) then
writeln(format(' +- Barracks found at (%d, %d)', [fx, fy]))
else
writeln(' +- No result for Barracks.');
end; //with TownBox block

//Increment the counter and set box to next city to test
Inc(i);
xs := X1 + 10;
xe := X2 - 10;
ys := Y1 + ((Y2 - Y1) / 10 * i) + 10;
ye := ys + ((Y2 - Y1) / 10) - 10;

end; //while..do loop block
end; //with CitiesBox block

//Free everything
FreeDTM(BlueDDTM);
FreeDTM(RedDDTM);
FreeDTM(GreenDDTM);
end.

Point Conversions.simba

function PercentToScreenX(const p: Variant): integer;
begin
Result := (p * cw / 100);
end;

function PercentToScreenY(const p: Variant): integer;
begin
Result := (cw * 7 * p / 1200);
end;

function ScreenToPercentX(const s: Variant): Variant;
begin
Result := (s * 100.0 / cw);
end;

function ScreenToPercentY(const s: Variant): Variant;
begin
Result := (s * 100.0)/(cw * 7.0 / 12.0);
end;

TomTuff

2010-12-23 18:18:57

tbh, there are so many "Clickbots" and packet sending bots out there for evony, it's not even worth it making one for simba.

PS quit now, shit sucks.

EGM

2010-12-23 18:38:29

From: TomTuff
tbh, there are so many "Clickbots" and packet sending bots out there for evony, it's not even worth it making one for simba.

PS quit now, shit sucks.


While I agree that there are more click-bots than Tinos has pizza-rolls, I started pursuing this for a number of reasons.

  1. I was unhappy that I couldn't find any click-bot to date that effectively had a "no click" setup.
  2. I enjoy Simba and it's one of the best platforms to code in.
  3. I was told that what this code does couldn't be done.
  4. I think I enjoy programming bots more than I enjoy playing! (But can't quit playing…)

Tom, to which "shit" are you referring: Evony, Simba, or my code?

TomTuff

2010-12-23 18:56:59

Evony. My step-mom practically left my dad because of it. We both used to play, I don't anymore but he still does (though not as much, but he still has the once-a-week all-night binge).

EGM

2010-12-23 19:13:03

From: TomTuff
Evony. My step-mom practically left my dad because of it. We both used to play, I don't anymore but he still does (though not as much, but he still has the once-a-week all-night binge).


Okay, can't disagree with that… especially since I've had to cut WAAAY back since coming close to losing things myself because of that infernal game.

Nowadays it's more of a social thing for me, talking to people, friends I've made. Unfortunately, daily minimum maintenance time is still required and I would like to make that as small and unobtrusive aspect as possible.

"Free Forever"? That's a nice catchphrase, while they try to suck every penny out of you they can. I simply refuse. Nor will I spend a dime on a bot for the same reasons.

But like I said before, in the end I'll enjoy the programming and wind up with something I can be truly happy with. :)

Harry

2010-12-23 19:26:11

As much as I agree the game is probably garbage (you can base this pretty much on how sleazy they made their banner advertisements, lol), that is irrelevant for this thread.

Looks really nice so far! Keep up the good work.

doublex8

2010-12-25 00:34:28

Never heard of this game. What is it similar to?

KingKong

2010-12-25 00:37:39

Its a game where you build your army, get as many towns/villages, kill people etc. Its like Ikariam or travian or KoB, if you've ever heard of em.

doublex8

2010-12-25 00:55:43

Is it fun?

KingKong

2010-12-25 01:21:53

If you're willing to spend hours(make that hours and hours and hours) of your time managing some village full of troops, then I guess it is.

EGM

2010-12-25 13:27:31

From: kongking
If you're willing to spend hours(make that hours and hours and hours) of your time managing some village full of troops, then I guess it is.


That about sums it up. :D

Best to leave the simple management and daily maintenance to automation and leave time for socializing in chats or actively fighting. Its basically flawed in many ways, and contains blatant ads and numerous specials to part you with your money. I can say that without feeling badly since most people who actively play are too addicted to care, like myself. ;)

doublex8

2010-12-25 13:30:47

Lol I'm scared to play now, sounds like I have to sell my soul. I just got it back after I found SRL ^_^

EGM

2010-12-25 13:36:16

Are you implying there's a mmorpg that doesn't require a lil soul selling? ;)

doublex8

2010-12-25 13:58:47

From: EGM
Are you implying there's a mmorpg that doesn't require a lil soul selling? ;)


I don't mind selling parts of it ;)