BlackJack.cpp

Messing around with IDA-PRO. This was an assignment, but since my class is switching to Java I have decided to complete it and post the source code.
Here is the link to the GitHub repo: https://github.com/Jyang772/BlackJack

You create two classes, Deck and Card. Deck has a private array of 52 Card objects. Each card object describes one card. It holds the card’s rank and suit.

Engie Union

This is just a small collection of photos that show what we engies can accomplish. Trololol.

Sins of a Solar Empire CE Script

This is a script that I found (and now modified) for Cheat Engine. Create a script file and load it into Cheat Engine, then select the Sins of a Solar Empire process. Change the values from 0 to 1 to enable a particular cheat. The following code is assembly language.

 

{
===========================================
 Game Title    : Sins of a Solar Empire - Rebellion
 Game Version  : 1.80.4976
 Game Sponsor  : MySelf (via Steam)
 Proces Name   : "Sins of a Solar Empire Rebellion".exe
 Script Version: 4.0
 CE Version    : 6.3
 Release date  : 07-Nov-2013
 Author        : Recifense
 History:
 13-Jun-12: First Release
 13-Jun-12: Fixed the cheats related to planets
 13-Jun-12: Adapted to version 1.02.4185
 18-Jun-12: Some features were added
 02-Jul-12: Adapted to version 1.03.4243 + New feature (XP)
 04-Jul-12: Killing a bug introduced in previous version
 12-Jul-12: New feature (Quick Startbase Upgrade)
 13-Sep-12: Adapted to version 1.04.4397 (Reloaded)
 05-Dec-12: Adapted to version 1.1.4480   (STEAM)
 05-Jun-13: Release for version 1.5.4755  (STEAM)
 22-Jun-13: Release for version 1.51.4787 (STEAM)
 28-Jun-13: Release for version 1.52.4792 (STEAM)
 07-Nov-13: Release for version 1.80.4976 (STEAM)
 Features:
 - Minimum Resources
 - God Mode
   - Ships  (hull and shield)
   - Planet (HP and Population)
 - Quick Kill
 - Full Antimatter,
 - Quick Research
 - Unlimited Ships
 - Quick Production (of Ships)
 - Quick Construction
 - Quick Planet Upgrade
 - Quick Level Up
 - Quick Starbase Upgrade
===========================================
}

//=========================================
// Definitions
define(LUDO,"Sins of a Solar Empire Rebellion.exe")

define(MORE,"Sins of a Solar Empire Rebellion.exe"+0019ca63) //====
define(MKUN,"Sins of a Solar Empire Rebellion.exe"+00122e4e) //==++
define(GDMD,"Sins of a Solar Empire Rebellion.exe"+0010031b) //====
define(MOSD,"Sins of a Solar Empire Rebellion.exe"+001002a8) //====
define(MOAM,"Sins of a Solar Empire Rebellion.exe"+000e0380) //====
define(PTPP,"Sins of a Solar Empire Rebellion.exe"+001458a0) //====
define(QKRH,"Sins of a Solar Empire Rebellion.exe"+00125e11) //====
define(GMDP,"Sins of a Solar Empire Rebellion.exe"+0011bde1) //====
define(MOSY,"Sins of a Solar Empire Rebellion.exe"+0005d986) //====
define(MOPN,"Sins of a Solar Empire Rebellion.exe"+0012d24d) //*===
define(MOCN,"Sins of a Solar Empire Rebellion.exe"+000e4ecb) //====
define(MOUP,"Sins of a Solar Empire Rebellion.exe"+0014f75b) //====
define(MCN2,"Sins of a Solar Empire Rebellion.exe"+00238a4e) //====
define(MOXP,"Sins of a Solar Empire Rebellion.exe"+0013aeee) //====
define(MXP2,"Sins of a Solar Empire Rebellion.exe"+000f874e) //====
define(MSBU,"Sins of a Solar Empire Rebellion.exe"+00137e9b) //====

//=========================================
[ENABLE]
//=========================================
//LuaCall(CheckVersion())
//=========================================
// Check if script is compatible to this game version
// If false the script will not be loaded

