TechBlog cikkei

Exponenciális interpolálás 3 ponton

Unknown magic content: 'mathml'

Egy zenei fórumon a következő problémába futottam: valaki exponenciálisan szeretne paramétereket skálázni. Ez azt jelenti, hogy van egy $[x_\min, x_\max]$ intervallum, amit exponenciálisan le szeretne képezni egy $[y_\min, y_\max]$ intervallumra. A feltétel, amit előírt, hogy van egy bizonyos $x_\mathrm{avg}$ szám, aminek a képe az $y_\mathrm{avg}$ számnak kell, hogy legyen (az eddig megadott hat valós szám tehát előre ismert paraméter).

Ebből kéne kitalálni, hogy melyik az az $y = a \mathrm{exp}\left(bx\right) + c$ alakú függvény, ami az egyik intervallumot a másikra képezi.

Elsőre látszik, hogy itt a kulcs a $b$ paraméter meghatározása lesz. Ha ugyanis $b$ ismert, akkor $a$ és $c$ meghatározása visszavezetődik egy lineáris egyenletrendszer megoldására, a következő módon:

$a = \frac{y_\min - y_\mathrm{avg}}{\mathrm{exp}\left(bx_\min\right) - \mathrm{exp}\left(bx_\mathrm{avg}\right)}$

$c = y_\min - a \mathrm{exp}\left(bx_\min\right)$

A probléma tehát tényleg a $b$ paraméter megadásán múlik.

Ha az ember kellően sokat ügyeskedik, akkor a fenti kifejezések visszahelyettesítésével végül a következő egyenletig jut el:

$\frac{\gamma^{\alpha-1} - 1}{\gamma^{\beta-1} - 1} = \frac{y_\min - y_\mathrm{avg}}{y_\max - y_\min}$,

ahol $\alpha = \frac{x_\mathrm{avg}}{x_\min}$ , $\beta = \frac{x_\max}{x_\min}$ és $\gamma = \mathrm{exp}\left(bx^\min\right)$. Vagyis, ha sikerülne a fenti egyenletből $\gamma$-t meghatározni, akkor kész is vagyunk.

És ez az a pont, ahol elakadtam...

Tagek:
 
Utoljára módosította SAdam 2012.VIII.28 17:02-n; 9 hozzászólás
Bejegyzés módosítása | PermaLink
Szavazás letiltva.

Team Fortress 2 LAN-ban

Ezt a linket elteszem az utókor számára, ha még egyszer találkoznánk ezzel a problémával:

http://gaming.stackexchange.com/questions/26664/how-can-my-friend-and-i-play-tf2-against-bots

A lényeg:

Here is an instruction on how to create a server and put bots on it:

  1. Make sure you have the port 27015 accessible for connections.
  2. Open the game console. (Options⇨Keyboard⇨Advanced...⇨Enable developer console. Press ~ / ` to open the console at any time.)
  3. Type sv_lan 0 if you want the game to be public, or sv_lan 1 for LAN only.
  4. Type map <mapname>, replacing <mapname> with the name of the map you want to play. Or press the [+] to the right of BROWSE SERVERS in main menu instead.
  5. If the server is public and you don't want anyone to intrude, you can set a password: Type sv_password <pass>, replacing <pass> with some simple password. (e.g. sv_password 1234)
  6. Set the bot difficulty: tf_bot_difficulty <x>, where <x> is from 0 (the easiest) to 3.
  7. Add bots: tf_bot_add <team> <class> (<team>: red | blue; <class>: scout | soldier | pyro | demoman | heavyweapons | engineer | medic | sniper | spy.) To remove all bots: tf_bot_kick all

Here are some ways for your friend to connect. If one fails, try the next one.

  • Join the game via Steam. (In Steam Friends list press ▼ and Join Game. In console: connect <ip>:27015, where <ip> is your (server's) IP address, e.g. connect 11.22.33.44:27015)
  • Try the same thing with your (server's) local IP address (find it in Windows/Linux)

If nothing works, see the step 1 of server creation instruction.

Tagek:
 
Utoljára módosította SAdam 2012.VIII.18 20:42-n; 0 hozzászólás
Bejegyzés módosítása | PermaLink
Szavazás letiltva.

Help Faulty Design!

Épp "rajzolgatós progit" csinálok. Az elvárás valami olyasmi, a felhasználó ne csak egyszerűen rajzparancsokat tudjon definiálni, hanem ún. layereket is. Egy layer (vagy sprite) egy "vászon a vászonon", vagyis egy olyan logikai egység a képen, ami egybe tud fogni több rajzolási parancsot, és utána ezekre egységesen lehet hivatkozni (pl. ha definiálod a "nyuszi" layert, amire kirajzolsz egy csomó kört meg vonalat, amiből kijön a nyuszi, akkor később, amikor ebbe bele akarsz zoomolni, vagy odébb akarod taszigálni a vásznon, nem kell minden kört és vonalat újradefiniálni, elég lesz csak a "nyuszi" layert odébbtolni).

Az első ötletem az volt, hogy lesz egy Shape nevű absztrakt ős-osztályom, aminek lesz egy absztrakt paint nevű metódusa. Ennek lesznek gyermek-osztályai (line, arc stb.), akik implementálják a paint metódust. Amikor a Layer osztály kirajzolja magát, akkor pusztán annyit kell tenni, hogy végigiterál azokon a Shape-származékokon, amik hozzá lettek regisztrálva, és mindegyiknek meghívja a paint metódusát. Mivel a felhasználás során várhatóan egy csomó transzformációnak lesz kitéve maga a Layer, ami az egyes Shape-eket meghatározó koordináták újraszámolását igényli, ezért az első ötletem az volt, hogy a koordinátákat nem az egyes Shape-gyermekek példányai fogják tárolni, hanem magának a Layer-nek lesz egy változója, ami egy egybefüggő memóriaterületen eltárolja az összes rajzolóparancs összes pontját, így a geometriai transzformációknál elég lesz ezen a memóriaterületen végigiterálni, ami tippem szerint gyorsabb, mint egyenként végigugrálni az egyes Shape-eken.

Amikor egy bizonyos technikai részletkérdéssel felmentem a stackoverflow.com-ra és elmeséltem a problémát (http://stackoverflow.com/questions/10915568/is-it-possible-to-declare-a-virtual-static-constant-value-in-a-c-class) az egyik commentemben, azt a választ kaptam, hogy ez így hibás design és javasolták a Head First Design Patterns című könyv tanulmányozását (amire most se pénzem, se időm nincs, sajnos, pedig tényleg érdekesnek hangzik).

Azóta gondolkodom rajta, hogy vajon miért olyan hibás ez a design, illetve, hogy mit kéne benne máshogy csinálni, hogy egy hozzáértő is azt mondja rá, hogy jó a design.

Van bármi ötletetek?

Tagek:
 
Utoljára módosította SAdam 2012.VI.08 11:22-n; 13 hozzászólás
Bejegyzés módosítása | PermaLink
Szavazás letiltva.

A programozás olyan...

A programozás olyan, mint a szex koton nélkül.

Egy aprócska hiba, és életed végéig támogathatod.

Tagek:
 
Utoljára módosította UPi 2012.VI.08 11:12-n; 0 hozzászólás
Bejegyzés módosítása | PermaLink
Szavazás letiltva.

Dead Island

Ezt a rövidke értekezést a Metacritic oldalra írtam a címben szereplő játékról. Gondoltam, bemásolom ide is, hátha valakit érdekel. – UPi

I think this game is a huge missed opportunity. They obviously spent a lot of effort on creating a world rich in eye candy. Unfortunately you will spend most of your time traveling to various locations and brawling with the same few types of zombies, running boring errands that you won't care much about anyways. Did I say "repetitive"? I lost count on how many times I had to do the jumpkick / stomp on the head killer combo.

It is unfortunate that such a rich environment should inform the player so poorly. An openable door, a breakable door and a piece of wall that just appears like a door all look the same. There are invisible barriers designed to keep you on track that you just can't pass. The "GPS" supposed to help you navigate from point A to B on a boring trek will cheerfully try to lead you through solid walls. After a daring jump you can simply get stuck somewhere and have to restart from a checkpoint.

You cannot save. You have the one game progress that is automatically kept for you. Seriously, games in the 90's had saves!

And then there are the big and small aggravations. You can carry a hundred medkits and they take up one inventory slot. But 13 knives? No. I won't even go into weapon breakage.

Pick up a bottle of alcohol, and it becomes your active weapon. (You don't notice this because you don't see the bottle anymore.) So next time a zombie attacks you and you click attack what happens? Your hero DRINKS IT RIGHT ON THE SPOT and gets drunk in the middle of a fight. God...

But all these little faults are irrelevant compared to the fact that the game just fails to connect emotionally. The NPC's are bland, their terror unauthentic, acts and needs out of touch. There's a woman in the middle of the zombie apocalypse NEXT TO A SWIMMING POOL asking you for water. (Gives you 100XP for each bottle, oh yeah, now I'm immersed.) People huddle in shelters with the door wide open. Yeah, now I really believe their fear of inevitable death. Sometimes NPCs attempt to instill a sense of urgency with lines like "We must waste no more time", all the while comfortably standing in one spot, doing nothing. The lines are repetitive (oh only you can help us, thank you so much for your help, our heroes), the voice acting uninspired. In the end I started to think these people deserved the undead brought upon them, which in my mind turned the zombies into the game's protagonists. The "plot", well... worse than a summer blockbuster, except there are no twists. The game just lacks atmosphere and spirit.

Tagek:
 
Utoljára módosította UPi 2012.V.30 22:03-n; 2 hozzászólás
Bejegyzés módosítása | PermaLink
Szavazás letiltva.