Jump to content









Control Emulators Via IRC -- Also a console bot!

c# programs games emulation

  • Please log in to reply
27 replies to this topic

#1 Iyouboushi

Iyouboushi

    Administrator

  • Administrators
  • 10,457 posts
  • LocationIn the Temen-ni-Gru ruining Vergil's day

Posted 16 February 2014 - 08:35 PM

C# EMULATION CONTROL (For those who want all the frustration and joys of Twitch Plays Pokemon without Twitch.....and possibly Pokemon.)
For those who missed my other topic about the subject, an anonymous programmer created a way for Twitch users to interact using the Twitch chat and they've been trying to collectively play the first Pokemon game (to some funny results). You can click on the link to learn more about that.

 

After seeing that I said "I bet I can do that in C#!" and set out on a frustrating journey to get it to work. However, I'm happy to report that thanks to a guy on the Tech Life Forum for providing a quick IRC GUI client demo and to the Input Manager Library, I've managed to get it to work.

 

I'm providing a few different things here in this topic. First, I'm providing the IRC version of the project. It still isn't perfect but it does work 99% of the time now. Second, I'm providing a console bot version that randomly selects keys and attempts to play games on its own (no AI behind it, it's all random baby). Third, the source codes of both programs are included. I honestly don't mind if someone downloads these and improves them/gets them to work better (I would like at least some credit for starting this project though if you choose to do that). Fourth, I've included a few emulators that both programs are designed to run with. These are just the emulators themselves, no ROMS are included (and won't be included).

 

With all that in mind..

 

Let me tell you how to get it working.

 

SETTING UP THE EMULATORS
It's important to make sure the emulators are set up correctly. No matter whether you're doing NES, SNES, GBA or PSX, the keys are set to default like this:

 

ALL EMULATORS:
UP: up arrow
DOWN: down arrow
LEFT/RIGHT: left and right arrows
A: HOME
B: END
START: PAGE UP
SELECT: PAGE DOWN

 

GBA:
L: INSERT
R: DELETE

 

SNES:
X: P
Y: O
L: INSERT
R: DELETE

 

SEGA:
C: I

 

PSX:
L1: INSERT
R1: DELETE
R2: T
L2: E
TRIANGLE: D
SQUARE: S
CIRCLE: X
X: P

 

GameboyAdvance, BoycottAdvance, fceux, and ZSNES allowed me to include config files that should be set correctly. The NES emulator nester did not, so you will need to do that one yourself.

 

The IRC Emulation Control program now has the ability to change the key bindings to however you would like. You can read more about that later on in this thread. The Console Bot does NOT allow you to customize the key bindings (yet) so make sure they match the above.

 

IRC VERSION (currently version 1.6)

Spoiler

 

CONSOLE BOT VERSION (version 1.2)

Spoiler

 