assert(MORE,d8 c1 d9 59 20 ?? ?? d9 41 08 d8 c1 d9 59 08 8b 49 04 8b 01)
assert(MKUN,8b 41 08 8b 4c 24 04 50 8b 81 e8 17 00 00 e8 ?? ?? ?? ?? c2)
assert(GDMD,d9 5b 0c d9 1c 24 e8 ?? ?? ?? ?? 8b 4b 04 8b 11 8b 42 4c ff)
assert(MOSD,d9 5b 10 d9 1c 24 e8 ?? ?? ?? ?? d9 45 0c 51 8b fb d9 1c 24)
assert(MOAM,d9 41 08 d8 64 24 04 d9 5c 24 04 d9 44 24 04 d9 51 08 d9 5c)
assert(PTPP,d9 41 10 d8 64 24 04 d9 5c 24 04 d9 44 24 04 d9 51 10 d9 5c)
assert(QKRH,d9 44 24 14 d9 55 2c dd 05 ?? ?? ?? ?? d9 5d 34 d9 05 ?? ??)
assert(GMDP,d9 9d 8c 00 00 00 e8 ?? ?? ?? ?? 85 db 0f 84 ?? ?? ?? ?? 8b)
assert(MOSY,d9 43 04 d9 5e 04 57 d9 43 08 8d 7b 10 d9 5e 08 8d 46 10 d9)
assert(MOPN,d9 9e 00 02 00 00 59 c2 08 00 cc ?? ?? ?? ?? ?? ?? ?? ?? ??)
assert(MOCN,d9 44 24 1c d9 57 1c d9 e8 de d9 df e0 f6 c4 41 ?? ?? 8b 47)
assert(MOUP,d9 44 24 14 d9 56 2c dd 05 ?? ?? ?? ?? d9 5e 34 de d9 df e0)
assert(MCN2,d9 40 0c d8 74 24 50 d9 5c 24 50 d9 e8 d9 44 24 50 d8 d1 df)
assert(MOXP,dc 5c 24 10 df e0 f6 c4 41 ?? ?? 8b 43 38 83 c0 01 e8 ?? ??)
assert(MXP2,dc 5c 24 10 df e0 f6 c4 41 ?? ?? 8b 43 10 6a 00 83 c0 01 50)
assert(MSBU,d9 44 24 14 d9 56 30 dd 05 ?? ?? ?? ?? d9 5e 38 de d9 df e0)

//=========================================
alloc(MyCode,4096,LUDO)
//=========================================
// Declaration section
label(_MonResources)
label(_MonR0)
label(_MonR1)
label(_BackMR)
label(_ExitMR)
label(_MarkUnits)
label(_BackMU)
label(_ExitMU)
label(_GodMode)
label(_GodM0)
label(_BackGM)
label(_ExitGM)
label(_MonShield)
label(_BackMS)
label(_ExitMS)
label(_MonAM)
label(_BackMA)
label(_ExitMA)
label(_PlanetPop)
label(_BackPP)
label(_ExitPP)
label(_QuickResearch)
label(_BackQR)
label(_ExitQR)
label(_GodModeP)
label(_BackGMP)
label(_ExitGMP)
label(_MonSupply)
label(_BackMSp)
label(_ExitMSp)
label(_MonProduction)
label(_BackMPr)
label(_ExitMPr)
label(_MonConstruction)
label(_BackMCr)
label(_ExitMCr)
label(_MonUpgrade)
label(_BackMUp)
label(_ExitMUp)
label(_MonConstruction2)
label(_BackMCr2)
label(_ExitMCr2)
label(_MonXP)
label(_BackMX)
label(_ExitMX)
label(_MonXP2)
label(_BackMX2)
label(_ExitMX2)
label(_MonSBUpgrade)
label(_BackSUp)
label(_ExitSUp)
label(iEnableGM)
label(iEnableMR)
label(iEnableQR)
label(iEnableMA)
label(iEnableQK)
label(iEnableMSp)
label(iEnableQP)
label(iEnableQC)
label(iEnableQU)
label(iEnableMX)
label(iEnableSU)
label(pSupply)
label(pConst)

//=========================================
// Registering Symbols
registersymbol(MyCode)
registersymbol(iEnableGM)
registersymbol(iEnableMR)
registersymbol(iEnableQR)
registersymbol(iEnableMA)
registersymbol(iEnableQK)
registersymbol(iEnableMSp)
registersymbol(iEnableQP)
registersymbol(iEnableQC)
registersymbol(iEnableQU)
registersymbol(iEnableMX)
registersymbol(iEnableSU)

