xkkmEl Posted May 25 Share Posted May 25 As everyone on this board should know by now, I am omniscient and omnipotent. From that state of superiority I can clearly see that neither one of you actually has studied the higher order mathematics of random numbers, nor do either one know how to code efficiently. This is how a shuffle is done: function randomizeIntArray( int[] array) int i = array.length while i ; PeterMartyr, the reverse counting loop is often slightly faster because it compares with zero (a constant) instead of a variable i -= 1 int rnd = Utility.randomInt( 0, i) ; Dilbyll, the swap method produces a truely uniform distribution ; Your method produces distributions that is not exactly uniform, and would be rejected by advanced statistical tests int tmp = array[i] array[i] = array[rnd] array[rnd] = tmp endwhile endfunction Don't bother arguing, I know I'm right and I will take any further comment as an invitation to resolve it in a duel. My preferred weapon, just so you know, is the nerf battleaxe. So be advised. Link to comment Share on other sites More sharing options...
dylbill Posted May 25 Share Posted May 25 Lol sure bruh. You got me, I sure don't know how to 'code efficiently', meanwhile you're still missing the point. I don't care about the card functions at all. Again, I just used that as an example to show how to add new types to papyrus. The original argument was "Is placeAtMe a constructor or not". It is. Btw, my preferred weapon is a pool noodle Link to comment Share on other sites More sharing options...
PeterMartyr Posted May 25 Share Posted May 25 OK OK OK OK I will do it with cloning... cos I am enjoying this, but am confident my code will become longer for little to no Gain do not call it Constructor, crap now I need a Form Array instead String array and need to add clonable object, with a script, containing variables and Extra Code, what for? And lets make a deal, if you stop being condescending which you started I do the same, cos your code got problems toooooo, and the fact that I posted Unfinished Untested NOT working code, just show where I was I at, should scream I am NOT that full of myself EDIT Once this is cloned, and filled, it is set in stone, forcing me to make 52 Cards.... ScriptName Card Extends ObjectReference String suit String name String value Function setSuit(string _suit) If !suit suit=_suit EndIf EndFunction Function setName(string _name) If !name name=_name EndIf EndFunction Function setValue(string _value) If !value value=_value EndIf EndFunction Link to comment Share on other sites More sharing options...
xkkmEl Posted May 25 Share Posted May 25 In truth, I think you both have valid points. Papyrus is a limited programming language by modern standards, and placeAtMe is a form of constructor. I also think you are both taking a narrow view of what a constructor is... there is not really a formal definition of the term, which like ALL the terms we use in computer science are just words from the common dictionary that we repurpose in different contexts to represent different technical ideas, not all of them compatible with each other. The wikipedia page also, imho, takes a somewhat narrow view (it does not fully encompass Dylbill's view, and I think it should): Quote A constructor resembles an instance method, but it differs from a method in that it has no explicit return type, it is not implicitly inherited and it usually has different rules for scope modifiers. Constructors often have the same name as the declaring class. They have the task of initializing the object's data members and of establishing the invariant of the class, failing if the invariant is invalid. A properly written constructor leaves the resulting object in a valid state. Immutable objects must be initialized in a constructor. PlaceAtMe definitely fails the "resembles an instance method" criteria, as well as the "establishing the invariant of the class". It also fails to support the RAII philosophy that is so dear to C++ programmers. BTW, Javascript constructors also fail wrt the Wikipedia definition. Taking the wider view on constructors, as Dylbill does, is widely accepted in the computer science community (though arguing about vocabulary is also all too common as well ). However, Papyrus is NOT an object oriented language, and so the expectation that it should support constructors in the Wikipedia sense is unreasonable. Despite its limitations, I find it is a fully functional language to work with, and it is possible to recreate the equivalent of quasi-true constructors; just wrap your placeAtMe in a global function that handles the initialization and establishment of invariants. You'll only miss having it appear as an quasi-instance method and hiding the return type. On the other hand, the concurrent execution model in Papyrus is broken. Working around the locking model is a major pain. The C++ interface through SKSE provides a way to get around that, which for most programmers will be more comfortable than papyrus-only techniques. Link to comment Share on other sites More sharing options...
PeterMartyr Posted May 25 Share Posted May 25 Well it compiled, now I need to open the KIT, but I am done for the day.. just to show you, I am cloning the object above with that script attach and still using the Quest as a Controller for the Deck, I still stand by it is a lot effort for little gain, and i do know if my approach will work ?? ¯\_(ツ)_/¯, LOL a Clone is still an Object, I never denied that OK and even implied it... Instead of me experimenting with trial and error, I just ask what a good object to use? I hope you notice my approach did not change... and good coding means no extra bullshite, it always Keep It Simple Stupid.. and the code is still shorter than yours, tight it up mate, am once you tighten up cos there so many ways skin a cat it will turn into mine)) with backward loops ScriptName Deck2 Extends Quest String Property HEARTS = "Hearts" AutoReadOnly String Property SPADES = "Spades" AutoReadOnly String Property CLUBS = "Clubs" AutoReadOnly String Property DIAMONDS = "Diamonds" AutoReadOnly String Property JACK = "Jack" AutoReadOnly String Property QUEEN = "Queen" AutoReadOnly String Property KING = "King" AutoReadOnly String Property ACE = "Ace" AutoReadOnly String Property OF = " of " AutoReadOnly Form Property objCard Auto Actor Property PlayerRef Auto Form[] theDeck Int numberOfCards = 0 Function NewDeck() String[] rank rank = new String[13] String[] pictures = new String[4] pictures[0] = JACK pictures[1] = QUEEN pictures[2] = KING pictures[3] = ACE int i = 2 While i < 15 if i < 11 rank[i - 2] = i + OF Else rank[i - 2] = pictures[i % 11] + OF EndIf i+=1 EndWhile theDeck = new Form[52] String[] suit = new String[4] suit[0] = HEARTS suit[1] = SPADES suit[2] = CLUBS suit[3] = DIAMONDS int j = 0 While j < suit.Length i = 0 While i < rank.Length ObjectReference clone = PlayerRef.PlaceAtMe(objCard, 1, true, true) (clone as Card).setSuit(suit[i]) (clone as Card).setName(rank[i]) (clone as Card).setValue(i) theDeck[i] = clone numberOfCards+=1 EndWhile i+=1 EndWhile EndFunction Function Shuffle() int i = 0 Int random While i < theDeck.Length random = Utility.RandomInt(0, theDeck.Length) form temp = theDeck[i] theDeck[i] = theDeck[random] theDeck[random] = temp i+=1 EndWhile EndFunction String Function Deal() If !numberOfCards==0 numberOfCards -= 1 Return theDeck[numberOfCards] Else debug.MessageBox("no more cards") Return "" EndIf EndFunction Link to comment Share on other sites More sharing options...
PeterMartyr Posted May 25 Share Posted May 25 not only is above now using objects it is using polymorphism so I guess papyrus is an is an object orientated language like I have always stated it is, how else can we explain the polymorphism and casting? If it will work, dunno.. still not open the KIT, and losing interest BTW I starting to feel like I am the only person who wrote and instantiated a class and then cloned it avoid to avoid a memory leak, on the most basic level while .. being told my mine betters that I am wrong in every thing I do, the reason I knew PlaceAtMe is not a constructor is I am very good with object orientated languages as the above script should show you... EDIT this is kinda embarrassing and I did think I need it, but I added a toString() to fake class on the clone, changed the quest controller accordingly, for fake unit testing preparation, and still not open the KIT it looks like real fake class @dylbill becareful with you attitude on loops, or you may end up making 52 version of the same cards, cos you know it all, while wondering what going on, pfff I cannot help it spinning a loop backwards in skyrim, pat yourself on the back, execute that loop for 10 minutes continuously and you just save a nano second. Link to comment Share on other sites More sharing options...
PeterMartyr Posted May 25 Share Posted May 25 Spoiler i = 0 int h = 0 While i < suit.Length int j = 0 While j < rank.Length ObjectReference clone = PlayerRef.PlaceAtMe(objCard, 1, true, true) (clone as Card).setSuit(suit[i]) (clone as Card).setName(rank[j]) (clone as Card).setValue(j) MiscUtil.PrintConsole((clone as Card).toString()) theDeck[h] = clone numberOfCards+=1 j+=1 h+=1 EndWhile Utility.Wait(0.5) i+=1 EndWhile Spoiler Utility.SetINIBool("bEnableTrace:Papyrus", True) Debug.OpenUserLog(scriptName_prop) String objectName = StringUtil.Substring( StringUtil.Split(Self, StringUtil.AsChar(32))[1], 1) Debug.TraceUser(scriptName_prop, "==============================================================================") Debug.TraceUser(scriptName_prop, " ===== "+objectName+" As "+scriptName_prop+" =====") Debug.TraceUser(scriptName_prop, "==============================================================================") Debug.TraceUser(scriptName_prop, "Self: "+ Self) Debug.TraceUser(scriptName_prop, "Object Container: "+objectName) Debug.TraceUser(scriptName_prop, "Script Name: "+scriptName_prop) Debug.TraceUser(scriptName_prop, "Array Length: "+theDeck.Length) Debug.TraceUser(scriptName_prop, "Number of Cards: "+numberOfCards) Int i = 0 While i < theDeck.Length Debug.TraceUser(scriptName_prop, " Index: ["+i+"], Element: "+theDeck[i]) Debug.TraceUser(scriptName_prop,((theDeck[i]as ObjectReference) as Card).toString()) i += 1 EndWhile Debug.TraceUser(scriptName_prop, "==============================================================================") Debug.TraceUser(scriptName_prop, "==============================================================================") Debug.CloseUserLog(scriptName_prop) Utility.SetINIBool("bEnableTrace:Papyrus", False) Debug.Notification("Custom Trace Logging Done") Spoiler [05/26/2024 - 09:14:37AM] Deck log opened (PC) [05/26/2024 - 09:14:37AM] ============================================================================== [05/26/2024 - 09:14:37AM] ===== UnitTestMCMQuest As Deck ===== [05/26/2024 - 09:14:37AM] ============================================================================== [05/26/2024 - 09:14:37AM] Self: [Deck <UnitTestMCMQuest (0A000D63)>] [05/26/2024 - 09:14:37AM] Object Container: UnitTestMCMQuest [05/26/2024 - 09:14:37AM] Script Name: Deck [05/26/2024 - 09:14:37AM] Array Length: 52 [05/26/2024 - 09:14:37AM] Number of Cards: 52 [05/26/2024 - 09:14:37AM] Index: [0], Element: [Card < (FF000D60)>] [05/26/2024 - 09:14:37AM] 2 of of HEARTS [05/26/2024 - 09:14:37AM] Index: [1], Element: [Card < (FF000D90)>] [05/26/2024 - 09:14:37AM] 3 of of HEARTS [05/26/2024 - 09:14:37AM] Index: [2], Element: [Card < (FF000D91)>] [05/26/2024 - 09:14:37AM] 4 of of HEARTS [05/26/2024 - 09:14:37AM] Index: [3], Element: [Card < (FF000D92)>] [05/26/2024 - 09:14:37AM] 5 of of HEARTS [05/26/2024 - 09:14:37AM] Index: [4], Element: [Card < (FF000D93)>] [05/26/2024 - 09:14:37AM] 6 of of HEARTS [05/26/2024 - 09:14:37AM] Index: [5], Element: [Card < (FF000D94)>] [05/26/2024 - 09:14:37AM] 7 of of HEARTS [05/26/2024 - 09:14:37AM] Index: [6], Element: [Card < (FF000D95)>] [05/26/2024 - 09:14:37AM] 8 of of HEARTS [05/26/2024 - 09:14:37AM] Index: [7], Element: [Card < (FF000D96)>] [05/26/2024 - 09:14:37AM] 9 of of HEARTS [05/26/2024 - 09:14:37AM] Index: [8], Element: [Card < (FF000D97)>] [05/26/2024 - 09:14:37AM] 10 of of HEARTS [05/26/2024 - 09:14:37AM] Index: [9], Element: [Card < (FF000D98)>] [05/26/2024 - 09:14:37AM] JACK of of HEARTS [05/26/2024 - 09:14:37AM] Index: [10], Element: [Card < (FF000D99)>] [05/26/2024 - 09:14:37AM] QUEEN of of HEARTS [05/26/2024 - 09:14:37AM] Index: [11], Element: [Card < (FF000D9A)>] [05/26/2024 - 09:14:37AM] KING of of HEARTS [05/26/2024 - 09:14:37AM] Index: [12], Element: [Card < (FF000D9B)>] [05/26/2024 - 09:14:37AM] ACE of of HEARTS [05/26/2024 - 09:14:37AM] Index: [13], Element: [Card < (FF000D9C)>] [05/26/2024 - 09:14:37AM] 2 of of SPADES [05/26/2024 - 09:14:37AM] Index: [14], Element: [Card < (FF000D9D)>] [05/26/2024 - 09:14:37AM] 3 of of SPADES [05/26/2024 - 09:14:37AM] Index: [15], Element: [Card < (FF000D9E)>] [05/26/2024 - 09:14:37AM] 4 of of SPADES [05/26/2024 - 09:14:37AM] Index: [16], Element: [Card < (FF000DA2)>] [05/26/2024 - 09:14:37AM] 5 of of SPADES [05/26/2024 - 09:14:37AM] Index: [17], Element: [Card < (FF000DA3)>] [05/26/2024 - 09:14:37AM] 6 of of SPADES [05/26/2024 - 09:14:37AM] Index: [18], Element: [Card < (FF000DA4)>] [05/26/2024 - 09:14:37AM] 7 of of SPADES [05/26/2024 - 09:14:37AM] Index: [19], Element: [Card < (FF000DA5)>] [05/26/2024 - 09:14:37AM] 8 of of SPADES [05/26/2024 - 09:14:37AM] Index: [20], Element: [Card < (FF000DAA)>] [05/26/2024 - 09:14:37AM] 9 of of SPADES [05/26/2024 - 09:14:37AM] Index: [21], Element: [Card < (FF000DAB)>] [05/26/2024 - 09:14:37AM] 10 of of SPADES [05/26/2024 - 09:14:37AM] Index: [22], Element: [Card < (FF000DAF)>] [05/26/2024 - 09:14:37AM] JACK of of SPADES [05/26/2024 - 09:14:37AM] Index: [23], Element: [Card < (FF000DB0)>] [05/26/2024 - 09:14:37AM] QUEEN of of SPADES [05/26/2024 - 09:14:37AM] Index: [24], Element: [Card < (FF000DB2)>] [05/26/2024 - 09:14:37AM] KING of of SPADES [05/26/2024 - 09:14:37AM] Index: [25], Element: [Card < (FF000DB3)>] [05/26/2024 - 09:14:37AM] ACE of of SPADES [05/26/2024 - 09:14:37AM] Index: [26], Element: [Card < (FF000DB4)>] [05/26/2024 - 09:14:37AM] 2 of of CLUBS [05/26/2024 - 09:14:37AM] Index: [27], Element: [Card < (FF000DB6)>] [05/26/2024 - 09:14:37AM] 3 of of CLUBS [05/26/2024 - 09:14:37AM] Index: [28], Element: [Card < (FF000DB8)>] [05/26/2024 - 09:14:37AM] 4 of of CLUBS [05/26/2024 - 09:14:37AM] Index: [29], Element: [Card < (FF000DB9)>] [05/26/2024 - 09:14:37AM] 5 of of CLUBS [05/26/2024 - 09:14:37AM] Index: [30], Element: [Card < (FF000DBA)>] [05/26/2024 - 09:14:37AM] 6 of of CLUBS [05/26/2024 - 09:14:37AM] Index: [31], Element: [Card < (FF000DBD)>] [05/26/2024 - 09:14:37AM] 7 of of CLUBS [05/26/2024 - 09:14:37AM] Index: [32], Element: [Card < (FF000DBE)>] [05/26/2024 - 09:14:37AM] 8 of of CLUBS [05/26/2024 - 09:14:37AM] Index: [33], Element: [Card < (FF000DBF)>] [05/26/2024 - 09:14:37AM] 9 of of CLUBS [05/26/2024 - 09:14:37AM] Index: [34], Element: [Card < (FF000DC0)>] [05/26/2024 - 09:14:37AM] 10 of of CLUBS [05/26/2024 - 09:14:37AM] Index: [35], Element: [Card < (FF000DC5)>] [05/26/2024 - 09:14:37AM] JACK of of CLUBS [05/26/2024 - 09:14:37AM] Index: [36], Element: [Card < (FF000DC6)>] [05/26/2024 - 09:14:37AM] QUEEN of of CLUBS [05/26/2024 - 09:14:37AM] Index: [37], Element: [Card < (FF000DC8)>] [05/26/2024 - 09:14:37AM] KING of of CLUBS [05/26/2024 - 09:14:37AM] Index: [38], Element: [Card < (FF000DC9)>] [05/26/2024 - 09:14:37AM] ACE of of CLUBS [05/26/2024 - 09:14:37AM] Index: [39], Element: [Card < (FF000DD0)>] [05/26/2024 - 09:14:37AM] 2 of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [40], Element: [Card < (FF000DD1)>] [05/26/2024 - 09:14:37AM] 3 of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [41], Element: [Card < (FF000DD2)>] [05/26/2024 - 09:14:37AM] 4 of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [42], Element: [Card < (FF000DD7)>] [05/26/2024 - 09:14:37AM] 5 of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [43], Element: [Card < (FF000DD8)>] [05/26/2024 - 09:14:37AM] 6 of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [44], Element: [Card < (FF000DD9)>] [05/26/2024 - 09:14:37AM] 7 of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [45], Element: [Card < (FF000DDA)>] [05/26/2024 - 09:14:37AM] 8 of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [46], Element: [Card < (FF000DDB)>] [05/26/2024 - 09:14:37AM] 9 of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [47], Element: [Card < (FF000DDC)>] [05/26/2024 - 09:14:37AM] 10 of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [48], Element: [Card < (FF000DDD)>] [05/26/2024 - 09:14:37AM] JACK of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [49], Element: [Card < (FF000DDE)>] [05/26/2024 - 09:14:37AM] QUEEN of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [50], Element: [Card < (FF000DDF)>] [05/26/2024 - 09:14:37AM] KING of of DIAMONDS [05/26/2024 - 09:14:37AM] Index: [51], Element: [Card < (FF000DE0)>] [05/26/2024 - 09:14:37AM] ACE of of DIAMONDS [05/26/2024 - 09:14:37AM] ============================================================================== [05/26/2024 - 09:14:37AM] ============================================================================== [05/26/2024 - 09:14:37AM] Log closed How is someone who is better than me struggling with this? Seriously this so easy...... Does it annoy you, I clone 52 Object filled their private variables just the Fake Class it is ......and did 70 line of code were you are failing with 160 line of code. BTW look up other code, that is a form array containing Fake Card Object... BTW2 still not a constructor, it a friggen Cloner and NOOOOOOOOOO they are not the same, and I got legal document saying I am Software Engineer too... that not my opinion, it is a fact, that a function with a designated return is not a constructor EDIT myArray = document.getElementsByClassName('data') for (var i = myArray.length - 1; i >= 0; i--) { myArray[i].style.color = '#b3b3b3'; } that what you call a for loop, if, IF you can read it you will see I am spinning it backwards, nothing you said that right was new to me, shock horror Eh? and most of what you said I disagree with.... and I say this too, to teach yourself about concept of object orientated coding with Papyrus, in Skyrim is doing you more harm than good.. Plus simple and concise is good, making it complicated just mean you not a grasp on what your doing.. I did it 60 lines of code you complain it was a string, 10 extra lines was all I changed, making it 70 lines, 10 lines was object part... that is it .... 10 lines or less.... what are doing you doing with complicated 160 lines of code? where the reasoning behind that? to achieve what you want is just (checking) OGM 5 lines of code...... OMG I did not think it would be small https://www.freecodecamp.org/news/keep-it-simple-stupid-how-to-use-the-kiss-principle-in-design/ if you do not believe me, maybe you will believe a free site... Link to comment Share on other sites More sharing options...
Recommended Posts