Tom's RSS Pro for Playtech Tutorial: Using Silver's Scripts.
This one will be a big Tutorial...
Lots of stuff to go through.
With a new script from Silver that I paid for.
It answers many of the questions I had.
This will hopefully be a full in depth Tutorial.
Will many of the old stuff covered.
And new stuff added in.
So from Design to getting the bot doing what it is supposed to do.
And that is. To place bets on the roulette table.
With any luck... It may even win a few rounds.
First thing we do is Design what the bot will look like.
If you haven't already, then I recommend that you should read Design tutorial I did.
link:://rouletteforum.cc/coding-for-roulette/tom%27s-rss-pro-tutorial-v4-%28design%29-in-depth/ (link:://rouletteforum.cc/coding-for-roulette/tom%27s-rss-pro-tutorial-v4-%28design%29-in-depth/)
Here is the video of the first part of the design.
Just simply adding in a form, and units.
Changing the font, the color, the features of the window.
Tom's RSS Pro for Playtech Tutorial: Using Silver's Scripts. Video 1. (link:://:.youtube.com/watch?v=PV59wADgpFo#)
Ok, we continue with the design.
Adding in the memos.
4 memos are added in.
3 are for the numbers that come in from the casino.
Memo_BN for black numbers.
Memo_0N for the Zero number.
Memo_RN for red numbers.
Memo_Results for the results.
Memo_Results will be used a fair bit for testing and to show what is going on.
Here is the video for it.
Tom's RSS Pro for Playtech Tutorial: Using Silver's Scripts. Video 2. (link:://:.youtube.com/watch?v=G_Ur93L2rRo#)
Here is the code for Unit1
uses
Classes, Graphics, Controls, Forms, Dialogs, Unit2, Unit3, Unit4;
var
MainForm: TForm2;
begin
MainForm := TForm2.Create(Application);
MainForm.Show;
end;
As you can see I have added in Unit3, Unit4;
Now for the final part of design.
[attachimg=1]
[attachimg=2]
Tom's RSS Pro for Playtech Tutorial: Using Silver's Scripts. Video3. (link:://:.youtube.com/watch?v=1w2uy1xQQzs#)
Now that the main design is done.
We can start coding it.
For those wishing to see the videos in better quality.
Here are the links for the videos I have done so far.
link:://rouletteprofesor.com/vids/rss_pro_playtech_vid1/rss_pro_playtech_vid1.html (link:://rouletteprofesor.com/vids/rss_pro_playtech_vid1/rss_pro_playtech_vid1.html)
link:://rouletteprofesor.com/vids/rss_pro_playtech_vid2/rss_pro_playtech_vid2.html (link:://rouletteprofesor.com/vids/rss_pro_playtech_vid2/rss_pro_playtech_vid2.html)
link:://rouletteprofesor.com/vids/rss_pro_playtech_vid3/rss_pro_playtech_vid3.html (link:://rouletteprofesor.com/vids/rss_pro_playtech_vid3/rss_pro_playtech_vid3.html)
Plus, I have included the bot to where I got to.
Much more to come.
I know I posted this before.
Just wanted to make sure you understood it.
In this video I show the how and why of these two procedures.
Tom's RSS Pro for Playtech Tutorial: Using Silver's Scripts. Video4. (link:://:.youtube.com/watch?v=qMWSFG2TUBI#)
var F : Text;
S : String;
var i;
{#### Window Operations ##############################################}
procedure close_me;
begin
if Self.Top<0 then Self.Top:=0;
if Self.Left<0 then Self.Left:=0;
AssignFile(F,'c:\rss-data\winpos');
Rewrite(F);
Writeln(F,Self.Top);
Writeln(F,Self.Left);
CloseFile(F);
end;
procedure load_winpos;
begin
AssignFile(F,'c:\rss-data\winpos');{If no file exist. Then you will get an error message}
Reset(F);{open the file for reading}
i := 0;
while not eof(F) do {loop that will repeat until the end of file will be not found}
begin
S:=ReadLn(F); {read the first line into "s" variable}
if i=0 then Self.Top:=s;
if i=1 then Self.Left:=s;
i := i+1;
end;
CloseFile(F);//close the file
end;
{#### End: Window Operations #########################################}
Just make sure you have this folder on your c: drive.
And all should be ok.
c:\rss-data\
Ok, in the video.
I show how I put the window position code into the settings window.
It is the same code.
Only the name of the file it saves to is different.
{#### Window Operations ##############################################}
procedure close_me;
begin
if Self.Top<0 then Self.Top:=0;
if Self.Left<0 then Self.Left:=0;
AssignFile(F,'c:\rss-data\s1_winpos');
Rewrite(F);
Writeln(F,Self.Top);
Writeln(F,Self.Left);
CloseFile(F);
end;
procedure load_winpos;
begin
AssignFile(F,'c:\rss-data\s1_winpos');{If no file exist. Then you will get an error message}
Reset(F);{open the file for reading}
i := 0;
while not eof(F) do {loop that will repeat until the end of file will be not found}
begin
S:=ReadLn(F); {read the first line into "s" variable}
if i=0 then Self.Top:=s;
if i=1 then Self.Left:=s;
i := i+1;
end;
CloseFile(F);//close the file
end;
{#### End: Window Operations #########################################}
Now we add in memo procedures.
These two simple procedures will put numbers into the marque (Memo_RN,Memo_BN,Memo_0N)
And print info into the Memo_Results.
Add last_nr to the variables.
var last_nr;
{#### Memo Operations ################################################}
procedure marque;
begin
if number_is(last_nr,'red')then
begin
Memo_RN.Lines.Insert(0,last_nr);
Memo_BN.Lines.Insert(0,'');
Memo_0N.Lines.Insert(0,'');
end;
if number_is(last_nr,'black')then
begin
Memo_RN.Lines.Insert(0,'');
Memo_BN.Lines.Insert(0,last_nr);
Memo_0N.Lines.Insert(0,'');
end;
if number_is(last_nr,'single0')then
begin
Memo_RN.Lines.Insert(0,'');
Memo_BN.Lines.Insert(0,'');
Memo_0N.Lines.Insert(0,last_nr);
end;
end;
procedure print_to_memo(arg1);
begin
Memo_Results.Lines.Add(arg1);
end;
{#### End: Memo Operations ###########################################}
Now we have some procedures in the code.
Lets add some more that will be used later on.
This is the latest system script that Silver sent me.
And I will try and explain how we will be using this later on.
I wont put the code in the post.
As it is a bit to big.
These are the main procedure that do all the work.
procedure add_system;
Here you can add your own system to the procedure.
procedure el_init(ei_elements; var ei_elements);
This is to initiate the elements in the systems.
procedure el_bet(eb_elements; var eb_elements);
This is used to place bets on the casino table.
procedure stack_array(sa_elements; var sa_elements);
Stacks or counts how many times a systems has not hit, or has hit.
procedure change_it(ci_elements,k,k1,id; var ci_elements);
New one from Silver. Here you can change the different element settings.
I will be modifying this part and showing you how we use it later on.
So I have uploaded where the script for you to read.
Ok, now I will go into a bit of detail on menus.
And I will add in a menu option so I can chose what chip set to play with.
chips:=[0,0.1,1,5,10,25,100,500];//here you need to specify chip values
Here is a video of it.
Tom's RSS Pro for Playtech Tutorial: Using Silver's Scripts. Video5. (link:://:.youtube.com/watch?v=3f5yP-imlAs#ws)
And the code.
procedure MainMenu1_10cClick(Sender: TObject);
begin
chips:=[0,0.01,0.1,0.50,1,5,10,25];//here you need to specify chip values
end;
procedure MainMenu1_50cClick(Sender: TObject);
begin
chips:=[0,0.1,0.50,1,5,10,25,100];//here you need to specify chip values
end;
Now that we have done a menu option.
Time to get this bot going.
Time for it to start betting.
First we add in a window procdure.
Form2Create
procedure Form2Create(Sender: TObject);
begin
load_winpos;
end;
And we move the load_winpos; procedure into it.
Then we add these lines to the Form2Activate
procedure Form2Activate(Sender: TObject);
begin
add_system;
chips:=[0,0.01,0.1,0.50,1,5,10,25];//here you need to specify chip values
unit_value:=0.10; //here you need to specify values of 1 unit
start_amount:=StrToFloat(Edit_Balance.Text);
amount:=start_amount;
wish_amount:=amount+StrToFloat(Edit_Profit.Text);
stop_loss:=StrToFloat(Edit_StopLoss.Text);
sim_mode:=0;
total_elements:=0;
el_init(elements,elements);
el_init(elements1,elements1);//here we set the elements
spin_count:=1;
was_betting:=1;
fl_stop:=0;
elements_played:=0;
end;
Ok, now that we got the basic done.
Lets get this bot doing something.
Here is the start button code.
This will get it cranking.
procedure Button_StartClick(Sender: TObject);
begin
unit_value:=1; //here you need to specify values of 1 unit
set_roulette_window_name('European Roulette - EuroGrand Casino');
while amount<wish_amount do begin
if (was_betting=1)and(sim_mode<>1) then begin ide_delay:=250;click_chip3();click_red();delay(200);click_chip3();click_even();delay(200);click_clear_bets(); end;
was_betting:=0;
elements_played:=0;
el_bet(elements,elements);
el_bet(elements1,elements1);//here we bet
if was_betting=0 then ide_delay:=200;//the speed of free spins. Very small value increase the speed but may pause the script itself, you can try 150
if (fl_stop=1)or(elements_played=total_elements) then break;
click_spin;
last_nr:=get_last_number();
marque;
stack_array(elements,elements); stack_array(elements1,elements1);
print_to_memo('Spin count - '+IntToSTr(spin_count)+'. Landed numbrer is '+IntToStr(last_nr)+'. Current amount is $'+FormatFloat('0.##',amount));
print_to_memo('-------------------------------------------');
if amount<=stop_loss then break;
Inc(spin_count);
end;
In the stop button.
I add this very small code to stop the process.
procedure Button_StopClick(Sender: TObject);
begin
fl_stop:=1;
end;
And in the edit balance field.
I put this in.
procedure Edit_BalanceKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
end;
end;
Here is video number 6 of it in action.
Tom's RSS Pro for Playtech Tutorial: Using Silver's Scripts. Video6. (link:://:.youtube.com/watch?v=x9w-26wGhCY#ws)
Plus the latest project file.
Check out this video I did.
This is showing RSS Pro running at Playtech at full speed.
And I only have half the bets done so far.
Tom's RSS Pro for Playtech Tutorial: Using Silver's Scripts. Video7. (link:://:.youtube.com/watch?v=WZlMBZX--rs#)
I was not to happy with the way this tutorial was going.
But have decided to carry on anyway...
A great deal of time is spent on looking things up.
On how to do things.
Or what does what.
Recently, I have tried to understand more of this amazing software.
Had a look into Databases.
How to create them.
How to send info to them.
Still have no clue...
I delved into Tabs...
How to use them.
I looked into memos.
How to save the info from them.
All sorts of stuff.
There are many problems when trying to code for this software.
1. There is not a great deal of help.
2. I have to constantly look up for help in Delphi webpages.
3. Then I have to convert what I read in Delphi to what I can do in RSS Pro.
4. It takes time.
But enough of me complaining...
And onto some interesting code.
One of my pet peeves is window positions.
When you close the software.
It should, on close. Remember where it was on your screen.
I was having no end of trouble figuring this out.
It works fine for the single window.
Or single form.
But when you try to load a second form.
And have it go to the last saved position where you left it.
Well... it was a nightmare trying to solve it.
First I looked into database.
How to save the window position to the database.
That proved way to hard.
And I still haven't figured out databases.
Maybe one day.
Then I can do a tutorial on that.
Anyway...
Back to window positions on the second form.
Oy veay...
So I went back to my original idea.
There must be a way to save the window position on the other form.
You see it all has to do with Self.Top and Self.Left
Since every form you create has it's own self.top and self.left
But when you close the form.
I sends that info to the first form.
So when you close it.
And open it again.
It opens in a different area.
Maddening...
Now I have posted these before.
But here they are again.
Here is the procedure I use to load the window position.
procedure load_winpos;
begin
AssignFile(F,'c:\rss-data\winpos');{If no file exist. Then you will get an error message}
Reset(F);{open the file for reading}
i := 0;
while not eof(F) do {loop that will repeat until the end of file will be not found}
begin
S:=ReadLn(F); {read the first line into "s" variable}
if i=0 then Self.Top:=s;
if i=1 then Self.Left:=s;
i := i+1;
end;
Self.ClientHeight:=368;
CloseFile(F);//close the file
end;
Fairly straight forward.
Ahh, but then came the awakening...
I had to have that part first.
Then do the save window position like this.
procedure close_me;
begin
if Self.Top<0 then Self.Top:=0;
if Self.Left<0 then
begin
Self.Left:=0;
load_winpos;
end;
AssignFile(F,'c:\rss-data\winpos');
Rewrite(F);
Writeln(F,Self.Top);
Writeln(F,Self.Left);
CloseFile(F);
end;
But that ain't the sneaky part...
This is.
This code is on the second form.
procedure close_me;
begin
if Self.Top<0 then Self.Top:=0;
if Self.Left<0 then
begin
Self.Left:=0;
load_winpos;
end;
AssignFile(F,'c:\rss-data\set_winpos');
Rewrite(F);
Writeln(F,Self.Top);
Writeln(F,Self.Left);
CloseFile(F);
Self.Left:=-1000;
Close();
end;
{####
The load_winpos; procedure is the same.
Only the name of the data file to save the position to, is changed.
So what happens in the other close, on the other form is this.
On close.
It moves it's self to the left -1000
Now before it does that.
It saves the original window position.
Then it closes.
Now before you close form2.
It does this.
if Self.Left<0 then
begin
Self.Left:=0;
load_winpos;
end;
So what it does, is it sees that the Self.Left is less than 0;
So it reloads the original winpos from the file.
Then closes it.
Wow, that took ages to work out.
Probably not the best way to do things.
But since I don't know how to save .ini files for each window.
I have to make do with what I know works for me.
If you know a better way to do this.
Then please tell me.
I have looked.
Believe me.
What works in Delphi.
Does not mean it will work in RSS Pro.
And vice a versa.
Especially when it comes to arrays.
Ohh well...
I just keep plodding along.
Right now I am trying different ways to communicate between forms.
Trying to find the best way for my settings to displayed.
And read. And then modified.
Frak it is hard...
Hi ho Silver to the rescue...
Silver does it again...
I ask him how to do something.
And he sends me the answer.
What great support.
I asked him how he would do the save window position.
As I was having no end of trouble.
Knew there had to be a better way.
And here is his answer.
procedure Form3Close(Sender: TObject; var Action: TCloseAction);
var x:TForm;
begin
x:=Sender;
AssignFile(F,'c:\winpos3');
Rewrite(F);
Writeln(F,x.Top);
Writeln(F,x.Left);
CloseFile(F);
end;
And when you read that.
You can see that x:=Sender;
Comes from the
procedure Form3Close(Sender: TObject; var Action: TCloseAction);
So the information comes from that form.
And not any others.
Latest video.
Tom's RSS Pro for Playtech Tutorial: Using Silver's Scripts. Video8. (link:://:.youtube.com/watch?v=BSZVn2-S4QM#ws)
I will continue to add script to this bot of mine.
Until I have it finished.
Then I may do a follow up.
Add more to this tutorial.
Show how I built it.
Ok, in this post.
I will be going over Load and Save.
Using the OpenDialog1 and SaveDialog1
So in these two procedures.
I will be Loading and Saving settings.
Save_Settings;
In this part of the code.
We open up the SaveDialog requester window.
SaveDialog1.Title:='Save Files: Settings'; {The Titles of the Dialog Window}
SaveDialog1.InitialDir:='';
SaveDialog1.DefaultExt := 'txt';
SaveDialog1.FileName:='settings';
SaveDialog1.Filter:='Txt files (*.txt)|*.txt';
{ InitialDir: The folder you wish the Dialog window to open in}
SaveDialog1.Execute(false); {This Opens the Dialog window}
if SaveDialog1.FileName='' then ShowMessage('Save file was cancelled');{If you press cancel, this message will appear}
Now, not sure if you noticed.
But we used a fair few options before the Dialog window was opened.
So let's take a look at them.
SaveDialog1.InitialDir:='';
{Opens the Dialog window in the folder you are working in}
SaveDialog1.FileName:='settings';
{Here we can set the name of the file wish to save}
SaveDialog1.DefaultExt := 'txt';
SaveDialog1.Filter:='Txt files (*.txt)|*.txt';
{These two deal with file extensions}
The next part of the code is where we save the info from Form3.
if SaveDialog1.FileName='' then ShowMessage('Save file was cancelled');{If you press cancel, this message will appear}
else if SaveDialog1.FileName<>'' then
begin
Form3:=TForm3.Create(Application);{Here I create the application without opening it}
AssignFile(F,SaveDialog1.FileName);
Rewrite(F);
Writeln(F,Form3.Edit_Max_Red.Text);
Writeln(F,Form3.Edit_Max_Black.Text);
Writeln(F,Form3.Edit_Max_High.Text);
Writeln(F,Form3.Edit_Max_Low.Text);
Writeln(F,Form3.Edit_Max_Odd.Text);
Writeln(F,Form3.Edit_Max_Even.Text);
Writeln(F,Form3.Edit_Max_DL.Text);
Writeln(F,Form3.Edit_Max_DM.Text);
Writeln(F,Form3.Edit_Max_DH.Text);
Writeln(F,Form3.Edit_Max_C1.Text);
Writeln(F,Form3.Edit_Max_C2.Text);
Writeln(F,Form3.Edit_Max_C3.Text);
Writeln(F,Form3.Edit_Max_DLM.Text);
Writeln(F,Form3.Edit_Max_DLH.Text);
Writeln(F,Form3.Edit_Max_DMH.Text);
Writeln(F,Form3.Edit_Max_C12.Text);
Writeln(F,Form3.Edit_Max_C13.Text);
Writeln(F,Form3.Edit_Max_C23.Text);
Writeln(F,Form3.Edit_Max_Tier.Text);
Writeln(F,Form3.Edit_Max_Voisins.Text);
Writeln(F,Form3.Edit_Max_Orph.Text);
ShowMessage('Save file '+SaveDialog1.FileName);{If a filenam is selected then show this message}
CloseFile(F);
end;
So that is SaveDialog.
Next is OpenDialog.
OpenDialog.
Here, I open the OpenDialog window so I can load in some saved settings.
OpenDialog1.Title:='Open Files: Settings'; {The Titles of the Dialog Window}
OpenDialog1.InitialDir:='';
OpenDialog1.DefaultExt := 'txt';
OpenDialog1.FileName:='settings';
OpenDialog1.Filter:='Txt files (*.txt)|*.txt';
{ InitialDir: The folder you wish the Dialog window to open in}
OpenDialog1.Execute(false); {This Opens the Dialog window}
if OpenDialog1.FileName='' then ShowMessage('Open file was cancelled');{If you press cancel, this message will appear}
And you add these lines in.
else if OpenDialog1.FileName<>'' then
begin
Form3:=TForm3.Create(Application);
AssignFile(F,OpenDialog1.FileName);{If no file exist. Then you will get an error message}
Reset(F);{open the file for reading}
i := 0;
while not eof(F) do {loop that will repeat until the end of file will be not found}
begin
S:=ReadLn(F); {read the first line into "s" variable}
if i=0 then Form3.Edit_Max_Red.Text:=s;
if i=1 then Form3.Edit_Max_Black.Text:=s;
if i=2 then Form3.Edit_Max_High.Text:=s;
if i=3 then Form3.Edit_Max_Low.Text:=s;
if i=4 then Form3.Edit_Max_Odd.Text:=s;
if i=5 then Form3.Edit_Max_Even.Text:=s;
if i=6 then Form3.Edit_Max_DL.Text:=s;
if i=7 then Form3.Edit_Max_DM.Text:=s;
if i=8 then Form3.Edit_Max_DH.Text:=s;
if i=9 then Form3.Edit_Max_C1.Text:=s;
if i=10 then Form3.Edit_Max_C2.Text:=s;
if i=11 then Form3.Edit_Max_C3.Text:=s;
if i=12 then Form3.Edit_Max_DLM.Text:=s;
if i=13 then Form3.Edit_Max_DLH.Text:=s;
if i=14 then Form3.Edit_Max_DMH.Text:=s;
if i=15 then Form3.Edit_Max_C12.Text:=s;
if i=16 then Form3.Edit_Max_C13.Text:=s;
if i=17 then Form3.Edit_Max_C23.Text:=s;
if i=18 then Form3.Edit_Max_Tier.Text:=s;
if i=19 then Form3.Edit_Max_Voisins.Text:=s;
if i=20 then Form3.Edit_Max_Orph.Text:=s;
i := i+1;
end;
CloseFile(F);//close the file
ShowMessage('Open file '+OpenDialog1.FileName);{If a filenam is selected then show this message}
Form3.Showmodal;
end;