//=========================================
MyCode:
//========================================= 15
// On main screen
_MonResources:
 push eax

 fadd st(0),st(1)               // Original code
 fstp dword ptr [ecx+20]        // Original code

 mov eax,[ecx+04]               // Get ptr to owner
 or eax,eax
 jz _ExitMR                     // Jump if null pointer

 cmp dword ptr [eax+0c],0       // Is it player's resource?
 jne _ExitMR                    // Jump if false

 lea eax,[ecx+000001b8]
 mov [pSupply],eax

 cmp dword ptr [iEnableMR],0
 je _ExitMR                     // Jump if feature is disabled

 mov eax,(float)9900

 cmp eax,[ecx+08]               // Credits >= 9900.0?
 jle _MonR0                     // Jump if true

 mov [ecx+08],eax               // Credits = 9900.0

_MonR0:
 cmp eax,[ecx+20]               // Metals >= 9900.0?
 jle _MonR1                     // Jump if true

 mov [ecx+20],eax               // Metals = 9900.0

_MonR1:
 cmp eax,[ecx+38]               // Crystals >= 9900.0?
 jle _ExitMR                    // Jump if true

 mov [ecx+38],eax               // Crystals = 9900.0

_ExitMR:
 pop eax
 jmp _BackMR                    // Back to main code

//========================================= 15
// On main screen
_MarkUnits:
 mov eax,[ecx+08]               // Original code (Rds ID)
 or eax,eax                     // Is it a Player's Unit?
 jnz _ExitMU                    // Jump if false

 mov eax,[ecx+04]               // Get ptr to Unit_Base
 or eax,eax                     // Valid pointer?
 jz _ExitMU                     // Jump if false

 or byte ptr [eax+0f],01        // Mark it as player's unit

_ExitMU:
 mov eax,[ecx+08]               // Original code (Rds ID)
 mov ecx,[esp+04]               // Original code
 jmp _BackMU                    // Back to main code

//========================================= 15
// During Battles
_GodMode:
 push eax

 mov eax,[ebx+04]               // Get pointer to Unit_Base
 or eax,eax                     // Valid pointer?
 jz _ExitGM                     // Jump if false

 and byte ptr [eax+0f],01       // Is it a player's unit?
 jz _GodM0                      // Jump if false

 cmp dword ptr [iEnableGM],0
 je _ExitGM                     // Jump if feature is disabled

 fstp st(0)                     // Discard value
 fld  dword ptr [ebx+0c]        // Get current HP
 jmp _ExitGM

_GodM0:
 cmp dword ptr [iEnableQK],0
 je _ExitGM                     // Jump if feature is disabled

 fstp st(0)                     // Discard value
 fldz                           // Make new HP = 0

_ExitGM:
 pop eax

 fstp dword ptr [ebx+0c]        // Original code
 fstp dword ptr [esp]           // Original code
 jmp _BackGM                    // Back to main code

//========================================= 15
// During Battle
_MonShield:
 push eax

 cmp dword ptr [iEnableGM],0
 je _ExitMS                     // Jump if feature is disabled

 mov eax,[ebx+04]               // Get pointer to Unit_Base
 or eax,eax                     // Valid pointer?
 jz _ExitMS                     // Jump if false

 and byte ptr [eax+0f],01       // Is it a player's unit?
 jz _ExitMS                     // Jump if false

 fstp st(0)                     // Discard value
 fld  dword ptr [ebx+10]        // Get current Shield Value

_ExitMS:
 pop eax

 fstp dword ptr [ebx+10]        // Original code
 fstp dword ptr [esp]           // Original code
 jmp _BackMS                    // Back to main code

//========================================= 15
//  This does not let the AntiMatter decrease
_MonAM:
 cmp dword ptr [iEnableMA],0
 je _ExitMA                     // Jump if feature is disabled

 push eax
 mov eax,[ecx+04]               // Get ptr to owner
 and byte ptr [eax+0f],01       // Is it a player's unit?...
 pop eax
 jz _ExitMA                     // ...Jump if false

 mov dword ptr [esp+04],0       // Make value2decrease = 0

_ExitMA:
 fld dword ptr [ecx+08]         // Original code
 fsub dword ptr [esp+04]        // Original code
 jmp _BackMA                    // Back to main code

//========================================= 15
//  This does not let the pop decrease
_PlanetPop:
 cmp dword ptr [iEnableGM],0
 je _ExitPP                     // Jump if feature is disabled

 push eax
 mov eax,[ecx+04]               // Get ptr to owner
 cmp dword ptr [eax+00000634],1 // Is it a player's planet?... **624
 pop eax
 jne _ExitPP                    // ...Jump if false

 mov dword ptr [esp+04],0       // Make value2decrease = 0

_ExitPP:
 fld dword ptr [ecx+10]         // Original code
 fsub dword ptr [esp+04]        // Original code
 jmp _BackPP                    // Back to main code

