CityVille – An Exercise

Last week-end I posted about the spreadsheets that I created for CityVille. The site that I linked had a very useful diagram on it to min/max decorations: One of the things that I discovered was that businesses don’t have to be connected to a road in order to have customers. You also get the coin bonus on “harvest” time.

Taking these two concepts together I have a row of businesses off by themselves, not connected to a road (just takes up space). I then cycle them into the middle of the discount nexus to gain the maximum discount for each shop (the Extreme Sports shop, which grants the best return/cargo according to my spreadsheet).

I was telling this to a friend, and saying that my interest in the title was waning (same problem as usual: what’s there to do in the end-game?). The idea was floated that I should see if scripting the game would be worthwhile.

So, after spending a few hours on it yesterday, I have the answer.

Scripting is totally not cost effective for either XP or Coins. At a base you get 12xp per hour (1 energy every five minutes, each energy equals a minimum of 1 xp). The first few levels go quick, but starting at around level 12 you need over 100xp to level. If you only get 1xp every five minutes (assuming you don’t get a double), then it would take you roughly 8 hours for a level.

If you have a group of friends and complete quests you gain quite a lot more than that, in a shorter time span. It’s even better to save some energy for larger tasks than to just spam collect from a house.

However, not everyone will be convinced, so let’s go over the script. The same rules as before apply: I will not tell you the scripting tool that I’m using, nor will I give you the complete compilable script. The code snippets in this post are roughly half of what’s needed to create the finished script, and no, I won’t give you the other half.

I started with a base that consisted of the script I made a few years ago for Adventure Quest, using the exact same methodology. Then I stumbled across a few pages that helped reshape the direction of the script (I’ll link them at the bottom of this article for reference).

As a result I ended up re-writing the script and making it more efficient. I thought the long list of coords and mouse moves was messy, so I moved the house coordinates to an array. Like so:

Global $HouseCoordArray[ 2 ] [ 2 ]

StoreHouseCoords ( 402 , 493 )
StoreHouseCoords ( 464 , 533 )

Func StoreHouseCoords( Const $CoordX , Const $CoordY )
Static Local $Htab = 0
$HouseCoordArray[ 0 + $Htab ] [ 0 ] = $CoordX
$HouseCoordArray[ 0 + $Htab ] [ 1 ] = $CoordY
$Htab += 1

This created an array to store the coordinates for the houses. This would let me more easily scale the script by simply putting in the new coords (instead of copy/pasting the entire block, like I had before).

I then needed a function to click on each of the items in the array. The following function did a lovely job of that.

FUNC _House()

For $i = 0 To UBound($HouseCoordArray) – 1
MouseClick(“left”, $HouseCoordArray[$i][0], $HouseCoordArray[$i][1], 1, 0)


The entire thing gets tied off with a loop that repeats every 5 minutes (the time it takes for 1 energy to recharge). The only thing left to do is wait.

Sadly, it really is more efficient to play manually. In the same span of time that the script is running, manually playing the game will net you at least 2 times the XP and Coin returns.

Using the above script as a base it would be very likely to perform tasks such as visiting your friends, but the script will never be worth the time investment unless you also create functions to complete quests (and build things) for you as well.

The redesign was based on ideas from LaCastiglione and Marian001. It was their examples that helped me get past the stumbling blocks that I encountered.

Comments are closed.