Hello Guest

Programmer Mode Tutorials

  • 9 Replies
  • 7163 Views
*

Seuntjie

  • *****
  • 496
  • +14/-2
    • View Profile
Programmer Mode Tutorials
« on: March 14, 2018, 02:07:13 pm »
Please have a look at some of the tutorials that's available for DiceBots programmer mode if you're having trouble with it:

The steemit tutorials are typically for beginner programmers and explain things like variables, functions and if statements. Tutorial 1.1 (variables), 1.2 (functions) and 2 (process) can be handy for experienced programmers that are new to dicebot though, as they contain a list of bot specific variables and functions that is available in the programmer mode and outlines the process of the programmer mode and how it fits into DiceBots overall system.

The youtube tutorials assume prior programming knowledge and focuses on utilizing the programmer mode, not on teaching how to program

Steemit:
https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-01-overview
https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-1-1-variables
https://steemit.com/seuntjie/@seuntjie/dicebot-programmer-mode-tutorial-01-2-functions
https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-02-process
https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-03-martingale
https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-04-martingale-and-mini-if-tutorial

Youtube
https://www.youtube.com/watch?v=m79E9QKm9PI&index=1&list=PLZH88mwZAXLxVtHpc3PIFamkiT1o2V3LX&t=1s
https://www.youtube.com/watch?v=k1GlmmXjtYc&index=2&list=PLZH88mwZAXLxVtHpc3PIFamkiT1o2V3LX&t=0s
https://www.youtube.com/watch?v=MmqZbpaJmH4&index=3&list=PLZH88mwZAXLxVtHpc3PIFamkiT1o2V3LX&t=2s
https://www.youtube.com/watch?v=RlxPCWG3zD8&index=4&list=PLZH88mwZAXLxVtHpc3PIFamkiT1o2V3LX&t=597s