//========================================= 15
// Start research at 90%
 _QuickResearch:
 fld dword ptr [esp+14]         // Original code
 fst dword ptr [ebp+2c]         // Original code

 push eax

 mov eax,[ebp+04]               // Get ptr ResearchOwner
 cmp dword ptr [eax+28],0       // Is it a player's research ?
 jne _ExitQR                    // Jump if false

 cmp dword ptr [iEnableQR],0
 je _ExitQR                     // Jump if feature is disabled

 mov eax,(float)0.9
 cmp eax,[ebp+2c]               // Current research >= 90%?
 jle _ExitQR                    // Jump if true

 mov [ebp+2c],eax               // Current research = 90%

_ExitQR:
 pop eax
 jmp _BackQR                    // Back to main code

//========================================= 15
// God Mode for Planet
_GodModeP:
 push eax

 cmp dword ptr [iEnableGM],0
 je _ExitGMP                    // Jump if feature is disabled

 mov eax,[ebp+08]               // Get ptr to owner

 cmp dword ptr [eax+00000634],1 // Is it a player's planet? **624
 jne _ExitGMP                   // Jump if false

 fstp st(0)                     // Discard value
 fld  dword ptr [ebp+0000008C]  // Get current HP

_ExitGMP:
 pop eax

 fstp dword ptr [ebp+0000008C]  // Original code
 jmp _BackGMP                   // Back to main code

//========================================= 15
//  This makes the spent supply = 0
_MonSupply:
 push eax

 cmp dword ptr [iEnableMSp],0
 je _ExitMSp                    // Jump if feature is disabled

 cmp ebx,[pSupply]
 jne _ExitMSp

 xor eax,eax
 mov [ebx+24],eax
 mov [ebx+3c],eax
 mov [ebx+54],eax
 mov [ebx+6c],eax
 mov [ebx+00000084],eax
 mov [ebx+000000A4],eax
 mov [ebx+000000BC],eax
 mov [ebx+000000D4],eax
 mov [ebx+000000EC],eax

_ExitMSp:
 pop eax

 fld dword ptr [ebx+04]         // Original code
 fstp dword ptr [esi+04]        // Original code
 jmp _BackMSp                   // Back to main code

//========================================= 15
//  Production start at 90%
_MonProduction:
 push eax

 fstp dword ptr [esi+00000200]  // Original code

 cmp dword ptr [iEnableQP],0
 je _ExitMPr                    // Jump if feature is disabled

 cmp dword ptr,[esi+000001fc],0
 jne _ExitMPr

 mov eax,(float)0.9
 cmp eax,[esi+00000200]
 jle _ExitMPr

 mov [esi+00000200],eax

_ExitMPr:
 pop eax
 jmp _BackMPr                   // Back to main code

//========================================= 15
//  Construction start at 90%
_MonConstruction:
 cmp dword ptr [iEnableQC],0
 je _ExitMCr                    // Jump if feature is disabled

 mov eax,[edi+04]               // Get ptr to owner
 and byte ptr [eax+0f],01       // Is it a player's unit?...
 jz _ExitMCr                    // ...Jump if false

 mov [pConst],eax

 mov eax,(float)0.9
 cmp eax,[esp+1c]
 jle _ExitMCr

 mov [esp+1c],eax

_ExitMCr:
 fld dword ptr [esp+1C]         // Original code
 fst dword ptr [edi+1C]         // Original code
 jmp _BackMCr                   // Back to main code

//========================================= 15
//  Upgrade start at 90% (Planet)
_MonUpgrade:
 cmp dword ptr [iEnableQU],0
 je _ExitMUp                    // Jump if feature is disabled

 mov eax,[esi+04]               // Get ptr to Planet

 cmp dword ptr [eax+00000634],1 // Is it a player's planet? **624
 jne _ExitMUp                   // Jump if false

 mov eax,(float)0.9
 cmp eax,[esp+14]
 jle _ExitMUp

 mov [esp+14],eax

_ExitMUp:
 fld dword ptr [esp+14]         // Original code
 fst dword ptr [esi+2C]         // Original code
 jmp _BackMUp                   // Back to main code

//========================================= 15
//  Hull = 100%
_MonConstruction2:
 cmp dword ptr [iEnableQC],0
 je _ExitMCr2                   // Jump if feature is disabled

 mov edx,[eax+04]               // Get ptr to owner
 and byte ptr [edx+0f],01       // Is it a player's unit?...
 jz _ExitMCr2                   // ...Jump if false

 cmp edx,[pConst]
 jne _ExitMCr2

 mov edx,[esp+50]
 mov [eax+0c],edx

 mov [pConst],edx