FINAL NOTES
I remind everyone that this is really a rough release. I'm not trying to steal the Twitch pokemon guy's thunder or run a stream of my own (as I can't leave my computer on 24/7 anyway). If you can, great, feel free to edit the source code and get it to connect to your Twitch stream and try your luck. I just thought it'd be fun to try and replicate the idea and see if I could do it.

 

I'll also add that there's probably better ways to do certain things in the code. I'll be trying to improve it as I go along, should I continue this project. It's been a long time since I've messed with C# and I'm a little rusty. But it works regardless.

 

GITHUB
In case you want to look at the source code before you download the 7z files, which are next in the list, you can head on over here:

 

C# Emulation Control - Console Bot
C# Emulation Control - IRC Client

 

DOWNLOAD (contains both, Release 009 current)
Emulation Control – release 009 (contains version 1.6 of the IRC client and 1.2 of the Console Bot)

 

OLD RELEASES

Spoiler

 

VERSION UPDATES

Spoiler


~James~
Even if you can't rely on anyone else, just pull yourself together and roar!
My Website :: The Ultimate Rurouni Kenshin FAQ

sig.gifiyouboushi.png


#2 Iyouboushi

Iyouboushi

    Administrator

  • Administrators
  • 10,457 posts
  • LocationIn the Temen-ni-Gru ruining Vergil's day

Posted 16 February 2014 - 10:27 PM

I'm in the process of rewriting the console bot to work with more emulators using the Input Management Library (whereas before it was using the SendKeys function which is unreliable and only works with BoycottAdvance).

 

In the mean time, I need some game suggestions for my bot to play. I know games that require multiple buttons to be pressed at the same time or buttons to be held for more than a split second (such as running in A Link to the Past) won't work.

 

I'm thinking maybe a sports game or some kind of action game where you don't need to jump will work best.

 

Know of any good silly sports games for NES or GBA that might work for this? If it does, I'll record it and upload it somewhere for everyone to see.


~James~
Even if you can't rely on anyone else, just pull yourself together and roar!
My Website :: The Ultimate Rurouni Kenshin FAQ

sig.gifiyouboushi.png


#3 Iyouboushi

Iyouboushi

    Administrator

  • Administrators
  • 10,457 posts
  • LocationIn the Temen-ni-Gru ruining Vergil's day

Posted 17 February 2014 - 12:52 PM

Added release 002 to the first post of this topic.

 

I've changed the IRC client so that it is now possible to change the nick, channel and server before connecting (once connected you're unable to change these values).

 