Forum Tutorials
Creating Functions - https://forum.seuntjie.com/index.php?topic=2.msg963#msg963
Modulo (every x something) - https://forum.seuntjie.com/index.php?topic=2.msg2086#msg2086
Resumable script (doesn't reset when you call start())-  https://forum.seuntjie.com/index.php?topic=2.msg2195#msg2195

I also have a quick overview of the programmer mode on https://bot.seuntjie.com/programmermode.aspx with a UML of the bet class.
« Last Edit: March 10, 2020, 01:00:28 pm by Seuntjie »

*

koyin

  • *
  • 4
  • +0/-0
    • View Profile
Re: Programmer Mode Tutorials
« Reply #1 on: March 27, 2018, 08:17:26 pm »
thanks for tutorials!!!

will there any further entries for more complex issues?

*

Seuntjie

  • *****
  • 496
  • +14/-2
    • View Profile
Re: Programmer Mode Tutorials
« Reply #2 on: March 28, 2018, 01:24:08 pm »
What issues would you like to be adressed?

*

koyin

  • *
  • 4
  • +0/-0
    • View Profile
Re: Programmer Mode Tutorials
« Reply #3 on: March 28, 2018, 08:51:22 pm »
i think a tutorial on creating new functions would be perfect.


*

Seuntjie

  • *****
  • 496
  • +14/-2
    • View Profile
Re: Programmer Mode Tutorials
« Reply #4 on: March 10, 2019, 05:13:21 pm »
Tutorial on creating functions:

A function is a piece of code you can call using a name and some parameters to do a task. For example, you can write a function to add two numbers together. You would call the function using it's name and give the two numbers you want added together as parameters, and the function will return the result. A function does not need to return a value. An example function that doesn't return a value can for example print out the parameters in a certain format.

The syntax of a function:
Code: [Select]
--<tell lua you're creating a function>     <the function name>          <the parameters, separated by columns)
function                                                  AddNums                           (number1, number2)

--<perform function logic inside the function body>
sum = number1+number2

--<return a value for the function>
return sum

--<specify the end of your function>
end


Example function without comments:
Code: [Select]
function AddNums(number1, number2)
   sum = number1+number2
   return sum
end

--use this function in another function or another part of the code
result = AddNums(987654321,123456789)
print(result)

Example of a more complex function that doesn't return a value
Code: [Select]
function prettyprint(bal, profit, bets, wins)
  if bets%1000==0 then --every 1000 bets
    print('Your Balance:'.bal)
    print('You\'ve made '.profit.' Profit so far')
    print('You\'ve made a total of '.bets.' bets')
    print('Of which you have won '.wins)
    print('And have lost '.(bets-wins))
  end
end


Your function name can be anything, as long as it is one word and there is no other function or variable with the same name. You can have as few or as many parameters as you need (I think there's a limit on parameters you can have, but it should be higher than you will ever practically need. If you need to use that many parameters, you need to restructure your code to have more and smaller functions). Functions do not need to return a value, if one does, you can get the result by assigning it to a value as I showed in the AddNums example.

Why use functions?
Functions are re-usable, so any time you have a piece of code that might be repeated, with the same or different values, it's worth putting them into functions. This allows you to have a single place to make changes if something in your code has to change in regards of what the function is doing, instead of having to search through your code for everywhere that you did the same thing and fixing it in 20 different places. It also typically makes your code easier to understand when others read and easier to maintain yourself.

*

Seuntjie

  • *****
  • 496
  • +14/-2
    • View Profile
Re: Programmer Mode Tutorials
« Reply #5 on: January 14, 2020, 11:27:29 am »
Modulo Tutorial (Often referred to as Modulus)

A frequent requirement for scripts is to repeat an action after every x of something. I've seen a lot of people approach this problem by using a custom variable that increments and is reset when the requirements are met. While the approach works, it gives space for errors to occur, especially once you start using more complex scripts.

A simpler solution to the problem is to use the modulo (%) operator.

As per wikipedia:
Quote
In computing, the modulo operation finds the remainder after division of one number by another. Given two positive numbers, a and n, a modulo n is the remainder of the Euclidean division of a by n, where a is the dividend and n is the divisor.

In short, it calculates the remainder after a division, for example:
Code: [Select]
5/2 = 2 with 1 remainder ((2*2)+[u]1[/u]=5)
Thus 5%2 = 1
15/6 = 2 with 3 remainder (6*2)+[u]3[/u]=15)
15%6 = 3
100/20 = 5 with 0 remainder.
100%20 = 0

You can use the modulo operator to determine when something is a factor of something else, for example

Code: [Select]
if currentstreak%3==0 and win then
--this will execute after EVERY 3 winning bets in a row, so after 3 in a row, 6 in a row, 9 in a row etc
end
if currentstreak==3 then
--this will execute after exactly 3 wins in a row
end
if wins%3==0 and win then
--after every 3 wins, regardless of whether they are in a streak or not
end
if wins == 3 then
--after you've won exactly 3 bets and then never again
end
[/quote]

*

rzjunction

  • **
  • 11
  • +0/-0
    • View Profile
Re: Programmer Mode Tutorials
« Reply #6 on: February 22, 2020, 11:00:19 am »
I'd like to find out what syntax is and what language this is using. For example, in trying to format a printout I tried

print(counter "counter") but it throws an error. I also tried print(counter, "counter") but it also throws an error.

Also some of the variables seem to be missing. For example, what is the variable for Largest Bet (which shows on the interface but seems to have no variable listed for it).

*

Seuntjie

  • *****
  • 496
  • +14/-2
    • View Profile
Re: Programmer Mode Tutorials
« Reply #7 on: February 22, 2020, 11:11:02 am »
I'd like to find out what syntax is and what language this is using. For example, in trying to format a printout I tried

print(counter "counter") but it throws an error. I also tried print(counter, "counter") but it also throws an error.

Also some of the variables seem to be missing. For example, what is the variable for Largest Bet (which shows on the interface but seems to have no variable listed for it).

The programmer mode uses LUA

See the steemit tutorials in the first post of this thread for more details, as well as a list of available variables and functions. There's also a list of variables and methods in the bot if you go to the Variables and Methods/Functions tabs.

If a variable isn't in there, it isn't available in the programmer mode. Most stats are not available as a variable in the programmer mode.

*

Seuntjie

  • *****
  • 496
  • +14/-2
    • View Profile
Re: Programmer Mode Tutorials
« Reply #8 on: March 10, 2020, 12:59:31 pm »
Resumable Script

This pattern will allow your script to resume betting by simply clicking start in case the script was stopped (you cannot automatically resume once the bot has been stopped. If you don't want it to stop, don't use the stop function. If it stopped because of an error, you don't want it to resume automatically, believe me.)
Code: [Select]
function dobet()
--your logic here
end

function initialize()
    if initialized!=true then
        print('Initializing')
        initialized=true
        --define and set your variables that would normally be at the top of your script here.
        --DO NOT define a variable here using local, if you do, the rest of the script won't be able to use it
        nextbet   = 0.00000001
        chance    = 49.5
        enablezz  = false
        enablesrc = false
        bethigh   = true
    else
        print('Already initialized, retrying last bet')
    end
end

initialize()

The initialize call at the bottom of the script is important. If it's not called, none of your variables will be declared. When you click start the first time, the script will initialize your variables. If you click start subsequently, it will retry your most recent bet (unless you manually specify a starting bet using the console) and resume betting from there. If you want the bot to reset, set initialized=false in the console before starting the bot.

*

JohnB75

  • **
  • 7
  • +0/-0
    • View Profile
Re: Programmer Mode Tutorials
« Reply #9 on: April 11, 2020, 12:13:19 pm »
How to code in a Btc Profit Reset.