_ExitMCr2:
 fld dword ptr [eax+0C]         // Original code
 fdiv dword ptr [esp+50]        // Original code
 jmp _BackMCr2                  // Back to main code

//========================================= 15
//  During battle (Titan)
_MonXP:
 cmp dword ptr [iEnableMX],0
 je _ExitMX                     // Jump if feature is disabled

 mov eax,[ebx+2c]               // Get ptr to owner
 and byte ptr [eax+0f],01       // Is it a player's unit?...
 jz _ExitMX                     // ...Jump if false

 fst dword ptr [ebx+34]
 fst qword ptr [esp+10]

_ExitMX:
 fcomp qword ptr [esp+10]       // Original code
 fnstsw ax                      // Original code
 jmp _BackMX                    // Back to main code

//========================================= 15
//  During battle (other Ships)
_MonXP2:
 cmp dword ptr [iEnableMX],0
 je _ExitMX2                    // Jump if feature is disabled

 mov eax,[ebx+04]               // Get ptr to owner
 and byte ptr [eax+0f],01       // Is it a player's unit?...
 jz _ExitMX2                    // ...Jump if false

 fst dword ptr [ebx+0c]
 fst qword ptr [esp+10]

_ExitMX2:
 fcomp qword ptr [esp+10]       // Original code
 fnstsw ax                      // Original code
 jmp _BackMX2                   // Back to main code

//========================================= 15
//  Upgrade start at 90% (Starbase)
_MonSBUpgrade:
 cmp dword ptr [iEnableSU],0
 je _ExitSUp                    // Jump if feature is disabled

 mov eax,[esi+0c]               // Get ptr to Starbase
 and byte ptr [eax+0f],01       // Is it a player's unit?...
 jz _ExitSUp                    // ...Jump if false

 mov eax,(float)0.9
 cmp eax,[esp+14]
 jle _ExitSUp

 mov [esp+14],eax

_ExitSUp:
 fld dword ptr [esp+14]         // Original code
 fst dword ptr [esi+30]         // Original code
 jmp _BackSUp                   // Back to main code

//=========================================
 db '===============================>'
 db 'CE6.3 Script by Recifense 110713'
//=========================================
// Variables
iEnableGM:
 dd 0
iEnableMR:
 dd 0
iEnableQR:
 dd 0
iEnableMA:
 dd 0
iEnableQK:
 dd 0
iEnableMSp:
 dd 0
iEnableQP:
 dd 0
iEnableQC:
 dd 0
iEnableQU:
 dd 0
iEnableMX:
 dd 0
iEnableSU:
 dd 0
pSupply:
 dd MyCode
pConst:
 dd MyCode

//=========================================
// Hacking Points
MORE:
 jmp _MonResources
_BackMR:

MKUN:
 jmp _MarkUnits
 nop
 nop
_BackMU:

GDMD:
 jmp _GodMode
 nop
_BackGM:

MOSD:
 jmp _MonShield
 nop
_BackMS:

MOAM:
 jmp _MonAM
 nop
 nop
_BackMA:

PTPP:
 jmp _PlanetPop
 nop
 nop
_BackPP:

QKRH:
 jmp _QuickResearch
 nop
 nop
_BackQR:

GMDP:
 jmp _GodModeP
 nop
_BackGMP:

MOSY:
 jmp _MonSupply
 nop
_BackMSp:

MOPN:
 jmp _MonProduction
 nop
_BackMPr:

MOCN:
 jmp _MonConstruction
 nop
 nop
_BackMCr:

MOUP:
 jmp _MonUpgrade
 nop
 nop
_BackMUp:

MCN2:
 jmp _MonConstruction2
 nop
 nop
_BackMCr2:

MOXP:
 jmp _MonXP
 nop
_BackMX:

MXP2:
 jmp _MonXP2
 nop
_BackMX2:

MSBU:
 jmp _MonSBUpgrade
 nop
 nop
_BackSUp:

//=========================================
// Script for Restoring Original Codes
[DISABLE]
MORE:
// fadd st(0),st(1)
// fstp dword ptr [ecx+20]
 db d8 c1 d9 59 20

MKUN:
// mov eax,[ecx+08]
// mov ecx,[esp+04]
 db 8b 41 08 8b 4c 24 04

GDMD:
// fstp dword ptr [ebx+0C]
// fstp dword ptr [esp]
 db d9 5b 0c d9 1c 24

