1/3
3 Years of Service
the man in the situation, I'm sure he played in jon wick c:great, slowly building my quote wall, cleaning some thrash here and there
You must be registered to see attachments
the man in the situation, I'm sure he played in jon wick c:great, slowly building my quote wall, cleaning some thrash here and there
You must be registered to see attachments
I usedI think some of the things to consider here, is that AI should be used to help, rather than to build completely (at this stage at least) and, like you say - it's not wrong necessarily, but just not ideal. In my experience, AI won't ever give you ideal since that's where some of our humanity and problem solving comes in. Also, remember it's an iterative process, so give it your feedback to improve it. Just like you would if you hired an outside developer/artist that doesn't do what you want.
That said, can I ask what AI you were using to Generate? Because that changes the output MASSIVELY. Let me share with you what I've just done in GPT based on your code. For reference, both of the below are ChatGPT 4o and both are brand new unique conversatons.
Can you improve this Javascript based on the users request?
For instance, I had it generate a 3x3 gameboard with card objects created based on a prototype object that is supposed to have 4 random values from 1-9 and functions to access its neighbors dynamically based on the current position. //
Prototype object for the card const cardPrototype = { values: Array.from({ length: 4 }, () => Math.floor(Math.random() * 9) + 1), top: function() { return gameboard[this.row - 1][this.col]; }, bottom: function() { return gameboard[this.row + 1][this.col]; }, left: function() { return gameboard[this.row][this.col - 1]; }, right: function() { return gameboard[this.row][this.col + 1]; } }; // Create a 3x3 gameboard with card objects const gameboard = Array.from({ length: 3 }, () => Array.from({ length: 3 }, () => Object.create(cardPrototype)) ); // Assign row and column properties to each card gameboard.forEach((row, i) => { row.forEach((card, j) => { card.row = i; card.col = j; }); });Sure, I'll make a few improvements to the JavaScript code to enhance clarity, functionality, and ensure it adheres to best practices.
Here is the improved code:
- The values array should be generated dynamically for each card object.
- The neighbor functions should handle boundary conditions gracefully.
- Use Object.assign to create card objects to ensure the values array is unique for each card.
JavaScript:// Prototype object for the card const cardPrototype = { init: function(row, col) { this.row = row; this.col = col; this.values = Array.from({ length: 4 }, () => Math.floor(Math.random() * 9) + 1); }, top: function() { return this.row > 0 ? gameboard[this.row - 1][this.col] : null; }, bottom: function() { return this.row < gameboard.length - 1 ? gameboard[this.row + 1][this.col] : null; }, left: function() { return this.col > 0 ? gameboard[this.row][this.col - 1] : null; }, right: function() { return this.col < gameboard[this.row].length - 1 ? gameboard[this.row][this.col + 1] : null; } }; // Create a 3x3 gameboard with card objects const gameboard = Array.from({ length: 3 }, (_, row) => Array.from({ length: 3 }, (_, col) => { const card = Object.create(cardPrototype); card.init(row, col); return card; }) ); // For demonstration: log the gameboard and one card's neighbors console.log(gameboard); console.log('Neighbors of card at (1,1):', gameboard[1][1].top(), gameboard[1][1].bottom(), gameboard[1][1].left(), gameboard[1][1].right());
Changes and Improvements:
This code should now correctly create a 3x3 gameboard with cards having unique values and correctly handle neighbor lookups.
- Dynamic values Array: The values array is now dynamically generated for each card during initialization.
- Boundary Handling: The neighbor functions (top, bottom, left, right) now check boundaries to avoid accessing undefined array elements.
- Initialization Method: Added an init method to the prototype for setting up row, col, and values properties.
- Object Creation: Used Object.create and card.init to ensure each card gets unique values.
A User is discussing trouble using AI Language Models to write code for a Java project. As I am unfamiliar with Java, can you take a look at his query below and perhaps improve his code to something more appropriate? It is interesting, though I've tried something similar on a javascript AI and immediately realized a whole lot of implementation problems. It works well as a piece limited, but in the greater whole, the AI chooses implementation versions that do not really work. For instance, I had it generate a 3x3 gameboard with card objects created based on a prototype object that is supposed to have 4 random values from 1-9 and functions to access its neighbors dynamically based on the current position. This is the result // Prototype object for the card const cardPrototype = { values: Array.from({ length: 4 }, () => Math.floor(Math.random() * 9) + 1), top: function() { return gameboard[this.row - 1][this.col]; }, bottom: function() { return gameboard[this.row + 1][this.col]; }, left: function() { return gameboard[this.row][this.col - 1]; }, right: function() { return gameboard[this.row][this.col + 1]; } }; // Create a 3x3 gameboard with card objects const gameboard = Array.from({ length: 3 }, () => Array.from({ length: 3 }, () => Object.create(cardPrototype)) ); // Assign row and column properties to each card gameboard.forEach((row, i) => { row.forEach((card, j) => { card.row = i; card.col = j; }); }); While this isn't wrong, that's not really dynamic. It works if you make sure that you tell the card it's new position every time you change on what tile it is, but it cannot dynamically detect the neighbors. A dynamic solution would be to use a function to access the gameboard, find the current row & column indexes and then use those to calculate the neighbors. This also only works on a fixed gameboard size with fixed dimensions, since the gameboard is automatically divided into rows and columns. This also fixes how the gameboard's tiles are accessible, because it predefines the size of the gameboard during creation. Instead, a different and more flexible solution would've been to have the gameboard creates as containing an array of x tiles, giving the gameboard a width & height and rather than using direct +/- operations on fixed tiles, using modulo to dynamically access the correct neighbors even if the size & width change. So it's a correct solution that might not work in the actual project, due to restrictions in what choices it has made for the implementation. I think it's a nifty thing for simple and straightforward operations, but I don't think it can, in the solution, correctly account of implentation-based restrictions in how it's going to have to interact in the greater whole. The particular choice made by the AI does provide the fastest solution (predefined values, even less math) but it's not necessarily giving the solution that would actually work with the project. I wonder if anyone managed to get it to work with something like PixiJS and create a simple visual game - because I wonder if the AI would detect the necessary restrictions in rendering hierarchy.It seems the user is trying to dynamically handle the position of cards on a gameboard in a JavaScript context, and they would like a more flexible solution that doesn't rely on fixed positions. Here's an improved version of the code that dynamically calculates the neighbours and can adapt to changes in the gameboard's size:
JavaScript:// Card constructor function function Card(row, col, gameboard) { this.row = row; this.col = col; this.gameboard = gameboard; this.values = Array.from({ length: 4 }, () => Math.floor(Math.random() * 9) + 1); } Card.prototype.getNeighbour = function (dRow, dCol) { const newRow = this.row + dRow; const newCol = this.col + dCol; if (newRow >= 0 && newRow < this.gameboard.length && newCol >= 0 && newCol < this.gameboard[0].length) { return this.gameboard[newRow][newCol]; } return null; }; Card.prototype.top = function () { return this.getNeighbour(-1, 0); }; Card.prototype.bottom = function () { return this.getNeighbour(1, 0); }; Card.prototype.left = function () { return this.getNeighbour(0, -1); }; Card.prototype.right = function () { return this.getNeighbour(0, 1); }; // Function to create a gameboard function createGameboard(rows, cols) { const gameboard = Array.from({ length: rows }, (_, row) => Array.from({ length: cols }, (_, col) => new Card(row, col, gameboard)) ); // Assign the gameboard reference after creation gameboard.forEach(row => row.forEach(card => card.gameboard = gameboard)); return gameboard; } // Create a 3x3 gameboard const gameboard = createGameboard(3, 3); // Example: Access neighbours of the card at (1, 1) const card = gameboard[1][1]; console.log('Top:', card.top()); console.log('Bottom:', card.bottom()); console.log('Left:', card.left()); console.log('Right:', card.right());
Explanation:
This approach allows the gameboard to dynamically calculate neighbours regardless of the board size and ensures that the card objects are aware of their own positions and the gameboard they belong to. This should address the user's concerns about flexibility and dynamic interaction in the project.
- Card Constructor: The Card function is used to create card objects with dynamic row and column properties. Each card also holds a reference to the gameboard it belongs to.
- getNeighbour Method: This method calculates the new row and column indices based on the current position and checks if the new indices are within bounds. If they are, it returns the neighbouring card; otherwise, it returns null.
- Direction Methods: The top, bottom, left, and right methods use getNeighbour to find the card in the corresponding direction.
- createGameboard Function: This function creates a gameboard of the specified size and populates it with cards. Each card is initially created without a reference to the gameboard, but after the gameboard is fully created, each card's gameboard reference is updated.
So, I'm not sure how much credit you give those responses? I'm not trying to "prove you wrong" or anything like that, just trying to say "have you tried this?" - you might look at this code and still call it bullshit, since I don't really know what I'm talking about when it comes to Java! I just thought it'd be interesting to get your perspective on it.
// Function to create a gameboard
function createGameboard(rows, cols) {
const gameboard = Array.from({ length: rows }, (_, row) =>
Array.from({ length: cols }, (_, col) => new Card(row, col, gameboard))
);
// Assign the gameboard reference after creation
gameboard.forEach(row => row.forEach(card => card.gameboard = gameboard));
return gameboard;
}
class Wall {
constructor() {
}
values() {
return [9,9,9,9]
}
}
class Card {
constructor(values) {
this._values = values;
}
values() {
return this._values;
}
getOwnPosition() {
const index = $GameBoard.tiles().findIndex(card => card === this);
const row = Math.floor(index / $GameBoard.width);
const column = index % $GameBoard.width;
return {row, column, index}
}
leftNeighbor() {
const pos = this.getOwnPosition();
if (pos.column === 0) {
return new Wall();
}
return $GameBoard.tiles()[pos.index - 1];
}
rightNeighbor() {
const pos = this.getOwnPosition();
if (pos.column === $GameBoard.width - 1) {
return new Wall();
}
return $GameBoard.tiles()[pos.index + 1];
}
topNeighbor() {
const pos = this.getOwnPosition();
if (pos.row === 0) {
return new Wall();
}
return $GameBoard.tiles()[pos.index - $GameBoard.width];
}
bottomNeighbor() {
const pos = this.getOwnPosition();
if (pos.row === $GameBoard.height - 1) {
return new Wall();
}
return $GameBoard.tiles()[pos.index + $GameBoard.width];
}
}
class Gameboard {
constructor(width, height) {
this.width = width;
this.height = height;
this.createTiles();
}
tiles() {
return this._tiles;
}
createTiles() {
this._tiles = [];
for (let i = 1; i <= this.width * this.height; i++) {
this.addCardToSlot();
}
}
addCardToSlot() {
const min = 1;
const max = 9;
const values = Array.from({ length: 4 }, () => this.createRandomNumber(min, max))
this._tiles.push(new Card(values));
}
createRandomNumber(min, max) {
return Math.floor((Math.random() * (max - min + 1))) + min;
}
}
// Create Board
const $GameBoard = new Gameboard(3, 3);
// Neighbor example
// retrieves the values of the card above the fourth card (row 2, column 1)
console.log($GameBoard.tiles()[3].topNeighbor().values)
good and you? do you have a nice day ?
Hello, Im new here. Nice to meet you
![]()
Seems like I managed to get you nut whit the last pictures i sendThis just in!
You must be registered to see attachments
There's still time to get your entries in! You can win 500 LC coins of the remaining 1,000 LC Coins!
And as a reminder to all of the contestants, the "Make Mime Nut" Bounty Hunt is always active, so you don't have to wait for lightning bounty hunts if you think you can win that one!
You must be registered to see attachments
Hello my lustful lewdians, how goes the monday ?
ow bebou =<, I hope it's gonna be all rightWas ok til a few minutes ago. I think i got dumped but .....mixed signals ya know
Hello, I'm Bonky and this is my first day as well. It's nice to meet you IIIIIIIIII
You must be registered to see attachments
I hope we don't have that many corpsy crime around to need such a job title.What do you call the people who clean up crime scenes and corpses in your countries?
in France it's all just "nettoyeur" (cleaners), maybe it's different where you live! v=
Bonky got out of his straightjacket again.. come here. Don't make me ask you twice. You know my temper!Was ok til a few minutes ago. I think i got dumped but .....mixed signals ya know
Hello, I'm Bonky and this is my first day as well. It's nice to meet you IIIIIIIIII
You must be registered to see attachments
Which adblock you are using? I'm on ublock origin and everything works ok.You must be registered to see attachments
You must be registered to see attachments
that was weird now, for some reason adblock started to block replies on this site, if i have it on cant reply and have to confirm likes.
worked fine till now tho
yes, I hope too x). I'm just asking myself the questions since I told myself that Guz was a kind of "nettoyeur" x:I hope we don't have that many corpsy crime around to need such a job title.
i using ublock, adguard (one making issues) and duck essentialsWhich adblock you are using? I'm on ublock origin and everything works ok.
slow and slower and it's hot!!You must be registered to see attachments
Hello my lustful lewdians, how goes the monday ?

yes, I hope too x). I'm just asking myself the questions since I told myself that Guz was a kind of "nettoyeur" x:
You must be registered to see attachments
Double adblock? That might cause a conflict. Can you try with a single one?i using ublock, adguard (one making issues) and duck essentials
You must be registered to see attachments
tripple and works fine. well 2 are still working just 1 is down. not 1st time adguard had some issues. tho was weird, wasn't sure if have pissed someone up and got blocked for replies orDouble adblock? That might cause a conflict. Can you try with a single one?
Feet up, watching the Olympics, enjoying the start of a well deserved week off work and first time off since christmas. Feel free to hate me now.You must be registered to see attachments
Hello my lustful lewdians, how goes the monday ?
This site provides links to other sites/services, and does not store any files