Also added nester (NES) support to both however this emulator has to be set up manually for the controls to work (as I can't include the config on this one). For the console version it is now possible to start nester without the START BUTTON support. The reason being certain games only use START to pause and the bot doesn't know that and will spam it (thus pausing and unpausing the game a ton) which is a bit annoying. For games where START is important you can include it but otherwise you can just leave it off the available buttons.

 

I tried the recent console version out with the NES game "Ice Hockey" and recorded it. It's 12 minutes and 50 seconds long. Spoiler: The bot never scores! It gets super close in period 3 though

 

http://www.youtube.com/watch?v=f9cHRnfc7EM

 

 

I think my next step in the console version will be to try and create game profiles with the available keys. By this I mean, you could make a config like tetris.config and tell it to only use RIGHT, LEFT, DOWN, A and B and not start, select or up.

 

I just have to figure out how to make it read from the file (that's easy) and convert what's in there to something the bot will understand (slightly harder) and redo the way the bot picks which command it chooses.

 

Otherwise, honestly, this is about as good as it gets. lol.


~James~
Even if you can't rely on anyone else, just pull yourself together and roar!
My Website :: The Ultimate Rurouni Kenshin FAQ

sig.gifiyouboushi.png


#4 Iyouboushi

Iyouboushi

    Administrator

  • Administrators
  • 10,457 posts
  • LocationIn the Temen-ni-Gru ruining Vergil's day

Posted 18 February 2014 - 12:28 PM

I've uploaded release 003 of my project.

 

This 7z contains version 1.0 of both the IRC and console bot versions.

 

First up, the IRC side of things..

 

In this version I've added the ability to connect to a server with a password, thus allowing the bot to connect to twitch. Read the top of this page for more info. You can ignore all the mIRC related stuff, but the information about the Oauth password and that you need to have lowercase user/channel names plus the twitch server address are all very relevant to this).

 

Furthermore, since the Oauth password is a royal pain to remember now, I've gone ahead and added the ability for the bot to save/load your last settings. When you connect they will be saved. When you start the program they will be loaded. Don't mess with settings.cfg once it's generated though or you run the risk of messing it up and the bot won't be able to load them any more.

 

For the console side..

 

I've Changed the code on how the bot builds its commands for the emulators. This is because..

 

I've added game control profiles. These are text files where you can list what buttons individual games have access to and then load those when running the bot. It's helpful if you want to exclude certain buttons or try to have certain buttons have stronger weight/show up more. You can read more about this in the first post..

 

And for both:

 

I've added Added ZSNES (SNES) support.

 

And finally, I've added new key combinations: DOWNB, DOWNA, and AB

 

 

I'll probably still try to get some more video of it working soon.


~James~
Even if you can't rely on anyone else, just pull yourself together and roar!
My Website :: The Ultimate Rurouni Kenshin FAQ

sig.gifiyouboushi.png


#5 Iyouboushi

Iyouboushi

    Administrator

  • Administrators
  • 10,457 posts
  • LocationIn the Temen-ni-Gru ruining Vergil's day

Posted 20 February 2014 - 07:50 AM

Release version 004 is now up. This contains the IRC Client version 1.1 and the Console Bot version 1.0.

 

I've made a few GUI changes in 1.1 of the IRC client. I figure most people who will be running this won't be using the thing as an actual IRC client (as it loses focus too much once the game starts getting played anyway). So I shrunk the window for that, which made the entire client smaller. Also fixed a mistake I had in which lowercase commands weren't being recognized (due to a mistake I made at the last second before releasing 1.0).

 


And here's a video of this in action. The command window is a little laggy/behind the actual commands though (it does the commands before it shows them in the window). But it works!

 

For testing I tried Pokemon Red and Link's Awakening (around a minute of each).

 


Pokemon Red:

 


Link's Awakening:

 

 

I haven't decided if I'm going to try to implement an anarchy vs democracy system similar to the way the Twitch Plays Pokemon is now or not. Part of me wants to just to see if I can get it done. We'll see. >.>


~James~
Even if you can't rely on anyone else, just pull yourself together and roar!
My Website :: The Ultimate Rurouni Kenshin FAQ

sig.gifiyouboushi.png


#6 Iyouboushi

Iyouboushi

    Administrator

  • Administrators
  • 10,457 posts
  • LocationIn the Temen-ni-Gru ruining Vergil's day

Posted 20 February 2014 - 11:35 PM

Argh.

 

It seems there are still some issues with version 1.1 of the IRC emulation control. Sorry everyone. This is what I get for being rusty at C# and making minor stupid human errors.

 

I'll work on version 1.2 in the morning and hopefully have a fix asap with release 005.

 

I've also found an updated copy of the InputManager.dll that makes all of this possible. With this update I'll be able to bring the projects over to .NET framework 4.5.1, which might actually solve a few other problems I've been having as well (as well as work on Windows 8.1 better). Of course that means it'll only work on computers that are running that framework but it should be the standard. I highly recommend upgrading to it if you haven't already.

 

Anyway, until I get the release out.. hang tight...


~James~
Even if you can't rely on anyone else, just pull yourself together and roar!
My Website :: The Ultimate Rurouni Kenshin FAQ

sig.gifiyouboushi.png


#7 Iyouboushi

Iyouboushi

    Administrator

  • Administrators
  • 10,457 posts
  • LocationIn the Temen-ni-Gru ruining Vergil's day

Posted 21 February 2014 - 08:11 AM

For version 1.2 of the IRC client I've hopefully fixed that error for good (a, b, x, y, l, and r shouldn't be ignored sometimes now). I've also added a pause button that will hopefully make it so commands stop working when pressed (and resume when pressed again). I didn't test it in a very active channel but it worked in a smaller channel.

 

For both the IRC client and bot control I've also changed the DOWN/RIGHT/LEFT/UP display to show arrows rather than the names of the keys.

 

Finally, as I mentioned in the post above, I've found an updated copy of the InputManager.dll that makes all of this possible. With this update both projects have been updated to .NET framework 4.5.1, which might actually solve a few other problems I've been having as well (as well as work on Windows 8.1 better). Of course that means it'll only work on computers that are running that framework but it should be the standard by now. I highly recommend upgrading to it if you haven't already.

 

Assuming I didn't make any more minor human errors and it works properly, I will probably be taking a break from the project for a little bit. If another error pops up and you discover it, feel free to tweet me about it or post here and I'll check into it as soon as I can.


~James~
Even if you can't rely on anyone else, just pull yourself together and roar!
My Website :: The Ultimate Rurouni Kenshin FAQ

sig.gifiyouboushi.png


#8 Iyouboushi

Iyouboushi

    Administrator

  • Administrators
  • 10,457 posts
  • LocationIn the Temen-ni-Gru ruining Vergil's day

Posted 22 February 2014 - 12:55 PM

lol I thought I was going to be taking a break from the project but I got inspired to try to and make the emulation bot work with ePSXe so that I could test the bot on Symphony of the Night. I won't be including ePSXe in the release pack though as it requires BIOS files to run (and those are technically illegal to be including). If you find your own copy you can make it work right (I'll update the opening post to say how to set up the keys correctly).