MOSD:
// fstp dword ptr [ebx+10]
// fstp dword ptr [esp]
 db d9 5b 10 d9 1c 24

MOAM:
// fld dword ptr [ecx+08]
// fsub dword ptr [esp+04]
 db d9 41 08 d8 64 24 04

PTPP:
// fld dword ptr [ecx+10]
// fsub dword ptr [esp+04]
 db d9 41 10 d8 64 24 04

QKRH:
// fld dword ptr [esp+14]
// fst dword ptr [ebp+2C]
 db d9 44 24 14 d9 55 2c

GMDP:
// fstp dword ptr [ebp+0000008C]
 db d9 9d 8c 00 00 00

MOSY:
// fld dword ptr [ebx+04]
// fstp dword ptr [esi+04]
 db d9 43 04 d9 5e 04

MOPN:
// fstp dword ptr [esi+00000200]
 db d9 9e 00 02 00 00

MOCN:
// fld dword ptr [esp+1C]
// fst dword ptr [edi+1C]
 db d9 44 24 1c d9 57 1c

MOUP:
// fld dword ptr [esp+14]
// fst dword ptr [esi+2C]
 db d9 44 24 14 d9 56 2c

MCN2:
// fld dword ptr [eax+0C]
// fdiv dword ptr [esp+50]
 db d9 40 0c d8 74 24 50

MOXP:
// fcomp qword ptr [esp+10]
// fnstsw ax
 db dc 5c 24 10 df e0

MXP2:
// fcomp qword ptr [esp+10]
// fnstsw ax
 db dc 5c 24 10 df e0

MSBU:
// fld dword ptr [esp+14]
// fst dword ptr [esi+30]
 db d9 44 24 14 d9 56 30

//=========================================
// Unregistering Symbols
unregistersymbol(MyCode)
unregistersymbol(iEnableGM)
unregistersymbol(iEnableMR)
unregistersymbol(iEnableQR)
unregistersymbol(iEnableMA)
unregistersymbol(iEnableQK)
unregistersymbol(iEnableMSp)
unregistersymbol(iEnableQP)
unregistersymbol(iEnableQC)
unregistersymbol(iEnableQU)
unregistersymbol(iEnableMX)
unregistersymbol(iEnableSU)

//=========================================
dealloc(MyCode)
//============= Scripts End ===============

// ****************************************
// NOTES
// ****************************************
{
1.52.4792:
define(MORE,"Sins of a Solar Empire Rebellion.exe"+00199323) //===
define(MKUN,"Sins of a Solar Empire Rebellion.exe"+001228de) //==+
define(GDMD,"Sins of a Solar Empire Rebellion.exe"+000ffe9b) //===
define(MOSD,"Sins of a Solar Empire Rebellion.exe"+000ffe28) //===
define(MOAM,"Sins of a Solar Empire Rebellion.exe"+000e0230) //===
define(PTPP,"Sins of a Solar Empire Rebellion.exe"+00144fa0) //===
define(QKRH,"Sins of a Solar Empire Rebellion.exe"+00125901) //===
define(GMDP,"Sins of a Solar Empire Rebellion.exe"+0011b8e1) //===
define(MOSY,"Sins of a Solar Empire Rebellion.exe"+0005da66) //===
define(MOPN,"Sins of a Solar Empire Rebellion.exe"+0012cccd) //*==
define(MOCN,"Sins of a Solar Empire Rebellion.exe"+000e4dbb) //===
define(MOUP,"Sins of a Solar Empire Rebellion.exe"+0014ee7b) //===
define(MCN2,"Sins of a Solar Empire Rebellion.exe"+00234d2e) //===
define(MOXP,"Sins of a Solar Empire Rebellion.exe"+0013a6be) //===
define(MXP2,"Sins of a Solar Empire Rebellion.exe"+000f842e) //===
define(MSBU,"Sins of a Solar Empire Rebellion.exe"+001376ab) //===

v1.51.4787:
define(MORE,LUDO+00199263) //==
define(MKUN,LUDO+001228de) //==
define(GDMD,LUDO+000ffecb) //==
define(MOSD,LUDO+000ffe58) //==
define(MOAM,LUDO+000e0200) //==
define(PTPP,LUDO+00144fb0) //==
define(QKRH,LUDO+001258f1) //==
define(GMDP,LUDO+0011b8f1) //==
define(MOSY,LUDO+0005db66) //==
define(MOPN,LUDO+0012cd1d) //*=
define(MOCN,LUDO+000e4dcb) //==
define(MOUP,LUDO+0014ee6b) //==
define(MCN2,LUDO+00234bde) //==
define(MOXP,LUDO+0013a6fe) //==
define(MXP2,LUDO+000f845e) //==
define(MSBU,LUDO+001376cb) //==

v1.5.4755
define(MORE,LUDO+001983e3) //=
define(MKUN,LUDO+001222ce) //=
define(GDMD,LUDO+000ff89b) //=
define(MOSD,LUDO+000ff828) //=
define(MOAM,LUDO+000dfc40) //=
define(PTPP,LUDO+001449a0) //=
define(QKRH,LUDO+00125301) //=
define(GMDP,LUDO+0011b2d1) //=
define(MOSY,LUDO+0005d9e6) //=
define(MOPN,LUDO+0012c6ed) //*
define(MOCN,LUDO+000e478b) //=
define(MOUP,LUDO+0014e88b) //=
define(MCN2,LUDO+00233b7e) //=
define(MOXP,LUDO+0013a09e) //=
define(MXP2,LUDO+000f7e3e) //=
define(MSBU,LUDO+0013709b) //=
}

