← Home ← Back to /g/

Thread 105687698

13 posts 8 images /g/
Anonymous No.105687698 [Report] >>105687713 >>105687727 >>105687776 >>105687869 >>105688410 >>105688468 >>105688752 >>105688799 >>105690985
im a programmer and im making a tictactoe ai right now using rust. what you suggest to help me improve?
Anonymous No.105687713 [Report] >>105687737
>>105687698 (OP)
>what you suggest to help me improve?
Anonymous No.105687727 [Report] >>105687737
>>105687698 (OP)
Castration
Anonymous No.105687737 [Report] >>105688377
>>105687713
First post seethe post
>>105687727
Second post seethe post

It's too easy
Anonymous No.105687776 [Report]
>>105687698 (OP)
>what you suggest to help me improve?
Anonymous No.105687869 [Report] >>105688476
>>105687698 (OP)
>core::fmt
>std::fmt
>not deriving clone, copy, debug, etc...
>&'b CellValue
absolute shit code
Anonymous No.105688377 [Report]
>>105687737
3rd post, cope post
Anonymous No.105688410 [Report]
>>105687698 (OP)
there is zero need for references and that lifetime
Anonymous No.105688468 [Report]
>>105687698 (OP)
use luajit. its way simpler
Anonymous No.105688476 [Report]
>>105687869
you have no idea what youre talking about
its just tictactoe retard
Anonymous No.105688752 [Report]
>>105687698 (OP)
Why does the board reference cells instead of owning them. A board is defined as a collection of cells.
Why are you givibg every cell a name instead of using [[CellValue; 3]; 3] (or [CellValue; 9], no difference)
Anonymous No.105688799 [Report]
>>105687698 (OP)
Since all your cells are &'b, you should definitely use an array (or better a slice) to store them.
Then you can use whatever rust's equivalent of c++'s mdspan to easily access them in a 2d array maner.

Also, it would make more sense that the tic-tac-toe board owns the cells. I don't know what your initialization logic looks like, but it would greatly help if you delegated the cell's initialization to the board. You'll find out soon enough, when you try to mutate a cell that is already immutably borrowed by the board
Anonymous No.105690985 [Report]
>>105687698 (OP)
a cell has 3 states -> so you need 2 bits to represent a cell the entire board could be represented in 18 bits so you need one u32

then you could create every state for which one player wins for this u32 and just match against them and match to the flipped version for the other player

by this you avoid every loop and every lifetime

if you don't do this why exactly does the board not have ownership of all the CellValues?