In any case, I won't be uploading this version til Monday at the earliest, but here's a demo of it working (playing the Japanese version of SotN):



SPOILER! Richter eventually vanquishes the evil Dracula... it just took 15 minutes (shortened down to 6 1/2 min in this video). I can't believe it eventually won. Of course this is partially due to the fact that you're invincible if you die the first time..but still. The rest of the footage after where I stopped this video didn't have anything of interest.




With release 006 it will be possible to tell the programs to use any emulator you can think of and it should work (it's still experimental though). However, the more complicated emulators (like PSX, NGC, Wii, PS2, etc) are far harder to control meaning the bot won't do a very good job (and I imagine IRC would have too much of a delay). These programs work best with the more simple consoles (NES, GB, GBA). But I'm trying to make it so it can run anything just for those who would be curious enough to try it..


~James~
Even if you can't rely on anyone else, just pull yourself together and roar!
My Website :: The Ultimate Rurouni Kenshin FAQ

sig.gifiyouboushi.png


#9 Iyouboushi

Iyouboushi

    Administrator

  • Administrators
  • 10,457 posts
  • LocationIn the Temen-ni-Gru ruining Vergil's day

Posted 24 February 2014 - 08:53 AM

Release 006 includes versions 1.3 of the IRC client and 1.2 of the console bot.

 

In this release I’ve added support for the “C” button that SEGA Genesis uses (set it to keyboard key I) and added support for the PSX buttons (you’ll have to look at the readme text for that though as there’s many buttons). I’ve added fceux to the IRC emulation list and cleaned that up a little (it’s by console -> emulator available now instead of just a list of emulators). On the code side of the IRC client, I’ve fixed a bug that would cause the program to crash if you hit “SEND” before you were connected to a channel. Speaking of channels, I’ve changed the client to check for the “#” in the channel name and add it if it’s missing.

 

Perhaps the best change to both versions is better window handle search functionality. This means it’s now possible to use pretty much any emulator with both programs. In the IRC version you can use the command /setemu (emulator name) to manually select an emulator that isn’t in the official menu list (such as /setemu ePSXe). The console version already has a menu option you can choose and follow the prompts. To make this work with the console version I had to include a bunch of default control config files, so please don’t remove these. You can still use custom ones for certain games though but if you don’t have one for a specific game use the default config for the console you’re trying to play.
Just as a quick warning, the better window search functionality seems to be working pretty good but there’s still a chance that it might not be able to find the emulator that you’re trying to use. It’s still experimental, so keep that in mind. Also you still have to set the keys up the way you would normally.

 

My next goal in this program is to make it so you can define the keys used by the programs instead of it being forced to use the built-in ones. This might take a while though.


~James~
Even if you can't rely on anyone else, just pull yourself together and roar!
My Website :: The Ultimate Rurouni Kenshin FAQ

sig.gifiyouboushi.png


#10 bswaldmann

bswaldmann

    Hollow

  • Members
  • 3 posts

Posted 24 February 2014 - 02:28 PM

I've got a problem, your program likes to push buttons twice.

 

I've set it up to play Advance Wars 2 over here: http://www.twitch.tv/bisw1

 

Every time anyone push a direction, the cursor moves two spots over.

 

Just letting you know, as I'm also pursuing solutions on my end...







Also tagged with one or more of these keywords: c#, programs, games, emulation

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users