The Engie Union

Turtle Mining Program (ComputerCraft)

This is the source code for a Turtle in ComputerCraft written in Lua. The Turtle will send messages to a receiving computer that has an attached modem. I have modified the code and written code for the receiving computer.

p.s.
I have changed my nickname to ~Black on a friend’s server.

Turtle

-- First set up computer #1.
-- Create a program. Type in the following
-- for i = 1,100 do
-- rednet.open("right")
-- id, message = rednet.receive()
-- print ("Computer ".. id .. " has sent us a message")
-- print ("The message is")
-- print (message)
-- end

isWireless = true
consoleID = 11
depth = 0

function fuel()
	if turtle.getFuelLevel() <= depth + 10 then
		turtle.select(16)
		turtle.refuel(1)
		if isWireless then rednet.send(consoleID,"Refueled. Fuel level: "..turtle.getFuelLevel()) end
	end
end

function isValuable() 
	if turtle.detect() == false then 
		return false 
	end 
	for i=1,3 do 
		turtle.select(i) 
		if turtle.compare() then 
			return false 
		end 
	end 
	return true 
end

function checkWalls(dp)
	for j=1,4 do
		if isValuable() then
			if isWireless then rednet.send(consoleID,"Found ore at depth "..dp) end
			turtle.dig()
		end
		turtle.turnRight()
	end
end

------ ( Program Start ) ------

if isWireless == true then
   rednet.open("right")
end

term.clear()
term.setCursorPos(1,1)
print("The Trololol Miner")
print("-------------------------")

term.write("Start Mining? (y/n): ")

while read() == "y" do

	depth = 0
	print("Commencing mining.")
	if isWireless then rednet.send(consoleID,"Commencing mining.") end

	fuel()
	turtle.digDown()
	for st=1,2 do
		turtle.down()
		depth = depth + 1
		turtle.digDown()
	end

	-- plug entrance hole
	turtle.select(15)
	turtle.placeUp()

	while not turtle.detectDown() do
		fuel()
		turtle.down()
		depth = depth + 1
		if isWireless and depth%10==0 then
			rednet.send(consoleID,"At depth "..depth)
		end
		checkWalls(depth)
		turtle.digDown()
	end

	if isWireless then rednet.send(consoleID,"Moving to next shaft location...") end

	for mv=1,6 do
		fuel()
		turtle.up()
		depth = depth - 1
	end

	-- move forward 2 blocks
	for z=1,2 do
		fuel()
		while not turtle.forward() do
			turtle.dig()
			sleep(.8)
		end
	end

	-- turn right and move one block
	turtle.turnRight()
	fuel()
	while not turtle.forward() do
		turtle.dig()
		sleep(.8)
	end
	turtle.turnLeft()

	-- go down to bedrock
	turtle.digDown()
	while not turtle.detectDown() do
		fuel()
		turtle.down()
		depth = depth + 1
		turtle.digDown()
	end

	if isWireless then rednet.send(consoleID,"Returning to surface!") end

	for k=depth,3,-1 do
		checkWalls(k)
		turtle.digUp()
		fuel()
		while not turtle.up() do
			turtle.digUp()
			sleep(.5)
		end
		if isWireless and k%10 == 0 then
			rednet.send(consoleID,"At depth "..k)
		end
	end

	fuel()
	turtle.digUp()
	turtle.up()
	turtle.digUp()
	turtle.up()

	-- fill exit hole
	turtle.select(15)
	turtle.placeDown()

	turtle.forward()
	turtle.forward()
	turtle.turnRight()
	turtle.forward()
	turtle.turnLeft()

	if isWireless then rednet.send(consoleID,"At the surface!") end
	term.write("Go on mining run? (y/n): ")
end

print("Cancelled mining.")

if isWireless then rednet.close("right") end

Computer

-- First set up computer #1.
-- Create a program. Type in the following
 for i = 1,200 do
 rednet.open("right")
 id, message = rednet.receive()
 print ("Computer ".. id .. " has sent us a message:")
print (message)
print("-------------------------")
end

Juggling Sequence Permutation Test

This is a basic program that uses the permutation test to display all possible juggling sequences of a certain period and with a certain number of balls. The program can be easily modified to ask the user for the period and number of balls required. Right now, it is hard coded in. The number of balls is 2 and the period is 4. Thus the sum of all of the beats in the sequence must be 8 and the average 2.

I worked on this in class, so please excuse the messy coding. I did not think that I would be showing the source code to anyone else.

 

//Justin Yang
//9-17-2013
//2:02 PM

#include
#include

using namespace std;

int main()
{
int x = 0;
int y = 0;
int z = 0;
int limit_one = 0;
int limit_two = 0;
int limit_three = 0;
int limit_four = 0;
int a_one[2];
int a_two[2];
int a_three[2];
int a_four[2];

int a, b, c, d, n;

cout << "Please input a, b, c, d: "; cin >> a >> b >> c >> d;

cout << "a: " << endl;
n = 0;
int lol = 0;
for (int i = 0; i < 10; i++)
{
if (((n + 0) % 4) == a){
cout << "\t" << n << endl;
a_one[lol] = n;
lol++;

limit_one++;
}
n++;
}

cout << "b: " << endl;
n = 0;
lol = 0;
for (int i = 0; i < 10; i++)
{
if ((n + 1) % 4 == b){
cout << "\t" << n << endl;
a_two[lol] = n;
lol++;
limit_two++;
}
n++;
}
cout << "c: " << endl;
n = 0;
lol = 0;
for (int i = 0; i < 10; i++)
{
if ((n + 2) % 4 == c){
cout << "\t" << n << endl;
a_three[lol] = n;
lol++;
limit_three++;
}
n++;
}
cout << "d: " << endl;
n = 0;
lol = 0;
for (int i = 0; i < 10; i++)
{
if ((n + 3) % 4 == d){
cout << "\t" << n << endl;
a_four[lol] = n;
lol++;
limit_four++;
}
n++;
}

/** for (int i = 0; i < limit_one; i++) cin >> a_one[i];

for (int i = 0; i < limit_two; i++) cin >> a_two[i];

for (int i = 0; i < limit_three; i++) cin >> a_three[i];

for (int i = 0; i < limit_four; i++) cin >> a_four[i];
**/

for (x; x < 3; x++)
{
// int n = a_one[x];
// cout << "A_One: " << a_one[x] << endl;
for (int y = 0; y < 3; y++)
{
// n += a_two[y];
// cout << "A_Two: " << a_two[y] << endl;
for (int z = 0; z < 3; z++)
{
// n += a_three[z];
// cout << "A_Three: " << a_three[z] << endl;
for (int i = 0; i < 3; i++)
{

// cout << "A_Four: " << a_four[i] << endl;
if ((a_one[x] + a_two[y] + a_three[z] + a_four[i]) == 8)
cout << a_one[x] << " " << a_two[y] << " " << a_three[z] << " " << a_four[i] << endl;
}
}
}
}

cout << "This is before System Pause." << endl;
system("PAUSE");
return 0;

}

Probability Poisson Distribution

// Probability.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include 
#include 
using namespace std;

double Success(double, int);

int main()
{
	double q;
	int z;

	std::cout << "Please enter a probability value: "; 	std::cin >> q;
	std::cout << "Please enter a Z-value: "; 	std::cin >> z;
	cout << Success(q, z);

	system("PAUSE");
	return 0;

}

double Success(double q, int z)
{

	double p = 1.0 - q;
	double lambda = z * (q / p);
	double sum = 1.0;
	int i, k;

	for (k = 0; k <= z; k++)
	{
		double poisson = exp(-lambda); // e^lambda
		for (i = 1; i <= k; i++)
			poisson * lambda / i;   // lambda^1,2,3,4 divided by K!(1,2,3,4...)
		sum -= poisson * (1 - pow(q / p, z - k));
	}
	return sum;
}

C++ Port 4.8.1.
Demonstration purposes.